llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.61k stars 11.82k forks source link

[DAGCombiner] crash in BackwardsPropagateMask() when trying to debug #37041

Open rotateright opened 6 years ago

rotateright commented 6 years ago
Bugzilla Link 37693
Version trunk
OS All
CC @RKSimon,@sparker-arm

Extended Description

I was trying to view debug output for the test in bug 37060, but that asserts:

@​c = external local_unnamed_addr constant i32, align 4 @​d = external local_unnamed_addr global i32*, align 8 @​e = external local_unnamed_addr global i32, align 4

define void @​tf_0_foo() { entry: %0 = load i32, i32 @​c, align 4 %rem = srem i32 -1, %0 %1 = load i32, i32* @​d, align 8 %2 = load i32, i32 %1, align 4 %xor = xor i32 %2, %rem %conv3 = and i32 %xor, 255 store i32 %conv3, i32* @​e, align 4 ret void }

$ llc -o - 37060func.ll -debug

...

Propagate AND back to: t9: i32,ch = load<(load 4 from %ir.Assertion failed: (F && "No function incorporated"), function getLocalSlot, file /llvm/lib/IR/AsmWriter.cpp, line 844. Stack dump:

  1. Program arguments: ./llc -o - 37060func.ll -debug
  2. Running pass 'Function Pass Manager' on module '37060func.ll'.
  3. Running pass 'X86 DAG->DAG Instruction Selection' on function '@tf_0_foo' 0 llc 0x0000000103e6fa28 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40 1 llc 0x0000000103e6e9d5 llvm::sys::RunSignalHandlers() + 85 2 llc 0x0000000103e70032 SignalHandler(int) + 258 3 libsystem_platform.dylib 0x00007fff66ceef5a _sigtramp + 26 4 libsystem_platform.dylib 0x00007fc76dc1ee10 _sigtramp + 116588240 5 libsystem_c.dylib 0x00007fff66a8c1ae abort + 127 6 libsystem_c.dylib 0x00007fff66a541ac basename_r + 0 7 llc 0x000000010371f293 llvm::ModuleSlotTracker::getLocalSlot(llvm::Value const) + 51 8 llc 0x00000001035540d7 llvm::MachineMemOperand::print(llvm::raw_ostream&, llvm::ModuleSlotTracker&, llvm::SmallVectorImpl&, llvm::LLVMContext const&, llvm::MachineFrameInfo const, llvm::TargetInstrInfo const) const + 3991 9 llc 0x0000000103d7742d printMemOperand(llvm::raw_ostream&, llvm::MachineMemOperand const&, llvm::SelectionDAG const) + 301 10 llc 0x0000000103d7656e llvm::SDNode::print_details(llvm::raw_ostream&, llvm::SelectionDAG const) const + 4414 11 llc 0x0000000103d7785e llvm::SDNode::printr(llvm::raw_ostream&, llvm::SelectionDAG const) const + 350 12 llc 0x0000000103d75150 llvm::SDNode::print(llvm::raw_ostream&, llvm::SelectionDAG const) const + 32 13 llc 0x0000000103d75100 llvm::SDNode::dump(llvm::SelectionDAG const) const + 32 14 llc 0x0000000103bab9f8 (anonymous namespace)::DAGCombiner::visitAND(llvm::SDNode*) + 13208
rotateright commented 6 years ago

Interestingly, the bug isn't visible if I remove the BB label ("entry") and rename the temp variables. Also, I don't think this is a mac-specific bug, but you're correct that I'm testing on a Mac with a release+asserts build of llc.

rotateright commented 6 years ago

There's still a bug here. It won't repro for an x86 target now that the transform doesn't fire there, but I still assert when targeting aarch64 for example:

$ llc -o - 37060func.ll -debug -mtriple=aarch64

...

Combining: t12: i32 = and t10, Constant:i32<255> Backwards propagate AND: t12: i32 = and t10, Constant:i32<255> First, need to fix up: t21: i32 = mul t20, t4 Creating new node: t36: i32 = and t21, Constant:i32<255> Propagate AND back to: t9: i32,ch = load<(load 4 from %ir.Assertion failed: (F && "No function incorporated"), function getLocalSlot, file /Users/spatel/myllvm/llvm/lib/IR/AsmWriter.cpp, line 844

sparker-arm commented 6 years ago

Hi Sanjay,

Do you still have this issue? If so, I'll get on my mac and have a look.