59
59
#include " llvm/ADT/Hashing.h"
60
60
#include " llvm/ADT/PointerIntPair.h"
61
61
#include " llvm/ADT/STLExtras.h"
62
- #include " llvm/ADT/SetOperations.h"
63
62
#include " llvm/ADT/SetVector.h"
64
63
#include " llvm/ADT/SmallBitVector.h"
65
64
#include " llvm/ADT/SmallPtrSet.h"
81
80
#include " llvm/IR/BasicBlock.h"
82
81
#include " llvm/IR/Constant.h"
83
82
#include " llvm/IR/Constants.h"
84
- #include " llvm/IR/DebugInfoMetadata.h"
85
83
#include " llvm/IR/DerivedTypes.h"
86
84
#include " llvm/IR/Dominators.h"
87
85
#include " llvm/IR/GlobalValue.h"
@@ -5778,27 +5776,6 @@ static bool ReduceLoopStrength(Loop *L, IVUsers &IU, ScalarEvolution &SE,
5778
5776
if (MSSA)
5779
5777
MSSAU = std::make_unique<MemorySSAUpdater>(MSSA);
5780
5778
5781
- // Debug preservation - record all llvm.dbg.value from the loop as well as
5782
- // the SCEV of their variable location. Since salvageDebugInfo may change the
5783
- // DIExpression we need to store the original here as well (i.e. it needs to
5784
- // be in sync with the SCEV).
5785
- SmallVector<
5786
- std::tuple<DbgValueInst *, const Type *, const SCEV *, DIExpression *>,
5787
- 32 >
5788
- DbgValues;
5789
- for (auto &B : L->getBlocks ()) {
5790
- for (auto &I : *B) {
5791
- if (DbgValueInst *D = dyn_cast<DbgValueInst>(&I)) {
5792
- auto V = D->getVariableLocation ();
5793
- if (!SE.isSCEVable (V->getType ()))
5794
- continue ;
5795
- auto DS = SE.getSCEV (V);
5796
- DbgValues.push_back (
5797
- std::make_tuple (D, V->getType (), DS, D->getExpression ()));
5798
- }
5799
- }
5800
- }
5801
-
5802
5779
// Run the main LSR transformation.
5803
5780
Changed |=
5804
5781
LSRInstance (L, IU, SE, DT, LI, TTI, AC, TLI, MSSAU.get ()).getChanged ();
@@ -5820,40 +5797,6 @@ static bool ReduceLoopStrength(Loop *L, IVUsers &IU, ScalarEvolution &SE,
5820
5797
DeleteDeadPHIs (L->getHeader (), &TLI, MSSAU.get ());
5821
5798
}
5822
5799
}
5823
- // Debug preservation - go through all recorded llvm.dbg.value and for those
5824
- // that now have an undef variable location use the recorded SCEV to try and
5825
- // update it. Compare with SCEV of Phi-nodes of loop header to find a
5826
- // suitable update candidate. SCEV match with constant offset is allowed and
5827
- // will be compensated for in the DIExpression.
5828
- if (Changed) {
5829
- for (auto &D : DbgValues) {
5830
- auto DbgValue = std::get<DbgValueInst *>(D);
5831
- auto DbgValueType = std::get<const Type *>(D);
5832
- auto DbgValueSCEV = std::get<const SCEV *>(D);
5833
- auto DbgDIExpr = std::get<DIExpression *>(D);
5834
- if (!isa<UndefValue>(DbgValue->getVariableLocation ()))
5835
- continue ;
5836
- for (PHINode &Phi : L->getHeader ()->phis ()) {
5837
- if (DbgValueType != Phi.getType ())
5838
- continue ;
5839
- if (!SE.isSCEVable (Phi.getType ()))
5840
- continue ;
5841
- auto PhiSCEV = SE.getSCEV (&Phi);
5842
- if (Optional<APInt> Offset =
5843
- SE.computeConstantDifference (DbgValueSCEV, PhiSCEV)) {
5844
- auto &Ctx = DbgValue->getContext ();
5845
- DbgValue->setOperand (
5846
- 0 , MetadataAsValue::get (Ctx, ValueAsMetadata::get (&Phi)));
5847
- if (Offset.getValue ().getSExtValue ()) {
5848
- SmallVector<uint64_t , 8 > Ops;
5849
- DIExpression::appendOffset (Ops, Offset.getValue ().getSExtValue ());
5850
- DbgDIExpr = DIExpression::prependOpcodes (DbgDIExpr, Ops, true );
5851
- }
5852
- DbgValue->setOperand (2 , MetadataAsValue::get (Ctx, DbgDIExpr));
5853
- }
5854
- }
5855
- }
5856
- }
5857
5800
return Changed;
5858
5801
}
5859
5802
0 commit comments