Open
Description
I created a simple .ll file which calls trampoline functions, and clang(14.0.6) crashed on it:
Stack dump:
0. Program arguments: /opt/homebrew/Cellar/llvm/14.0.6_1/bin/clang-14 -cc1 -triple arm64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name a.ll -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -funwind-tables=2 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 -target-feature +v8.5a -target-feature +fp-armv8 -target-feature +neon -target-feature +crc -target-feature +crypto -target-feature +dotprod -target-feature +fp16fml -target-feature +ras -target-feature +lse -target-feature +rdm -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=lldb -target-linker-version 764 -fcoverage-compilation-dir=/Users/bobli/src/calc -resource-dir /opt/homebrew/Cellar/llvm/14.0.6_1/lib/clang/14.0.6 -fdebug-compilation-dir=/Users/bobli/src/calc -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcolor-diagnostics -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/bm/4rksdqgn30g5zn2yscfr0p7w0000gn/T/a-5b76d2.o -x ir a.ll
1. Code generation
2. Running pass 'Function Pass Manager' on module 'a.ll'.
3. Running pass 'AArch64 Instruction Selection' on function '@main'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 libLLVM.dylib 0x0000000112f50d14 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 libLLVM.dylib 0x00000001158e2d64 SignalHandler(int) + 304
2 libsystem_platform.dylib 0x00000001af9284e4 _sigtramp + 56
3 libLLVM.dylib 0x0000000113506de0 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) + 2008
4 libLLVM.dylib 0x0000000113506de0 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) + 2008
5 libLLVM.dylib 0x0000000113506494 llvm::SelectionDAG::Legalize() + 336
6 libLLVM.dylib 0x000000011369c89c llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 664
7 libLLVM.dylib 0x000000011369becc llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 4916
8 libLLVM.dylib 0x000000011369a020 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1784
9 libLLVM.dylib 0x0000000113279810 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 296
10 libLLVM.dylib 0x0000000113089728 llvm::FPPassManager::runOnModule(llvm::Module&) + 1100
11 libLLVM.dylib 0x0000000113081fbc llvm::legacy::PassManagerImpl::run(llvm::Module&) + 864
12 libclang-cpp.dylib 0x0000000109c31cb0 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) + 1344
13 libclang-cpp.dylib 0x0000000109f04ff4 clang::CodeGenAction::ExecuteAction() + 1604
14 libclang-cpp.dylib 0x000000010a48d158 clang::FrontendAction::Execute() + 96
15 libclang-cpp.dylib 0x000000010a40add8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 556
16 libclang-cpp.dylib 0x000000010a4d5fd0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 512
17 clang-14 0x0000000104ec3030 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1284
18 clang-14 0x0000000104ec1c7c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 804
19 clang-14 0x0000000104ec12fc main + 11884
20 dyld 0x000000010529d0f4 start + 520
clang-14: error: unable to execute command: Trace/BPT trap: 5
clang-14: error: clang frontend command failed due to signal (use -v to see invocation)
Homebrew clang version 14.0.6
Target: arm64-apple-darwin21.3.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
clang-14: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
source file
declare void @llvm.init.trampoline(i8*, i8*, i8*);
declare i8* @llvm.adjust.trampoline(i8*);
declare void @__enable_execute_stack(i8* %tramp)
define i32 @foo(i32* nest %ptr, i32 %val) {
%x = load i32, i32* %ptr
%sum = add i32 %x, %val
ret i32 %sum
}
define i32 @main(i32, i8**) {
%closure = alloca i32
store i32 13, i32* %closure
%closure_ptr = bitcast i32* %closure to i8*
%tramp_buf = alloca [72 x i8], align 16
%tramp_ptr = getelementptr [72 x i8], [72 x i8]* %tramp_buf, i32 0, i32 0
call void @__enable_execute_stack(i8* %tramp_ptr)
call void @llvm.init.trampoline(
i8* %tramp_ptr,
i8* bitcast (i32 (i32*, i32)* @foo to i8*),
i8* %closure_ptr)
%ptr = call i8* @llvm.adjust.trampoline(i8* %tramp_ptr)
%fp = bitcast i8* %ptr to i32(i32)*
%res = call i32 %fp (i32 13)
ret i32 1
}
system info
Hardware Overview:
Model Name: MacBook Pro
Model Identifier: MacBookPro18,1
Chip: Apple M1 Pro
Total Number of Cores: 10 (8 performance and 2 efficiency)
Memory: 16 GB
System Firmware Version: 7429.81.3
OS Loader Version: 7429.81.3
clang info
Homebrew clang version 14.0.6
Target: arm64-apple-darwin21.3.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin