2727#include " llvm/Analysis/MemoryLocation.h"
2828#include " llvm/Analysis/ValueTracking.h"
2929#include " llvm/Analysis/VectorUtils.h"
30- #include " llvm/BinaryFormat/Dwarf.h"
3130#include " llvm/CodeGen/Analysis.h"
3231#include " llvm/CodeGen/FunctionLoweringInfo.h"
3332#include " llvm/CodeGen/ISDOpcodes.h"
@@ -10844,11 +10843,8 @@ void SelectionDAG::salvageDebugInfo(SDNode &N) {
1084410843 case ISD::ADD: {
1084510844 SDValue N0 = N.getOperand (0 );
1084610845 SDValue N1 = N.getOperand (1 );
10847- if (!isa<ConstantSDNode>(N0)) {
10848- bool RHSConstant = isa<ConstantSDNode>(N1);
10849- uint64_t Offset;
10850- if (RHSConstant)
10851- Offset = N.getConstantOperandVal (1 );
10846+ if (!isa<ConstantSDNode>(N0) && isa<ConstantSDNode>(N1)) {
10847+ uint64_t Offset = N.getConstantOperandVal (1 );
1085210848
1085310849 // Rewrite an ADD constant node into a DIExpression. Since we are
1085410850 // performing arithmetic to compute the variable's *value* in the
@@ -10857,46 +10853,27 @@ void SelectionDAG::salvageDebugInfo(SDNode &N) {
1085710853 auto *DIExpr = DV->getExpression ();
1085810854 auto NewLocOps = DV->copyLocationOps ();
1085910855 bool Changed = false ;
10860- size_t OrigLocOpsSize = NewLocOps.size ();
10861- for (size_t i = 0 ; i < OrigLocOpsSize; ++i) {
10856+ for (size_t i = 0 ; i < NewLocOps.size (); ++i) {
1086210857 // We're not given a ResNo to compare against because the whole
1086310858 // node is going away. We know that any ISD::ADD only has one
1086410859 // result, so we can assume any node match is using the result.
1086510860 if (NewLocOps[i].getKind () != SDDbgOperand::SDNODE ||
1086610861 NewLocOps[i].getSDNode () != &N)
1086710862 continue ;
1086810863 NewLocOps[i] = SDDbgOperand::fromNode (N0.getNode (), N0.getResNo ());
10869- if (RHSConstant) {
10870- SmallVector<uint64_t , 3 > ExprOps;
10871- DIExpression::appendOffset (ExprOps, Offset);
10872- DIExpr = DIExpression::appendOpsToArg (DIExpr, ExprOps, i, true );
10873- } else {
10874- // Convert to a variadic expression (if not already).
10875- // convertToVariadicExpression() returns a const pointer, so we use
10876- // a temporary const variable here.
10877- const auto *TmpDIExpr =
10878- DIExpression::convertToVariadicExpression (DIExpr);
10879- SmallVector<uint64_t , 3 > ExprOps;
10880- ExprOps.push_back (dwarf::DW_OP_LLVM_arg);
10881- ExprOps.push_back (NewLocOps.size ());
10882- ExprOps.push_back (dwarf::DW_OP_plus);
10883- SDDbgOperand RHS =
10884- SDDbgOperand::fromNode (N1.getNode (), N1.getResNo ());
10885- NewLocOps.push_back (RHS);
10886- DIExpr = DIExpression::appendOpsToArg (TmpDIExpr, ExprOps, i, true );
10887- }
10864+ SmallVector<uint64_t , 3 > ExprOps;
10865+ DIExpression::appendOffset (ExprOps, Offset);
10866+ DIExpr = DIExpression::appendOpsToArg (DIExpr, ExprOps, i, true );
1088810867 Changed = true ;
1088910868 }
1089010869 (void )Changed;
1089110870 assert (Changed && " Salvage target doesn't use N" );
1089210871
10893- bool IsVariadic =
10894- DV->isVariadic () || OrigLocOpsSize != NewLocOps.size ();
10895-
1089610872 auto AdditionalDependencies = DV->getAdditionalDependencies ();
10897- SDDbgValue *Clone = getDbgValueList (
10898- DV->getVariable (), DIExpr, NewLocOps, AdditionalDependencies,
10899- DV->isIndirect (), DV->getDebugLoc (), DV->getOrder (), IsVariadic);
10873+ SDDbgValue *Clone = getDbgValueList (DV->getVariable (), DIExpr,
10874+ NewLocOps, AdditionalDependencies,
10875+ DV->isIndirect (), DV->getDebugLoc (),
10876+ DV->getOrder (), DV->isVariadic ());
1090010877 ClonedDVs.push_back (Clone);
1090110878 DV->setIsInvalidated ();
1090210879 DV->setIsEmitted ();
0 commit comments