[llvm] 1540da3 - ABI breaking changes fixes.
Neil Henning via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 15 03:08:56 PDT 2021
Author: Neil Henning
Date: 2021-06-15T11:08:13+01:00
New Revision: 1540da3b788272e9aacc698ef96e75a4a5839ee1
URL: https://github.com/llvm/llvm-project/commit/1540da3b788272e9aacc698ef96e75a4a5839ee1
DIFF: https://github.com/llvm/llvm-project/commit/1540da3b788272e9aacc698ef96e75a4a5839ee1.diff
LOG: ABI breaking changes fixes.
This commit mostly just replaces bad uses of `NDEBUG` with uses of
`LLVM_ENABLE_ABI_BREAKING_CHANGES` - the safe way to include ABI
breaking changes (normally extra struct elements in headers).
Differential Revision: https://reviews.llvm.org/D104216
Added:
Modified:
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/include/llvm/Support/GenericDomTreeConstruction.h
llvm/include/llvm/Transforms/Scalar/JumpThreading.h
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h
index 5fadb6f717adf..9011c52f20c1f 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -145,7 +145,7 @@ class PreservedCFGCheckerInstrumentation {
FunctionAnalysisManager::Invalidator &);
};
-#ifndef NDEBUG
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
SmallVector<StringRef, 8> PassStack;
#endif
diff --git a/llvm/include/llvm/Support/GenericDomTreeConstruction.h b/llvm/include/llvm/Support/GenericDomTreeConstruction.h
index 4b59ad1f017f5..c476ccbfc7631 100644
--- a/llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ b/llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -643,7 +643,7 @@ struct SemiNCAInfo {
Bucket;
SmallDenseSet<TreeNodePtr, 8> Visited;
SmallVector<TreeNodePtr, 8> Affected;
-#ifndef NDEBUG
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
SmallVector<TreeNodePtr, 8> VisitedUnaffected;
#endif
};
@@ -852,7 +852,7 @@ struct SemiNCAInfo {
TN->setIDom(NCD);
}
-#ifndef NDEBUG
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
for (const TreeNodePtr TN : II.VisitedUnaffected)
assert(TN->getLevel() == TN->getIDom()->getLevel() + 1 &&
"TN should have been updated by an affected ancestor");
@@ -918,7 +918,7 @@ struct SemiNCAInfo {
LLVM_DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> "
<< BlockNamePrinter(To) << "\n");
-#ifndef NDEBUG
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
// Ensure that the edge was in fact deleted from the CFG before informing
// the DomTree about it.
// The check is O(N), so run it only in debug configuration.
diff --git a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
index 951f4e487753d..816ea1071e52b 100644
--- a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
+++ b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
@@ -85,7 +85,7 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
std::unique_ptr<BranchProbabilityInfo> BPI;
bool HasProfileData = false;
bool HasGuards = false;
-#ifdef NDEBUG
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
SmallPtrSet<const BasicBlock *, 16> LoopHeaders;
#else
SmallSet<AssertingVH<const BasicBlock>, 16> LoopHeaders;
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index 480f5e5dfebd8..69ee7c78f1893 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -269,7 +269,7 @@ class LPMUpdater {
}
void setParentLoop(Loop *L) {
-#ifndef NDEBUG
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
ParentL = L;
#endif
}
@@ -308,7 +308,7 @@ class LPMUpdater {
/// loops within them will be visited in postorder as usual for the loop pass
/// manager.
void addSiblingLoops(ArrayRef<Loop *> NewSibLoops) {
-#ifndef NDEBUG
+#if defined(LLVM_ENABLE_ABI_BREAKING_CHECKS) && !defined(NDEBUG)
for (Loop *NewL : NewSibLoops)
assert(NewL->getParentLoop() == ParentL &&
"All of the new loops must be siblings of the current loop!");
@@ -349,7 +349,7 @@ class LPMUpdater {
bool SkipCurrentLoop;
const bool LoopNestMode;
-#ifndef NDEBUG
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
// In debug builds we also track the parent loop to implement asserts even in
// the face of loop deletion.
Loop *ParentL;
diff --git a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
index 5d9340803ebb7..8662dbf385dc9 100644
--- a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
+++ b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
@@ -160,7 +160,7 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
/// consistent when instructions are moved.
SmallVector<SCEVInsertPointGuard *, 8> InsertPointGuards;
-#ifndef NDEBUG
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
const char *DebugType;
#endif
@@ -176,7 +176,7 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
Builder(se.getContext(), TargetFolder(DL),
IRBuilderCallbackInserter(
[this](Instruction *I) { rememberInstruction(I); })) {
-#ifndef NDEBUG
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
DebugType = "";
#endif
}
@@ -186,7 +186,7 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
assert(InsertPointGuards.empty());
}
-#ifndef NDEBUG
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
void setDebugType(const char *s) { DebugType = s; }
#endif
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index b28f4bab39e3e..a03e0d4b597eb 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -1086,7 +1086,9 @@ void PreservedCFGCheckerInstrumentation::registerCallbacks(
PIC.registerBeforeNonSkippedPassCallback(
[this, &FAM](StringRef P, Any IR) {
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
assert(&PassStack.emplace_back(P));
+#endif
(void)this;
if (!any_isa<const Function *>(IR))
return;
@@ -1098,16 +1100,20 @@ void PreservedCFGCheckerInstrumentation::registerCallbacks(
PIC.registerAfterPassInvalidatedCallback(
[this](StringRef P, const PreservedAnalyses &PassPA) {
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
assert(PassStack.pop_back_val() == P &&
"Before and After callbacks must correspond");
+#endif
(void)this;
});
PIC.registerAfterPassCallback([this, &FAM,
checkCFG](StringRef P, Any IR,
const PreservedAnalyses &PassPA) {
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
assert(PassStack.pop_back_val() == P &&
"Before and After callbacks must correspond");
+#endif
(void)this;
if (!any_isa<const Function *>(IR))
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 2f851c4832f84..b62b26edc8056 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -29,6 +29,12 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
+#define SCEV_DEBUG_WITH_TYPE(TYPE, X) DEBUG_WITH_TYPE(TYPE, X)
+#else
+#define SCEV_DEBUG_WITH_TYPE(TYPE, X)
+#endif
+
using namespace llvm;
cl::opt<unsigned> llvm::SCEVCheapExpansionBudget(
@@ -1225,7 +1231,7 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized,
// We should not look for a incomplete PHI. Getting SCEV for a incomplete
// PHI has no meaning at all.
if (!PN.isComplete()) {
- DEBUG_WITH_TYPE(
+ SCEV_DEBUG_WITH_TYPE(
DebugType, dbgs() << "One incomplete PHI is found: " << PN << "\n");
continue;
}
@@ -2086,8 +2092,9 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
Phi->replaceAllUsesWith(V);
DeadInsts.emplace_back(Phi);
++NumElim;
- DEBUG_WITH_TYPE(DebugType, dbgs()
- << "INDVARS: Eliminated constant iv: " << *Phi << '\n');
+ SCEV_DEBUG_WITH_TYPE(DebugType,
+ dbgs() << "INDVARS: Eliminated constant iv: " << *Phi
+ << '\n');
continue;
}
@@ -2144,9 +2151,9 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
TruncExpr == SE.getSCEV(IsomorphicInc) &&
SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc) &&
hoistIVInc(OrigInc, IsomorphicInc)) {
- DEBUG_WITH_TYPE(DebugType,
- dbgs() << "INDVARS: Eliminated congruent iv.inc: "
- << *IsomorphicInc << '\n');
+ SCEV_DEBUG_WITH_TYPE(
+ DebugType, dbgs() << "INDVARS: Eliminated congruent iv.inc: "
+ << *IsomorphicInc << '\n');
Value *NewInc = OrigInc;
if (OrigInc->getType() != IsomorphicInc->getType()) {
Instruction *IP = nullptr;
@@ -2165,10 +2172,11 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
}
}
}
- DEBUG_WITH_TYPE(DebugType, dbgs() << "INDVARS: Eliminated congruent iv: "
- << *Phi << '\n');
- DEBUG_WITH_TYPE(DebugType, dbgs() << "INDVARS: Original iv: "
- << *OrigPhiRef << '\n');
+ SCEV_DEBUG_WITH_TYPE(DebugType,
+ dbgs() << "INDVARS: Eliminated congruent iv: " << *Phi
+ << '\n');
+ SCEV_DEBUG_WITH_TYPE(
+ DebugType, dbgs() << "INDVARS: Original iv: " << *OrigPhiRef << '\n');
++NumElim;
Value *NewIV = OrigPhiRef;
if (OrigPhiRef->getType() != Phi->getType()) {
More information about the llvm-commits
mailing list