-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[CLANG] Fixes the issue with using bool in builtin_bswapg #169285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-clang Author: Ebin Jose (ebinjose02) ChangesFixes #168690 Full diff: https://github.com/llvm/llvm-project/pull/169285.diff 2 Files Affected:
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<llvm::IntegerType>(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.cpp b/clang/test/CodeGen/builtin_bswapg.cpp
new file mode 100644
index 0000000000000..8e9af98a58d35
--- /dev/null
+++ b/clang/test/CodeGen/builtin_bswapg.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64 -O0 -emit-llvm -o - %s | FileCheck %s
+
+auto test_bswapg(bool c) {
+ return __builtin_bswapg(c);
+}
+
+// CHECK-LABEL: define{{.*}} i1 @_Z11test_bswapgb(
+// CHECK: ret i1 %{{.*}}
|
|
@llvm/pr-subscribers-clang-codegen Author: Ebin Jose (ebinjose02) ChangesFixes #168690 Full diff: https://github.com/llvm/llvm-project/pull/169285.diff 2 Files Affected:
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<llvm::IntegerType>(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.cpp b/clang/test/CodeGen/builtin_bswapg.cpp
new file mode 100644
index 0000000000000..8e9af98a58d35
--- /dev/null
+++ b/clang/test/CodeGen/builtin_bswapg.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64 -O0 -emit-llvm -o - %s | FileCheck %s
+
+auto test_bswapg(bool c) {
+ return __builtin_bswapg(c);
+}
+
+// CHECK-LABEL: define{{.*}} i1 @_Z11test_bswapgb(
+// CHECK: ret i1 %{{.*}}
|
fcf359f to
8702e84
Compare
🐧 Linux x64 Test Results
Failed Tests(click on a test name to see its output) ClangClang.CodeGen/builtin_bswapg.cIf these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the |
Prevents assertion in CGBuiltin for i1 - returns identity. Created test file for the same.
8702e84 to
4baf6aa
Compare
Fixes #168690
Prevents assertion in CGBuiltin for i1 - returns identity. Created test file for the same.