diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 93f691e4c2267..8bcc2c8e7d8fe 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -3653,6 +3653,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, Value *ArgValue = EmitScalarExpr(E->getArg(0)); llvm::IntegerType *IntTy = cast(ArgValue->getType()); assert(IntTy && "LLVM's __builtin_bswapg only supports integer variants"); + if (IntTy->getBitWidth() == 1) + return RValue::get(ArgValue); assert(((IntTy->getBitWidth() % 16 == 0 && IntTy->getBitWidth() != 0) || IntTy->getBitWidth() == 8) && "LLVM's __builtin_bswapg only supports integer variants that has a " diff --git a/clang/test/CodeGen/builtin_bswapg.c b/clang/test/CodeGen/builtin_bswapg.c new file mode 100644 index 0000000000000..35f4728d15d3a --- /dev/null +++ b/clang/test/CodeGen/builtin_bswapg.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -triple x86_64 -O0 -emit-llvm -o - %s | FileCheck %s +#include +bool test_bswapg(bool c) { + return __builtin_bswapg(c); +} + +// CHECK-LABEL: define{{.*}} i1 @_Z11test_bswapgb( +// CHECK: ret i1 %{{.*}}