Issue |
123203
|
Summary |
[Clang][OpenCL] Compiler crash on __builtin_assume_aligned in OpenCL
|
Labels |
clang,
OpenCL,
crash
|
Assignees |
|
Reporter |
ritter-x2a
|
Using the return value of `__builtin_assume_aligned` in OpenCL hits an assertion in clang. I don't have a strong opinion on whether the builtin should be supported in OpenCL since it's not part of the Khronos spec, but it shouldn't hit an assertion.
Observed with a RelWithDebInfo trunk build, on Ubuntu 22.04.
Reproducer:
```c
void f(__global int *g) {
__global int *ag = __builtin_assume_aligned(g, 16);
}
```
When compiling this via `clang -c test.cl`, clang first reports unexpected diagnostics (I don't see how `bool`s are involved) and then hits an assertion:
```
test.cl:2:17: error: incompatible integer to pointer conversion initializing '__global int *__private' with an _expression_ of type 'bool' [-Wint-conversion]
2 | __global int *ag = __builtin_assume_aligned(g, 16);
| ^ ~~~~~~
clang: /home/faritter/playground/llvm/llvm-project/llvm/lib/IR/Instructions.cpp:2974: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::InsertPosition): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: ./build/bin/clang -c test.cl
1. <eof> parser at end of file
2. test.cl:1:6: LLVM IR generation of declaration 'f'
3. test.cl:1:6: Generating code for declaration 'f'
#0 0x000056e464acc7ff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/faritter/playground/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:802:3
[...]
#13 0x000056e4636a9852 llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::MDNode*, llvm::FMFSource) /home/faritter/playground/llvm/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2193:0
#14 0x000056e4636a9852 llvm::IRBuilderBase::CreateIntCast(llvm::Value*, llvm::Type*, bool, llvm::Twine const&) /home/faritter/playground/llvm/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2231:0
#15 0x000056e464e2f677 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) /home/faritter/playground/llvm/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:2574:44
#16 0x000056e464e2c104 Visit /home/faritter/playground/llvm/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:449:3
#17 0x000056e464e2c104 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) /home/faritter/playground/llvm/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:5591:13
[...]
```
The full backtrace, preprocessed source, and run script are attached:
[backtrace.txt](https://github.com/user-attachments/files/18440429/backtrace.txt)
[test-ff43fa.cl.txt](https://github.com/user-attachments/files/18440433/test-ff43fa.cl.txt)
[test-ff43fa.sh.txt](https://github.com/user-attachments/files/18440434/test-ff43fa.sh.txt)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs