lonemeow wrote:
I was looking into whether this exposes an existing GlobalISel crash, and found
that it actually introduces a new crash on both SelectionDAG and GlobalISel
when compiling for Aarch64 on -O2.
```c
unsigned long f(void) {
unsigned long x;
asm("# $0" : "=ro"(x));
return x;
}
```
Crashes with both `clang --target=aarch64-linux-gnu -O2 test.c`:
```
lonewolf@hyperwolf:~/test$ ~/llvm-pr197798/build/bin/clang
--target=aarch64-linux-gnu -O2 test.c
clang-23:
/home/lonewolf/llvm-pr197798/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:10333:
void computeConstraintToUse({anonymous}::ConstraintDecisionInfo&, const
llvm::CallBase&, llvm::TargetLowering::AsmOperandInfoVector&,
llvm::SelectionDAGBuilder&, const llvm::TargetLowering&, const
llvm::TargetMachine&, llvm::SelectionDAG&): Assertion
`(OpInfo.isMultipleAlternative || OpInfo.Type == InlineAsm::isInput) && "Can
only indirectify direct input operands!"' 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: /home/lonewolf/llvm-pr197798/build/bin/clang-23 -cc1
-triple aarch64-unknown-linux-gnu -O2 -emit-obj -dumpdir a- -disable-free
-clear-ast-before-backend -main-file-name test.c -mrelocation-model pic
-pic-level 2 -pic-is-pie -mframe-pointer=non-leaf-no-reserve -fmath-errno
-ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2
-enable-tlsdesc -target-cpu generic -target-feature +v8a -target-feature
+fp-armv8 -target-feature +neon -target-abi aapcs -debugger-tuning=gdb
-fdebug-compilation-dir=/home/lonewolf/test
-fcoverage-compilation-dir=/home/lonewolf/test -resource-dir
/home/lonewolf/llvm-pr197798/build/lib/clang/23 -internal-isystem
/home/lonewolf/llvm-pr197798/build/lib/clang/23/include -internal-isystem
/usr/local/include -internal-isystem
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-ferror-limit 19 -fmessage-length=120 -fno-signed-char -fgnuc-version=4.2.1
-fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp
-target-feature +outline-atomics -target-feature -fmv -faddrsig
-fdwarf2-cfi-asm -o /tmp/test-f48933.o -x c test.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'test.c'.
4. Running pass 'AArch64 Instruction Selection' on function '@f'
#0 0x00005e835ee72dc0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x2341dc0)
#1 0x00005e835ee6f98c llvm::sys::RunSignalHandlers()
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x233e98c)
#2 0x00005e835ee6faf2 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00005e835ee6fbac SignalHandlerTerminate(int, siginfo_t*, void*)
Signals.cpp:0:0
#4 0x00007fc2bb642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007fc2bb6969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#6 0x00007fc2bb6969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#7 0x00007fc2bb6969fc pthread_kill ./nptl/pthread_kill.c:89:10
#8 0x00007fc2bb642476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#9 0x00007fc2bb6287f3 abort ./stdlib/abort.c:81:7
#10 0x00007fc2bb62871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x00007fc2bb639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#12 0x00005e8360572064 llvm::SelectionDAGBuilder::visitInlineAsm(llvm::CallBase
const&, llvm::BasicBlock const*)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x3a41064)
#13 0x00005e83605a45cc llvm::SelectionDAGBuilder::visit(llvm::Instruction
const&) (/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x3a735cc)
#14 0x00005e8360646532
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction,
true, false, void, true, llvm::BasicBlock>, false, true>,
llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction,
true, false, void, true, llvm::BasicBlock>, false, true>, bool&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x3b15532)
#15 0x00005e8360646ffa
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x3b15ffa)
#16 0x00005e8360648933
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x3b17933)
#17 0x00005e8360631339
llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x3b00339)
#18 0x00005e835e14839b
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0)
MachineFunctionPass.cpp:0:0
#19 0x00005e835e87369f llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x1d4269f)
#20 0x00005e835e873af9 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x1d42af9)
#21 0x00005e835e874451 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x1d43451)
#22 0x00005e835f2b69ca clang::emitBackendOutput(clang::CompilerInstance&,
clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x27859ca)
#23 0x00005e835f99e432
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x2e6d432)
#24 0x00005e83616af8ac clang::ParseAST(clang::Sema&, bool, bool)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x4b7e8ac)
#25 0x00005e835fd15659 clang::FrontendAction::Execute()
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x31e4659)
#26 0x00005e835fc8ed88
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x315dd88)
#27 0x00005e835fe12b53
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x32e1b53)
#28 0x00005e835d82bac2 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/lonewolf/llvm-pr197798/build/bin/clang-23+0xcfaac2)
#29 0x00005e835d82175a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&,
llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>)
driver.cpp:0:0
#30 0x00005e835d825a5e clang_main(int, char**, llvm::ToolContext const&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0xcf4a5e)
#31 0x00005e835d739251 main
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0xc08251)
#32 0x00007fc2bb629d90 __libc_start_call_main
./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#33 0x00007fc2bb629e40 call_init ./csu/../csu/libc-start.c:128:20
#34 0x00007fc2bb629e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#35 0x00005e835d820e75 _start
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0xcefe75)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed with exit code -2 (use -v to see
invocation)
clang version 23.0.0git ([email protected]:llvm/llvm-project.git
4f40c263d3b97eefbad0ad62c81c6219ab3bec10)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/lonewolf/llvm-pr197798/build/bin
Build config: +assertions
```
And also with GlobalISel `clang --target=aarch64-linux-gnu -O2 -fglobal-isel
test.c`:
```
lonewolf@hyperwolf:~/test$ ~/llvm-pr197798/build/bin/clang
--target=aarch64-linux-gnu -O2 -fglobal-isel test.c
clang: warning: -fglobal-isel support is incomplete for this architecture at
the current optimization level [-Wglobal-isel]
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: /home/lonewolf/llvm-pr197798/build/bin/clang-23 -cc1
-triple aarch64-unknown-linux-gnu -O2 -emit-obj -dumpdir a- -disable-free
-clear-ast-before-backend -main-file-name test.c -mrelocation-model pic
-pic-level 2 -pic-is-pie -mframe-pointer=non-leaf-no-reserve -fmath-errno
-ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2
-enable-tlsdesc -target-cpu generic -target-feature +v8a -target-feature
+fp-armv8 -target-feature +neon -target-abi aapcs -debugger-tuning=gdb
-fdebug-compilation-dir=/home/lonewolf/test
-fcoverage-compilation-dir=/home/lonewolf/test -resource-dir
/home/lonewolf/llvm-pr197798/build/lib/clang/23 -internal-isystem
/home/lonewolf/llvm-pr197798/build/lib/clang/23/include -internal-isystem
/usr/local/include -internal-isystem
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-ferror-limit 19 -fmessage-length=120 -fno-signed-char -fgnuc-version=4.2.1
-fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp
-mllvm -global-isel=1 -mllvm -global-isel-abort=2 -target-feature
+outline-atomics -target-feature -fmv -faddrsig -fdwarf2-cfi-asm -o
/tmp/test-e0ede4.o -x c test.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'test.c'.
4. Running pass 'IRTranslator' on function '@f'
#0 0x0000559444d01dc0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x2341dc0)
#1 0x0000559444cfe98c llvm::sys::RunSignalHandlers()
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x233e98c)
#2 0x0000559444cfeaf2 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x0000559444cfebac SignalHandlerTerminate(int, siginfo_t*, void*)
Signals.cpp:0:0
#4 0x00007faf12c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x000055944619bee3 llvm::IRTranslator::getOrCreateVRegs(llvm::Value const&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x37dbee3)
#6 0x000055944619dcc0 std::_Function_handler<llvm::ArrayRef<llvm::Register>
(llvm::Value const&), llvm::IRTranslator::translateInlineAsm(llvm::CallBase
const&, llvm::MachineIRBuilder&)::'lambda'(llvm::Value
const&)>::_M_invoke(std::_Any_data const&, llvm::Value const&)
IRTranslator.cpp:0:0
#7 0x00005594461b6037
llvm::InlineAsmLowering::lowerInlineAsm(llvm::MachineIRBuilder&, llvm::CallBase
const&, std::function<llvm::ArrayRef<llvm::Register> (llvm::Value const&)>)
const (/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x37f6037)
#8 0x0000559446191195 llvm::IRTranslator::translateInlineAsm(llvm::CallBase
const&, llvm::MachineIRBuilder&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x37d1195)
#9 0x00005594461b2036
llvm::IRTranslator::runOnMachineFunction(llvm::MachineFunction&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x37f2036)
#10 0x0000559443fd739b
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0)
MachineFunctionPass.cpp:0:0
#11 0x000055944470269f llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x1d4269f)
#12 0x0000559444702af9 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x1d42af9)
#13 0x0000559444703451 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x1d43451)
#14 0x00005594451459ca clang::emitBackendOutput(clang::CompilerInstance&,
clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x27859ca)
#15 0x000055944582d432
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x2e6d432)
#16 0x000055944753e8ac clang::ParseAST(clang::Sema&, bool, bool)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x4b7e8ac)
#17 0x0000559445ba4659 clang::FrontendAction::Execute()
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x31e4659)
#18 0x0000559445b1dd88
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x315dd88)
#19 0x0000559445ca1b53
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0x32e1b53)
#20 0x00005594436baac2 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/lonewolf/llvm-pr197798/build/bin/clang-23+0xcfaac2)
#21 0x00005594436b075a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&,
llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>)
driver.cpp:0:0
#22 0x00005594436b4a5e clang_main(int, char**, llvm::ToolContext const&)
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0xcf4a5e)
#23 0x00005594435c8251 main
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0xc08251)
#24 0x00007faf12c29d90 __libc_start_call_main
./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#25 0x00007faf12c29e40 call_init ./csu/../csu/libc-start.c:128:20
#26 0x00007faf12c29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#27 0x00005594436afe75 _start
(/home/lonewolf/llvm-pr197798/build/bin/clang-23+0xcefe75)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed with exit code -2 (use -v to see
invocation)
clang version 23.0.0git ([email protected]:llvm/llvm-project.git
4f40c263d3b97eefbad0ad62c81c6219ab3bec10)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/lonewolf/llvm-pr197798/build/bin
Build config: +assertions
```
https://github.com/llvm/llvm-project/pull/197798
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits