forked from OSchip/llvm-project
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
This commit is contained in:
parent
fffb975095
commit
1540da3b78
|
@ -145,7 +145,7 @@ public:
|
||||||
FunctionAnalysisManager::Invalidator &);
|
FunctionAnalysisManager::Invalidator &);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
SmallVector<StringRef, 8> PassStack;
|
SmallVector<StringRef, 8> PassStack;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -643,7 +643,7 @@ struct SemiNCAInfo {
|
||||||
Bucket;
|
Bucket;
|
||||||
SmallDenseSet<TreeNodePtr, 8> Visited;
|
SmallDenseSet<TreeNodePtr, 8> Visited;
|
||||||
SmallVector<TreeNodePtr, 8> Affected;
|
SmallVector<TreeNodePtr, 8> Affected;
|
||||||
#ifndef NDEBUG
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
SmallVector<TreeNodePtr, 8> VisitedUnaffected;
|
SmallVector<TreeNodePtr, 8> VisitedUnaffected;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -852,7 +852,7 @@ struct SemiNCAInfo {
|
||||||
TN->setIDom(NCD);
|
TN->setIDom(NCD);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
for (const TreeNodePtr TN : II.VisitedUnaffected)
|
for (const TreeNodePtr TN : II.VisitedUnaffected)
|
||||||
assert(TN->getLevel() == TN->getIDom()->getLevel() + 1 &&
|
assert(TN->getLevel() == TN->getIDom()->getLevel() + 1 &&
|
||||||
"TN should have been updated by an affected ancestor");
|
"TN should have been updated by an affected ancestor");
|
||||||
|
@ -918,7 +918,7 @@ struct SemiNCAInfo {
|
||||||
LLVM_DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> "
|
LLVM_DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> "
|
||||||
<< BlockNamePrinter(To) << "\n");
|
<< BlockNamePrinter(To) << "\n");
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
// Ensure that the edge was in fact deleted from the CFG before informing
|
// Ensure that the edge was in fact deleted from the CFG before informing
|
||||||
// the DomTree about it.
|
// the DomTree about it.
|
||||||
// The check is O(N), so run it only in debug configuration.
|
// The check is O(N), so run it only in debug configuration.
|
||||||
|
|
|
@ -85,7 +85,7 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
|
||||||
std::unique_ptr<BranchProbabilityInfo> BPI;
|
std::unique_ptr<BranchProbabilityInfo> BPI;
|
||||||
bool HasProfileData = false;
|
bool HasProfileData = false;
|
||||||
bool HasGuards = false;
|
bool HasGuards = false;
|
||||||
#ifdef NDEBUG
|
#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
SmallPtrSet<const BasicBlock *, 16> LoopHeaders;
|
SmallPtrSet<const BasicBlock *, 16> LoopHeaders;
|
||||||
#else
|
#else
|
||||||
SmallSet<AssertingVH<const BasicBlock>, 16> LoopHeaders;
|
SmallSet<AssertingVH<const BasicBlock>, 16> LoopHeaders;
|
||||||
|
|
|
@ -269,7 +269,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void setParentLoop(Loop *L) {
|
void setParentLoop(Loop *L) {
|
||||||
#ifndef NDEBUG
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
ParentL = L;
|
ParentL = L;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ public:
|
||||||
/// loops within them will be visited in postorder as usual for the loop pass
|
/// loops within them will be visited in postorder as usual for the loop pass
|
||||||
/// manager.
|
/// manager.
|
||||||
void addSiblingLoops(ArrayRef<Loop *> NewSibLoops) {
|
void addSiblingLoops(ArrayRef<Loop *> NewSibLoops) {
|
||||||
#ifndef NDEBUG
|
#if defined(LLVM_ENABLE_ABI_BREAKING_CHECKS) && !defined(NDEBUG)
|
||||||
for (Loop *NewL : NewSibLoops)
|
for (Loop *NewL : NewSibLoops)
|
||||||
assert(NewL->getParentLoop() == ParentL &&
|
assert(NewL->getParentLoop() == ParentL &&
|
||||||
"All of the new loops must be siblings of the current loop!");
|
"All of the new loops must be siblings of the current loop!");
|
||||||
|
@ -349,7 +349,7 @@ private:
|
||||||
bool SkipCurrentLoop;
|
bool SkipCurrentLoop;
|
||||||
const bool LoopNestMode;
|
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
|
// In debug builds we also track the parent loop to implement asserts even in
|
||||||
// the face of loop deletion.
|
// the face of loop deletion.
|
||||||
Loop *ParentL;
|
Loop *ParentL;
|
||||||
|
|
|
@ -160,7 +160,7 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
|
||||||
/// consistent when instructions are moved.
|
/// consistent when instructions are moved.
|
||||||
SmallVector<SCEVInsertPointGuard *, 8> InsertPointGuards;
|
SmallVector<SCEVInsertPointGuard *, 8> InsertPointGuards;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
const char *DebugType;
|
const char *DebugType;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public:
|
||||||
Builder(se.getContext(), TargetFolder(DL),
|
Builder(se.getContext(), TargetFolder(DL),
|
||||||
IRBuilderCallbackInserter(
|
IRBuilderCallbackInserter(
|
||||||
[this](Instruction *I) { rememberInstruction(I); })) {
|
[this](Instruction *I) { rememberInstruction(I); })) {
|
||||||
#ifndef NDEBUG
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
DebugType = "";
|
DebugType = "";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ public:
|
||||||
assert(InsertPointGuards.empty());
|
assert(InsertPointGuards.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
void setDebugType(const char *s) { DebugType = s; }
|
void setDebugType(const char *s) { DebugType = s; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1086,7 +1086,9 @@ void PreservedCFGCheckerInstrumentation::registerCallbacks(
|
||||||
|
|
||||||
PIC.registerBeforeNonSkippedPassCallback(
|
PIC.registerBeforeNonSkippedPassCallback(
|
||||||
[this, &FAM](StringRef P, Any IR) {
|
[this, &FAM](StringRef P, Any IR) {
|
||||||
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
assert(&PassStack.emplace_back(P));
|
assert(&PassStack.emplace_back(P));
|
||||||
|
#endif
|
||||||
(void)this;
|
(void)this;
|
||||||
if (!any_isa<const Function *>(IR))
|
if (!any_isa<const Function *>(IR))
|
||||||
return;
|
return;
|
||||||
|
@ -1098,16 +1100,20 @@ void PreservedCFGCheckerInstrumentation::registerCallbacks(
|
||||||
|
|
||||||
PIC.registerAfterPassInvalidatedCallback(
|
PIC.registerAfterPassInvalidatedCallback(
|
||||||
[this](StringRef P, const PreservedAnalyses &PassPA) {
|
[this](StringRef P, const PreservedAnalyses &PassPA) {
|
||||||
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
assert(PassStack.pop_back_val() == P &&
|
assert(PassStack.pop_back_val() == P &&
|
||||||
"Before and After callbacks must correspond");
|
"Before and After callbacks must correspond");
|
||||||
|
#endif
|
||||||
(void)this;
|
(void)this;
|
||||||
});
|
});
|
||||||
|
|
||||||
PIC.registerAfterPassCallback([this, &FAM,
|
PIC.registerAfterPassCallback([this, &FAM,
|
||||||
checkCFG](StringRef P, Any IR,
|
checkCFG](StringRef P, Any IR,
|
||||||
const PreservedAnalyses &PassPA) {
|
const PreservedAnalyses &PassPA) {
|
||||||
|
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||||
assert(PassStack.pop_back_val() == P &&
|
assert(PassStack.pop_back_val() == P &&
|
||||||
"Before and After callbacks must correspond");
|
"Before and After callbacks must correspond");
|
||||||
|
#endif
|
||||||
(void)this;
|
(void)this;
|
||||||
|
|
||||||
if (!any_isa<const Function *>(IR))
|
if (!any_isa<const Function *>(IR))
|
||||||
|
|
|
@ -29,6 +29,12 @@
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Transforms/Utils/LoopUtils.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;
|
using namespace llvm;
|
||||||
|
|
||||||
cl::opt<unsigned> llvm::SCEVCheapExpansionBudget(
|
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
|
// We should not look for a incomplete PHI. Getting SCEV for a incomplete
|
||||||
// PHI has no meaning at all.
|
// PHI has no meaning at all.
|
||||||
if (!PN.isComplete()) {
|
if (!PN.isComplete()) {
|
||||||
DEBUG_WITH_TYPE(
|
SCEV_DEBUG_WITH_TYPE(
|
||||||
DebugType, dbgs() << "One incomplete PHI is found: " << PN << "\n");
|
DebugType, dbgs() << "One incomplete PHI is found: " << PN << "\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2086,8 +2092,9 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
|
||||||
Phi->replaceAllUsesWith(V);
|
Phi->replaceAllUsesWith(V);
|
||||||
DeadInsts.emplace_back(Phi);
|
DeadInsts.emplace_back(Phi);
|
||||||
++NumElim;
|
++NumElim;
|
||||||
DEBUG_WITH_TYPE(DebugType, dbgs()
|
SCEV_DEBUG_WITH_TYPE(DebugType,
|
||||||
<< "INDVARS: Eliminated constant iv: " << *Phi << '\n');
|
dbgs() << "INDVARS: Eliminated constant iv: " << *Phi
|
||||||
|
<< '\n');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2144,9 +2151,9 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
|
||||||
TruncExpr == SE.getSCEV(IsomorphicInc) &&
|
TruncExpr == SE.getSCEV(IsomorphicInc) &&
|
||||||
SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc) &&
|
SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc) &&
|
||||||
hoistIVInc(OrigInc, IsomorphicInc)) {
|
hoistIVInc(OrigInc, IsomorphicInc)) {
|
||||||
DEBUG_WITH_TYPE(DebugType,
|
SCEV_DEBUG_WITH_TYPE(
|
||||||
dbgs() << "INDVARS: Eliminated congruent iv.inc: "
|
DebugType, dbgs() << "INDVARS: Eliminated congruent iv.inc: "
|
||||||
<< *IsomorphicInc << '\n');
|
<< *IsomorphicInc << '\n');
|
||||||
Value *NewInc = OrigInc;
|
Value *NewInc = OrigInc;
|
||||||
if (OrigInc->getType() != IsomorphicInc->getType()) {
|
if (OrigInc->getType() != IsomorphicInc->getType()) {
|
||||||
Instruction *IP = nullptr;
|
Instruction *IP = nullptr;
|
||||||
|
@ -2165,10 +2172,11 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG_WITH_TYPE(DebugType, dbgs() << "INDVARS: Eliminated congruent iv: "
|
SCEV_DEBUG_WITH_TYPE(DebugType,
|
||||||
<< *Phi << '\n');
|
dbgs() << "INDVARS: Eliminated congruent iv: " << *Phi
|
||||||
DEBUG_WITH_TYPE(DebugType, dbgs() << "INDVARS: Original iv: "
|
<< '\n');
|
||||||
<< *OrigPhiRef << '\n');
|
SCEV_DEBUG_WITH_TYPE(
|
||||||
|
DebugType, dbgs() << "INDVARS: Original iv: " << *OrigPhiRef << '\n');
|
||||||
++NumElim;
|
++NumElim;
|
||||||
Value *NewIV = OrigPhiRef;
|
Value *NewIV = OrigPhiRef;
|
||||||
if (OrigPhiRef->getType() != Phi->getType()) {
|
if (OrigPhiRef->getType() != Phi->getType()) {
|
||||||
|
|
Loading…
Reference in New Issue