-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
OpenCLclang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]Prefer [crash-on-valid] or [crash-on-invalid]
Description
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:
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:
Metadata
Metadata
Assignees
Labels
OpenCLclang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]Prefer [crash-on-valid] or [crash-on-invalid]