[PATCH] D41924: dagcombine: Transfer debug information when folding (zext (truncate x)) -> (zext (truncate x))

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 09:28:33 PST 2018


aprantl added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:7803
+        // Transfer the debug info; the new node is equivalent to N0.
+        DAG.transferDbgValues(N0, ZExtOrTrunc);
+        return ZExtOrTrunc;
----------------
RKSimon wrote:
> aprantl wrote:
> > RKSimon wrote:
> > > I'm surprised we need to do this - can we achieve the same by using SDLoc(N0) instead of SDLoc(N) in both the above?
> > Just to make sure we are talking about the same thing, I changed the code to be
> > 
> > ```
> >     if (SrcVT.bitsLT(VT)) {
> >       if (!LegalOperations || (TLI.isOperationLegal(ISD::AND, SrcVT) &&
> >                                TLI.isOperationLegal(ISD::ZERO_EXTEND, VT))) {
> >         SDValue Op = N0.getOperand(0);
> >         Op = DAG.getZeroExtendInReg(Op, SDLoc(N0), MinVT.getScalarType());
> >         AddToWorklist(Op.getNode());
> >         SDValue ZExtOrTrunc = DAG.getZExtOrTrunc(Op, SDLoc(N0), VT);
> >         // Transfer the debug info; the new node is equivalent to N0.
> >         //DAG.transferDbgValues(N0, ZExtOrTrunc);
> >         return ZExtOrTrunc;
> >       }
> >     }
> > ```
> > 
> > That does *not* preserve the DBG_VALUE.
> OK - but its very rare to have to call transferDbgValues directly like this - I just have the feeling that there is a better way......
I would be thrilled if there were a more natural way to do this.
My understanding at this point is that we have >100 dag-combiner patterns that all need to be manually audited for whether they should preserve debug info (like this patch does).


Repository:
  rL LLVM

https://reviews.llvm.org/D41924





More information about the llvm-commits mailing list