Skip to content

Commit 9d63029

Browse files
committed
Revert "[DebugInfo] Improve dbg preservation in LSR."
This reverts commit a3caf7f. The ReleaseLTO-g test-suite configuration has been failing to build since this commit, because clang segfaults while building 7zip.
1 parent 6bcaf6f commit 9d63029

File tree

4 files changed

+10
-141
lines changed

4 files changed

+10
-141
lines changed

llvm/include/llvm/Analysis/ScalarEvolution.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,15 +1117,6 @@ class ScalarEvolution {
11171117
const SCEV *S, const Loop *L,
11181118
SmallPtrSetImpl<const SCEVPredicate *> &Preds);
11191119

1120-
/// Compute \p LHS - \p RHS and returns the result as an APInt if it is a
1121-
/// constant, and None if it isn't.
1122-
///
1123-
/// This is intended to be a cheaper version of getMinusSCEV. We can be
1124-
/// frugal here since we just bail out of actually constructing and
1125-
/// canonicalizing an expression in the cases where the result isn't going
1126-
/// to be a constant.
1127-
Optional<APInt> computeConstantDifference(const SCEV *LHS, const SCEV *RHS);
1128-
11291120
private:
11301121
/// A CallbackVH to arrange for ScalarEvolution to be notified whenever a
11311122
/// Value is deleted.
@@ -1808,6 +1799,15 @@ class ScalarEvolution {
18081799
bool splitBinaryAdd(const SCEV *Expr, const SCEV *&L, const SCEV *&R,
18091800
SCEV::NoWrapFlags &Flags);
18101801

1802+
/// Compute \p LHS - \p RHS and returns the result as an APInt if it is a
1803+
/// constant, and None if it isn't.
1804+
///
1805+
/// This is intended to be a cheaper version of getMinusSCEV. We can be
1806+
/// frugal here since we just bail out of actually constructing and
1807+
/// canonicalizing an expression in the cases where the result isn't going
1808+
/// to be a constant.
1809+
Optional<APInt> computeConstantDifference(const SCEV *LHS, const SCEV *RHS);
1810+
18111811
/// Drop memoized information computed for S.
18121812
void forgetMemoizedResults(const SCEV *S);
18131813

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
#include "llvm/ADT/Hashing.h"
6060
#include "llvm/ADT/PointerIntPair.h"
6161
#include "llvm/ADT/STLExtras.h"
62-
#include "llvm/ADT/SetOperations.h"
6362
#include "llvm/ADT/SetVector.h"
6463
#include "llvm/ADT/SmallBitVector.h"
6564
#include "llvm/ADT/SmallPtrSet.h"
@@ -81,7 +80,6 @@
8180
#include "llvm/IR/BasicBlock.h"
8281
#include "llvm/IR/Constant.h"
8382
#include "llvm/IR/Constants.h"
84-
#include "llvm/IR/DebugInfoMetadata.h"
8583
#include "llvm/IR/DerivedTypes.h"
8684
#include "llvm/IR/Dominators.h"
8785
#include "llvm/IR/GlobalValue.h"
@@ -5778,27 +5776,6 @@ static bool ReduceLoopStrength(Loop *L, IVUsers &IU, ScalarEvolution &SE,
57785776
if (MSSA)
57795777
MSSAU = std::make_unique<MemorySSAUpdater>(MSSA);
57805778

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-
58025779
// Run the main LSR transformation.
58035780
Changed |=
58045781
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,
58205797
DeleteDeadPHIs(L->getHeader(), &TLI, MSSAU.get());
58215798
}
58225799
}
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-
}
58575800
return Changed;
58585801
}
58595802

llvm/test/DebugInfo/COFF/fpo-shrink-wrap.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
; ASM: popl %ebx
3434
; ASM: [[EPILOGUE]]: # %return
3535
; ASM: retl $8
36-
; ASM: Ltmp11:
36+
; ASM: Ltmp10:
3737
; ASM: .cv_fpo_endproc
3838

3939
; Note how RvaStart advances 7 bytes to skip the shrink-wrapped portion.

llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-0.ll

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)