Fixes https://bugs.llvm.org/show_bug.cgi?id=46009
See the link for a more detailed analysis
Details
Diff Detail
Event Timeline
llvm/test/DebugInfo/MIR/X86/branch-folder-hoisting-location.mir | ||
---|---|---|
1–6 | Probably this test can be trimmed, but I wanted to put this online to get a general feeling of the idea. |
Also, looks like this one exposed a bug in LiveDbgValues. I'll look at it while waiting for the review:
******************** TEST 'LLVM :: CodeGen/X86/dbg-changes-codegen-branch-folding.ll' FAILED ******************** Script: -- : 'RUN: at line 1'; /Users/davide/work/build/bin/llc -mtriple=x86_64-linux < /Users/davide/work/llvm-project/llvm/test/CodeGen/X86/dbg-changes-codegen-branch-folding.ll | /Users/davide/work/build/bin/FileCheck /Users/davide/work/llvm-project/llvm/test/CodeGen/X86/dbg-changes-codegen-branch-folding.ll : 'RUN: at line 2'; /Users/davide/work/build/bin/opt -strip-debug < /Users/davide/work/llvm-project/llvm/test/CodeGen/X86/dbg-changes-codegen-branch-folding.ll | /Users/davide/work/build/bin/llc -mtriple=x86_64-linux | /Users/davide/work/build/bin/FileCheck /Users/davide/work/llvm-project/llvm/test/CodeGen/X86/dbg-changes-codegen-branch-folding.ll -- Exit Code: 2 Command Output (stderr): -- PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump: 0. Program arguments: /Users/davide/work/build/bin/llc -mtriple=x86_64-linux 1. Running pass 'Function Pass Manager' on module '<stdin>'. 2. Running pass 'Live DEBUG_VALUE analysis' on function '@_Z3barii' 0 llc 0x00000001031bc825 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37 1 llc 0x00000001031bb6a8 llvm::sys::RunSignalHandlers() + 248 2 llc 0x00000001031bce26 SignalHandler(int) + 262 3 libsystem_platform.dylib 0x00007fff7223355d _sigtramp + 29 4 libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338601253568 5 llc 0x000000010285958d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 285 6 llc 0x0000000102b82658 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1064 7 llc 0x0000000102b82933 llvm::FPPassManager::runOnModule(llvm::Module&) + 67 8 llc 0x0000000102b82dd9 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 937 9 llc 0x0000000101627b3f compileModule(char**, llvm::LLVMContext&) + 9647 10 llc 0x000000010162508c main + 1308 11 libdyld.dylib 0x00007fff72026259 start + 1 12 libdyld.dylib 0x0000000000000002 start + 18446603338603404714 FileCheck error: '<stdin>' is empty. FileCheck command line: /Users/davide/work/build/bin/FileCheck /Users/davide/work/llvm-project/llvm/test/CodeGen/X86/dbg-changes-codegen-branch-folding.ll
Yes, I captured the MIR before my patch and realized LiveDebugValues crashes without it. It's just the MIR presented to the pass that causes the problem. I'm going to file a separate PR for it.
llvm/lib/CodeGen/BranchFolding.cpp | ||
---|---|---|
2028 | I've drafted some rules for updating debug locs here: https://reviews.llvm.org/D81198. We haven't reached consensus around those rules, but my $0.02 is that HoistCommonCodeInSuccs should: a) clear the debug locs on the instructions it hoists if it found identical instructions in multiple successor blocks, and b) /not/ hoist any DBG_VALUEs. I haven't written up rules for dealing with DBG_VALUEs yet, but I think the guiding principle is going to be 'touch dbg.value/DBG_VALUE as little as possible' to avoid having assignments show up too early. |
Back to this. I think what Vedant suggest is the right approach and I'll try implementing it now.
To summarize some offline discussions: