27
27
#include " llvm/Analysis/MemoryLocation.h"
28
28
#include " llvm/Analysis/ValueTracking.h"
29
29
#include " llvm/Analysis/VectorUtils.h"
30
- #include " llvm/BinaryFormat/Dwarf.h"
31
30
#include " llvm/CodeGen/Analysis.h"
32
31
#include " llvm/CodeGen/FunctionLoweringInfo.h"
33
32
#include " llvm/CodeGen/ISDOpcodes.h"
@@ -10844,11 +10843,8 @@ void SelectionDAG::salvageDebugInfo(SDNode &N) {
10844
10843
case ISD::ADD: {
10845
10844
SDValue N0 = N.getOperand (0 );
10846
10845
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 );
10852
10848
10853
10849
// Rewrite an ADD constant node into a DIExpression. Since we are
10854
10850
// performing arithmetic to compute the variable's *value* in the
@@ -10857,46 +10853,27 @@ void SelectionDAG::salvageDebugInfo(SDNode &N) {
10857
10853
auto *DIExpr = DV->getExpression ();
10858
10854
auto NewLocOps = DV->copyLocationOps ();
10859
10855
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) {
10862
10857
// We're not given a ResNo to compare against because the whole
10863
10858
// node is going away. We know that any ISD::ADD only has one
10864
10859
// result, so we can assume any node match is using the result.
10865
10860
if (NewLocOps[i].getKind () != SDDbgOperand::SDNODE ||
10866
10861
NewLocOps[i].getSDNode () != &N)
10867
10862
continue ;
10868
10863
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 );
10888
10867
Changed = true ;
10889
10868
}
10890
10869
(void )Changed;
10891
10870
assert (Changed && " Salvage target doesn't use N" );
10892
10871
10893
- bool IsVariadic =
10894
- DV->isVariadic () || OrigLocOpsSize != NewLocOps.size ();
10895
-
10896
10872
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 ());
10900
10877
ClonedDVs.push_back (Clone);
10901
10878
DV->setIsInvalidated ();
10902
10879
DV->setIsEmitted ();
0 commit comments