llvm / llvm/llvm-project

[GlobalISel] Crash on inline asm with a direct memory output constraint

Open
#207,440 1 comment 0 reactions 0 assignees View on GitHub
backend:AArch64 confirmed crash-on-valid llvm:globalisel
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```llvm
define i64 @f() {
%v = call i64 asm "", "=rm"()
ret i64 %v
}
```

```llvm
define i64 @f() {
%v = call i64 asm "", "=m"()
ret i64 %v
}
```

Both crash with

```
Stack dump:
0. Program arguments: /home/lonewolf/llvm-project/build/bin/llc -mtriple=aarch64-unknown-linux-gnu -global-isel test-m.ll
1. Running pass 'Function Pass Manager' on module 'test-m.ll'.
2. Running pass 'IRTranslator' on function '@f'
#0 0x00006218fdba7ca9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/lonewolf/llvm-project/build/bin/llc+0x38f2ca9)
#1 0x00006218fdba49dc llvm::sys::RunSignalHandlers() (/home/lonewolf/llvm-project/build/bin/llc+0x38ef9dc)
#2 0x00006218fdba4b42 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007a743f842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00006218fe58e95c llvm::IRTranslator::getOrCreateVRegs(llvm::Value const&) (/home/lonewolf/llvm-project/build/bin/llc+0x42d995c)
#5 0x00006218fe590630 std::_Function_handler (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
#6 0x00006218fe5a8060 llvm::InlineAsmLowering::lowerInlineAsm(llvm::MachineIRBuilder&, llvm::CallBase const&, std::function (llvm::Value const&)>) const (/home/lonewolf/llvm-project/build/bin/llc+0x42f3060)
#7 0x00006218fe5842d5 llvm::IRTranslator::translateInlineAsm(llvm::CallBase const&, llvm::MachineIRBuilder&) (/home/lonewolf/llvm-project/build/bin/llc+0x42cf2d5)
#8 0x00006218fe5a42da llvm::IRTranslator::runOnMachineFunction(llvm::MachineFunction&) (/home/lonewolf/llvm-project/build/bin/llc+0x42ef2da)
#9 0x00006218fc8c59cc llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#10 0x00006218fcf28df5 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/lonewolf/llvm-project/build/bin/llc+0x2c73df5)
#11 0x00006218fcf293d9 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/lonewolf/llvm-project/build/bin/llc+0x2c743d9)
#12 0x00006218fcf29dc2 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) LegacyPassManager.cpp:0:0
#13 0x00006218fcf2a4fb llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/lonewolf/llvm-project/build/bin/llc+0x2c754fb)
#14 0x00006218fa910781 compileModule(char**, llvm::SmallVectorImpl&, llvm::LLVMContext&, std::__cxx11::basic_string, std::allocator>&) llc.cpp:0:0
#15 0x00006218fa84f08c main (/home/lonewolf/llvm-project/build/bin/llc+0x59a08c)
#16 0x00007a743f829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#17 0x00007a743f829e40 call_init ./csu/../csu/libc-start.c:128:20
#18 0x00007a743f829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#19 0x00006218fa905b95 _start (/home/lonewolf/llvm-project/build/bin/llc+0x650b95)
Segmentation fault (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the crash with llc, -mtriple=aarch64-unknown-linux-gnu, -global-isel, and the two inline-asm constraints shown. Inspect IRTranslator::translateInlineAsm in IRTranslator.cpp and InlineAsmLowering::lowerInlineAsm, where the stack trace ends; done means these inputs no longer crash during IR translation.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.