[llvm] r301983 - ARM: avoid handing a deleted node back to TableGen during ISel.
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Tue May 2 15:45:19 PDT 2017
Author: tnorthover
Date: Tue May 2 17:45:19 2017
New Revision: 301983
URL: http://llvm.org/viewvc/llvm-project?rev=301983&view=rev
Log:
ARM: avoid handing a deleted node back to TableGen during ISel.
When we replaced the multiplicand the destination node might already exist.
When that happens the original gets CSEd and deleted. However, it's actually
used as the offset so nonsense is produced.
Should fix PR32726.
Added:
llvm/trunk/test/CodeGen/ARM/load-arm.ll
Modified:
llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=301983&r1=301982&r2=301983&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue May 2 17:45:19 2017
@@ -740,7 +740,9 @@ bool ARMDAGToDAGISel::SelectLdStSOReg(SD
unsigned PowerOfTwo = 0;
SDValue NewMulConst;
if (canExtractShiftFromMul(Offset, 31, PowerOfTwo, NewMulConst)) {
+ HandleSDNode Handle(Offset);
replaceDAGValue(Offset.getOperand(1), NewMulConst);
+ Offset = Handle.getValue();
ShAmt = PowerOfTwo;
ShOpcVal = ARM_AM::lsl;
}
@@ -1420,7 +1422,9 @@ bool ARMDAGToDAGISel::SelectT2AddrModeSo
unsigned PowerOfTwo = 0;
SDValue NewMulConst;
if (canExtractShiftFromMul(OffReg, 3, PowerOfTwo, NewMulConst)) {
+ HandleSDNode Handle(OffReg);
replaceDAGValue(OffReg.getOperand(1), NewMulConst);
+ OffReg = Handle.getValue();
ShAmt = PowerOfTwo;
}
}
Added: llvm/trunk/test/CodeGen/ARM/load-arm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/load-arm.ll?rev=301983&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/load-arm.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/load-arm.ll Tue May 2 17:45:19 2017
@@ -0,0 +1,17 @@
+; RUN: llc -mtriple=arm %s -o - | FileCheck %s
+; RUN: llc -mtriple=thumbv7 %s -o - | FileCheck %s
+
+; We ended up feeding a deleted node back to TableGen when we converted "Off *
+; 410" into "(Off * 205) << 1", where the multiplication already existed in the
+; DAG.
+
+; CHECK-LABEL: addrmode_cse_mutation:
+; CHECK: {{mul|muls}} [[OFFSET:r[0-9]+]], {{r[0-9]+}}, {{r[0-9]+}}
+; CHECK: {{ldrb|ldrb.w}} {{r[0-9]+}}, [r0, [[OFFSET]], lsl #3]
+define i32 @addrmode_cse_mutation(i8* %base, i32 %count) {
+ %offset = mul i32 %count, 277288
+ %ptr = getelementptr i8, i8* %base, i32 %offset
+ %val = load volatile i8, i8* %ptr
+ %res = mul i32 %count, 34661
+ ret i32 %res
+}
More information about the llvm-commits
mailing list