Skip to content

Commit 8702e84

Browse files
committed
Fixes #168690
Prevents assertion in CGBuiltin for i1 - returns identity. Created test file for the same.
1 parent 669c30c commit 8702e84

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3653,6 +3653,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
36533653
Value *ArgValue = EmitScalarExpr(E->getArg(0));
36543654
llvm::IntegerType *IntTy = cast<llvm::IntegerType>(ArgValue->getType());
36553655
assert(IntTy && "LLVM's __builtin_bswapg only supports integer variants");
3656+
if (IntTy->getBitWidth() == 1)
3657+
return RValue::get(ArgValue);
36563658
assert(((IntTy->getBitWidth() % 16 == 0 && IntTy->getBitWidth() != 0) ||
36573659
IntTy->getBitWidth() == 8) &&
36583660
"LLVM's __builtin_bswapg only supports integer variants that has a "
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -triple x86_64 -O0 -emit-llvm -o - %s | FileCheck %s
2+
3+
auto test_bswapg(bool c) {
4+
return __builtin_bswapg(c);
5+
}
6+
7+
// CHECK-LABEL: define{{.*}} i1 @_Z11test_bswapgb(
8+
// CHECK: ret i1 %{{.*}}

0 commit comments

Comments
 (0)