Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

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

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR37693
Status NEW
Importance P enhancement
Reported by Sanjay Patel (spatel+llvm@rotateright.com)
Reported on 2018-06-05 11:33:09 -0700
Last modified on 2018-06-08 07:42:20 -0700
Version trunk
Hardware PC All
CC llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, sam.parker@arm.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also PR37060, PR37667
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:
0.  Program arguments: ./llc -o - 37060func.ll -debug
1.  Running pass 'Function Pass Manager' on module '37060func.ll'.
2.  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::StringRef>&, 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
Quuxplusone commented 6 years ago

Hi Sanjay,

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

Quuxplusone 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
Quuxplusone 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.