[llvm] r273456 - Preserve DebugInfo when replacing values in DAGCombiner
Mikael Holmén via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 23 00:55:45 PDT 2016
Hi,
This commit seems to introduce way too many DBG_VALUE
During ISel I see
===== Instruction selection ends:
Selected selection DAG: BB#12 'two:bb12'
SelectionDAG has 50 nodes:
t1: i16 = load_stack_address_pseudo TargetFrameIndex:i16<0>
t6: i16 = mv_any16 TargetConstant:i16<202>, TargetConstant:i16<0>,
Register:i16 %noreg, TargetConstant:i16<0>
t0: ch = EntryToken
t9: ch = mv_any16_r16_nimm12<Mem:ST1[%_tmp199]> t6, t1,
TargetConstant:i16<3>, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t0
t41: i32,ch =
mv_r16_nimm12_ar32_aN32dst<Mem:LD2[%sunkaddr3](align=1)> t1,
TargetConstant:i16<9>, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t9
t35: i16,ch = mv_r16_nimm12_any16<Mem:LD1[%13]> t1,
TargetConstant:i16<8>, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t9
t31: i16,ch = mv_r16_nimm12_any16<Mem:LD1[%11]> t1,
TargetConstant:i16<7>, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t9
t27: i16,ch = mv_r16_nimm12_any16<Mem:LD1[%9]> t1,
TargetConstant:i16<6>, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t9
t23: i16,ch = mv_r16_nimm12_any16<Mem:LD1[%7]> t1,
TargetConstant:i16<5>, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t9
t19: i16,ch = mv_r16_nimm12_any16<Mem:LD1[%5]> t1,
TargetConstant:i16<4>, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t9
t14: i16,ch =
mv_r16_nimm12_any16<Mem:LD1[%_tmp200.unpack6.unpack.elt]> t1,
TargetConstant:i16<2>, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t9
t44: ch = TokenFactor t97:1, t14:1, t19:1, t23:1, t27:1, t31:1,
t35:1, t41:1
t46: i16,ch,glue = ADJCALLSTACKDOWN TargetConstant:i16<11>,
TargetConstant:i16<0>, Register:i16 %noreg, TargetConstant:i16<0>, t44
t49: ch,glue = push_any32 t41, TargetConstant:i16<0>, Register:i16
%noreg, TargetConstant:i16<0>, t46:1, t46:2
t50: ch,glue = push_any16 t35, TargetConstant:i16<0>, Register:i16
%noreg, TargetConstant:i16<0>, t49, t49:1
t51: ch,glue = push_any16 t31, TargetConstant:i16<0>, Register:i16
%noreg, TargetConstant:i16<0>, t50, t50:1
t52: ch,glue = push_any16 t27, TargetConstant:i16<0>, Register:i16
%noreg, TargetConstant:i16<0>, t51, t51:1
t53: ch,glue = push_any16 t23, TargetConstant:i16<0>, Register:i16
%noreg, TargetConstant:i16<0>, t52, t52:1
t54: ch,glue = push_any16 t19, TargetConstant:i16<0>, Register:i16
%noreg, TargetConstant:i16<0>, t53, t53:1
t55: ch,glue = push_any16 t6, TargetConstant:i16<0>, Register:i16
%noreg, TargetConstant:i16<0>, t54, t54:1
t56: ch,glue = push_any16 t14, TargetConstant:i16<0>, Register:i16
%noreg, TargetConstant:i16<0>, t55, t55:1
t57: ch,glue = push_any32 t97, TargetConstant:i16<0>, Register:i16
%noreg, TargetConstant:i16<0>, t56, t56:1
t59: i40,ch,glue = callr TargetGlobalAddress:i16<void (%rec830)
addrspace(40)* @g_cm_set> 0, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t57, t57:1
t60: i16,ch,glue = ADJCALLSTACKUP TargetConstant:i16<11>,
TargetConstant:i16<0>, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t59:1, t59:2
t94: i32 = mv32Sym TargetGlobalAddress:i32<%rec830
addrspace(21)* @g_cm_s> 0
t76: i32,i16 = add_nimm5_a32 t94, TargetConstant:i32<3>,
TargetConstant:i16<0>, Register:i16 %noreg, TargetConstant:i16<0>
t67: i16,i16,ch = aload_a16<Mem:LD1[getelementptr inbounds
(%rec830, %rec830 addrspace(21)* @g_cm_s, i32 0, i32 1, i32 0, i32
1)(addrspace=21)]> t76, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t60:1
t91: i16,ch,glue = cmp_nimm16_a16 t67, TargetConstant:i16<202>,
TargetConstant:i16<0>, Register:i16 %noreg, TargetConstant:i16<0>, t60:1
t97: i32,ch = mv_dp16_nimm13_any32<Mem:LD2[%1](align=1)>
TargetFrameIndex:i16<0>, TargetConstant:i16<0>, Register:i16 %noreg,
TargetConstant:i16<0>, t9
t92: ch = brr_cond BasicBlock:ch<bb14 0x3803dc8>,
TargetConstant:i16<2>, Register:i16 %CCReg, TargetConstant:i16<0>,
t91:1, t91:2
t73: ch = brr_uncond BasicBlock:ch<bb13 0x3803d18>, t92
and then somewhat later this is turned into:
*** MachineFunction at end of ISel ***
# Machine code for function two (#32): Properties: <SSA, tracking
liveness, HasVRegs>
[...]
BB#12: derived from LLVM BB %bb12
Predecessors according to CFG: BB#10
%vreg40<def> = mv_any16 202, pred:0, pred:%noreg, pred:0,
%ac0<imp-use>, %ac1<imp-use>; aNlh_rN:%vreg40
dbg:/repo/uabelho/dev-master/tmp/cmtest.c:189:3
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
and then comes literally zillions of
DBG_VALUE %vreg40, %noreg, !"s", <!32>; aNlh_rN:%vreg40 line no:168
Regards,
Mikael
On 06/22/2016 09:03 PM, Nirav Dave via llvm-commits wrote:
> Author: niravd
> Date: Wed Jun 22 14:03:26 2016
> New Revision: 273456
>
> URL: http://llvm.org/viewvc/llvm-project?rev=273456&view=rev
> Log:
> Preserve DebugInfo when replacing values in DAGCombiner
>
> Recommiting after fixing over-aggressive assertion
>
> [DAG] Previously debug values would transfer debuginfo for the selected
> start node for a replacement which allows for debug to be dropped.
>
> Push debug value transfer to occur with node/value replacement in
> SelectionDAG, remove now extraneous transfers of debug values.
>
> This refixes PR9817 which was being incompletely checked in the
> testsuite.
>
> Reviewers: jyknight
>
> Subscribers: dblaikie, llvm-commits
>
> Differential Revision: http://reviews.llvm.org/D21037
>
> Modified:
> llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
> llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> llvm/trunk/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
> llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp
> llvm/trunk/test/DebugInfo/X86/dbg-value-dag-combine.ll
>
> Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=273456&r1=273455&r2=273456&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Wed Jun 22 14:03:26 2016
> @@ -1221,9 +1221,11 @@ public:
> return DbgInfo->getSDDbgValues(SD);
> }
>
> - /// Transfer SDDbgValues.
> +private:
> + /// Transfer SDDbgValues. Called via ReplaceAllUses{OfValue}?With
> void TransferDbgValues(SDValue From, SDValue To);
>
> +public:
> /// Return true if there are any SDDbgValue nodes associated
> /// with this SelectionDAG.
> bool hasDebugValues() const { return !DbgInfo->empty(); }
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=273456&r1=273455&r2=273456&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Jun 22 14:03:26 2016
> @@ -1333,8 +1333,6 @@ void DAGCombiner::Run(CombineLevel AtLev
> DEBUG(dbgs() << " ... into: ";
> RV.getNode()->dump(&DAG));
>
> - // Transfer debug value.
> - DAG.TransferDbgValues(SDValue(N, 0), RV);
> if (N->getNumValues() == RV.getNode()->getNumValues())
> DAG.ReplaceAllUsesWith(N, RV.getNode());
> else {
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp?rev=273456&r1=273455&r2=273456&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Wed Jun 22 14:03:26 2016
> @@ -320,7 +320,6 @@ InstrEmitter::AddRegisterOperand(Machine
> "Chain and glue operands should occur at end of operand list!");
> // Get/emit the operand.
> unsigned VReg = getVR(Op, VRBaseMap);
> - assert(TargetRegisterInfo::isVirtualRegister(VReg) && "Not a vreg?");
>
> const MCInstrDesc &MCID = MIB->getDesc();
> bool isOptDef = IIOpNum < MCID.getNumOperands() &&
> @@ -334,6 +333,8 @@ InstrEmitter::AddRegisterOperand(Machine
> const TargetRegisterClass *DstRC = nullptr;
> if (IIOpNum < II->getNumOperands())
> DstRC = TRI->getAllocatableClass(TII->getRegClass(*II,IIOpNum,TRI,*MF));
> + assert((!DstRC || TargetRegisterInfo::isVirtualRegister(VReg)) &&
> + "Expected VReg");
> if (DstRC && !MRI->constrainRegClass(VReg, DstRC, MinRCSize)) {
> unsigned NewVReg = MRI->createVirtualRegister(DstRC);
> BuildMI(*MBB, InsertPos, Op.getNode()->getDebugLoc(),
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=273456&r1=273455&r2=273456&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Wed Jun 22 14:03:26 2016
> @@ -179,8 +179,6 @@ public:
> "Replacing one node with another that produces a different number "
> "of values!");
> DAG.ReplaceAllUsesWith(Old, New);
> - for (unsigned i = 0, e = Old->getNumValues(); i != e; ++i)
> - DAG.TransferDbgValues(SDValue(Old, i), SDValue(New, i));
> if (UpdatedNodes)
> UpdatedNodes->insert(New);
> ReplacedNode(Old);
> @@ -190,7 +188,6 @@ public:
> dbgs() << " with: "; New->dump(&DAG));
>
> DAG.ReplaceAllUsesWith(Old, New);
> - DAG.TransferDbgValues(Old, New);
> if (UpdatedNodes)
> UpdatedNodes->insert(New.getNode());
> ReplacedNode(Old.getNode());
> @@ -203,7 +200,6 @@ public:
> DEBUG(dbgs() << (i == 0 ? " with: "
> : " and: ");
> New[i]->dump(&DAG));
> - DAG.TransferDbgValues(SDValue(Old, i), New[i]);
> if (UpdatedNodes)
> UpdatedNodes->insert(New[i].getNode());
> }
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=273456&r1=273455&r2=273456&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Jun 22 14:03:26 2016
> @@ -6333,6 +6333,9 @@ void SelectionDAG::ReplaceAllUsesWith(SD
> AddModifiedNodeToCSEMaps(User);
> }
>
> + // Preserve Debug Values
> + TransferDbgValues(FromN, To);
> +
> // If we just RAUW'd the root, take note.
> if (FromN == getRoot())
> setRoot(To);
> @@ -6356,6 +6359,11 @@ void SelectionDAG::ReplaceAllUsesWith(SD
> if (From == To)
> return;
>
> + // Preserve Debug Info. Only do this if there's a use.
> + for (unsigned i = 0, e = From->getNumValues(); i != e; ++i)
> + if (From->hasAnyUseOfValue(i))
> + TransferDbgValues(SDValue(From, i), SDValue(To, i));
> +
> // Iterate over just the existing users of From. See the comments in
> // the ReplaceAllUsesWith above.
> SDNode::use_iterator UI = From->use_begin(), UE = From->use_end();
> @@ -6395,6 +6403,10 @@ void SelectionDAG::ReplaceAllUsesWith(SD
> if (From->getNumValues() == 1) // Handle the simple case efficiently.
> return ReplaceAllUsesWith(SDValue(From, 0), To[0]);
>
> + // Preserve Debug Info.
> + for (unsigned i = 0, e = From->getNumValues(); i != e; ++i)
> + TransferDbgValues(SDValue(From, i), *To);
> +
> // Iterate over just the existing users of From. See the comments in
> // the ReplaceAllUsesWith above.
> SDNode::use_iterator UI = From->use_begin(), UE = From->use_end();
> @@ -6439,6 +6451,9 @@ void SelectionDAG::ReplaceAllUsesOfValue
> return;
> }
>
> + // Preserve Debug Info.
> + TransferDbgValues(From, To);
> +
> // Iterate over just the existing users of From. See the comments in
> // the ReplaceAllUsesWith above.
> SDNode::use_iterator UI = From.getNode()->use_begin(),
> @@ -6513,6 +6528,8 @@ void SelectionDAG::ReplaceAllUsesOfValue
> if (Num == 1)
> return ReplaceAllUsesOfValueWith(*From, *To);
>
> + TransferDbgValues(*From, *To);
> +
> // Read up all the uses and make records of them. This helps
> // processing new uses that are introduced during the
> // replacement process.
> @@ -6661,7 +6678,7 @@ void SelectionDAG::AddDbgValue(SDDbgValu
> DbgInfo->add(DB, SD, isParameter);
> }
>
> -/// TransferDbgValues - Transfer SDDbgValues.
> +/// TransferDbgValues - Transfer SDDbgValues. Called in replace nodes.
> void SelectionDAG::TransferDbgValues(SDValue From, SDValue To) {
> if (From == To || !From.getNode()->getHasDebugValue())
> return;
>
> Modified: llvm/trunk/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp?rev=273456&r1=273455&r2=273456&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp (original)
> +++ llvm/trunk/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp Wed Jun 22 14:03:26 2016
> @@ -1308,8 +1308,6 @@ void HexagonDAGToDAGISel::SelectFrameInd
> R = CurDAG->getMachineNode(Hexagon::TFR_FIA, DL, MVT::i32, Ops);
> }
>
> - if (N->getHasDebugValue())
> - CurDAG->TransferDbgValues(SDValue(N, 0), SDValue(R, 0));
> ReplaceNode(N, R);
> }
>
>
> Modified: llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp?rev=273456&r1=273455&r2=273456&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp Wed Jun 22 14:03:26 2016
> @@ -1057,8 +1057,8 @@ HexagonTargetLowering::LowerDYNAMIC_STAC
> SDValue AC = DAG.getConstant(A, dl, MVT::i32);
> SDVTList VTs = DAG.getVTList(MVT::i32, MVT::Other);
> SDValue AA = DAG.getNode(HexagonISD::ALLOCA, dl, VTs, Chain, Size, AC);
> - if (Op.getNode()->getHasDebugValue())
> - DAG.TransferDbgValues(Op, AA);
> +
> + DAG.ReplaceAllUsesOfValueWith(Op, AA);
> return AA;
> }
>
>
> Modified: llvm/trunk/test/DebugInfo/X86/dbg-value-dag-combine.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-value-dag-combine.ll?rev=273456&r1=273455&r2=273456&view=diff
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/X86/dbg-value-dag-combine.ll (original)
> +++ llvm/trunk/test/DebugInfo/X86/dbg-value-dag-combine.ll Wed Jun 22 14:03:26 2016
> @@ -3,6 +3,13 @@ target datalayout = "e-p:32:32:32-i1:8:8
> target triple = "i686-apple-darwin"
> ; PR 9817
>
> +; There should be a DEBUG_VALUE for each call to llvm.dbg.value
> +
> +; CHECK: ##DEBUG_VALUE: __OpenCL_test_kernel:ip <-
> +; CHECK: ##DEBUG_VALUE: xxx <- 0
> +; CHECK: ##DEBUG_VALUE: gid <- %E{{..$}}
> +; CHECK: ##DEBUG_VALUE: idx <- %E{{..$}}
> +; CHECK-NOT: ##DEBUG_VALUE:
>
> declare <4 x i32> @__amdil_get_global_id_int()
> declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
> @@ -12,10 +19,9 @@ entry:
> %0 = call <4 x i32> @__amdil_get_global_id_int() nounwind
> %1 = extractelement <4 x i32> %0, i32 0
> call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !9, metadata !DIExpression()), !dbg !11
> - call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !13, metadata !DIExpression()), !dbg !14
> + call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !21, metadata !DIExpression()), !dbg !14
> %tmp2 = load i32, i32 addrspace(1)* %ip, align 4, !dbg !15
> %tmp3 = add i32 0, %tmp2, !dbg !15
> -; CHECK: ##DEBUG_VALUE: idx <- %E{{..$}}
> call void @llvm.dbg.value(metadata i32 %tmp3, i64 0, metadata !13, metadata !DIExpression()), !dbg !15
> %arrayidx = getelementptr i32, i32 addrspace(1)* %ip, i32 %1, !dbg !16
> store i32 %tmp3, i32 addrspace(1)* %arrayidx, align 4, !dbg !16
> @@ -44,3 +50,4 @@ entry:
> !17 = !DILocation(line: 7, column: 1, scope: !0)
> !19 = !DIFile(filename: "OCL6368.tmp.cl", directory: "E:\5CUsers\5Cmvillmow.AMD\5CAppData\5CLocal\5CTemp")
> !20 = !{i32 1, !"Debug Info Version", i32 3}
> +!21 = !DILocalVariable(name: "xxx", line: 4, scope: !10, file: !1, type: !6)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list