Skip to content

Commit 6c7a3f8

Browse files
authored
Fix LLVM_ENABLE_ABI_BREAKING_CHECKS macro check: use #if instead of #ifdef (#110938)
This macros is always defined: either 0 or 1. The correct pattern is to use #if. Re-apply #110185 with more fixes for debug build with the ABI breaking checks disabled.
1 parent e3686f1 commit 6c7a3f8

File tree

18 files changed

+41
-39
lines changed

18 files changed

+41
-39
lines changed

llvm/include/llvm/CodeGen/SelectionDAG.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ class SelectionDAG {
584584
return Root;
585585
}
586586

587-
#ifndef NDEBUG
587+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
588588
void VerifyDAGDivergence();
589589
#endif
590590

llvm/include/llvm/Passes/StandardInstrumentations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class PreservedCFGCheckerInstrumentation {
171171
FunctionAnalysisManager::Invalidator &);
172172
};
173173

174-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
174+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
175175
SmallVector<StringRef, 8> PassStack;
176176
#endif
177177

llvm/include/llvm/Support/GenericDomTreeConstruction.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ struct SemiNCAInfo {
640640
Bucket;
641641
SmallDenseSet<TreeNodePtr, 8> Visited;
642642
SmallVector<TreeNodePtr, 8> Affected;
643-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
643+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
644644
SmallVector<TreeNodePtr, 8> VisitedUnaffected;
645645
#endif
646646
};
@@ -815,7 +815,7 @@ struct SemiNCAInfo {
815815
LLVM_DEBUG(dbgs() << "\t\tMarking visited not affected "
816816
<< BlockNamePrinter(Succ) << "\n");
817817
UnaffectedOnCurrentLevel.push_back(SuccTN);
818-
#ifndef NDEBUG
818+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
819819
II.VisitedUnaffected.push_back(SuccTN);
820820
#endif
821821
} else {
@@ -849,7 +849,7 @@ struct SemiNCAInfo {
849849
TN->setIDom(NCD);
850850
}
851851

852-
#if defined(LLVM_ENABLE_ABI_BREAKING_CHECKS) && !defined(NDEBUG)
852+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS && !defined(NDEBUG)
853853
for (const TreeNodePtr TN : II.VisitedUnaffected)
854854
assert(TN->getLevel() == TN->getIDom()->getLevel() + 1 &&
855855
"TN should have been updated by an affected ancestor");
@@ -915,7 +915,7 @@ struct SemiNCAInfo {
915915
LLVM_DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> "
916916
<< BlockNamePrinter(To) << "\n");
917917

918-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
918+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
919919
// Ensure that the edge was in fact deleted from the CFG before informing
920920
// the DomTree about it.
921921
// The check is O(N), so run it only in debug configuration.

llvm/include/llvm/Transforms/Scalar/JumpThreading.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
8989
bool ChangedSinceLastAnalysisUpdate = false;
9090
bool HasGuards = false;
9191
#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
92-
SmallPtrSet<const BasicBlock *, 16> LoopHeaders;
93-
#else
9492
SmallSet<AssertingVH<const BasicBlock>, 16> LoopHeaders;
93+
#else
94+
SmallPtrSet<const BasicBlock *, 16> LoopHeaders;
9595
#endif
9696

9797
unsigned BBDupThreshold;

llvm/include/llvm/Transforms/Scalar/LoopPassManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class LPMUpdater {
256256
}
257257

258258
void setParentLoop(Loop *L) {
259-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
259+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
260260
ParentL = L;
261261
#endif
262262
}
@@ -295,7 +295,7 @@ class LPMUpdater {
295295
/// loops within them will be visited in postorder as usual for the loop pass
296296
/// manager.
297297
void addSiblingLoops(ArrayRef<Loop *> NewSibLoops) {
298-
#if defined(LLVM_ENABLE_ABI_BREAKING_CHECKS) && !defined(NDEBUG)
298+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS && !defined(NDEBUG)
299299
for (Loop *NewL : NewSibLoops)
300300
assert(NewL->getParentLoop() == ParentL &&
301301
"All of the new loops must be siblings of the current loop!");
@@ -347,7 +347,7 @@ class LPMUpdater {
347347
const bool LoopNestMode;
348348
bool LoopNestChanged;
349349

350-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
350+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
351351
// In debug builds we also track the parent loop to implement asserts even in
352352
// the face of loop deletion.
353353
Loop *ParentL;

llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
168168
/// consistent when instructions are moved.
169169
SmallVector<SCEVInsertPointGuard *, 8> InsertPointGuards;
170170

171-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
171+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
172172
const char *DebugType;
173173
#endif
174174

@@ -184,7 +184,7 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
184184
Builder(se.getContext(), InstSimplifyFolder(DL),
185185
IRBuilderCallbackInserter(
186186
[this](Instruction *I) { rememberInstruction(I); })) {
187-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
187+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
188188
DebugType = "";
189189
#endif
190190
}
@@ -194,7 +194,7 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
194194
assert(InsertPointGuards.empty());
195195
}
196196

197-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
197+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
198198
void setDebugType(const char *s) { DebugType = s; }
199199
#endif
200200

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11725,7 +11725,7 @@ void SelectionDAG::CreateTopologicalOrder(std::vector<SDNode *> &Order) {
1172511725
}
1172611726
}
1172711727

11728-
#ifndef NDEBUG
11728+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
1172911729
void SelectionDAG::VerifyDAGDivergence() {
1173011730
std::vector<SDNode *> TopoOrder;
1173111731
CreateTopologicalOrder(TopoOrder);

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ void PreservedCFGCheckerInstrumentation::registerCallbacks(
13581358
bool Registered = false;
13591359
PIC.registerBeforeNonSkippedPassCallback([this, &MAM, Registered](
13601360
StringRef P, Any IR) mutable {
1361-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
1361+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
13621362
assert(&PassStack.emplace_back(P));
13631363
#endif
13641364
(void)this;
@@ -1387,7 +1387,7 @@ void PreservedCFGCheckerInstrumentation::registerCallbacks(
13871387

13881388
PIC.registerAfterPassInvalidatedCallback(
13891389
[this](StringRef P, const PreservedAnalyses &PassPA) {
1390-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
1390+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
13911391
assert(PassStack.pop_back_val() == P &&
13921392
"Before and After callbacks must correspond");
13931393
#endif
@@ -1396,7 +1396,7 @@ void PreservedCFGCheckerInstrumentation::registerCallbacks(
13961396

13971397
PIC.registerAfterPassCallback([this, &MAM](StringRef P, Any IR,
13981398
const PreservedAnalyses &PassPA) {
1399-
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
1399+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
14001400
assert(PassStack.pop_back_val() == P &&
14011401
"Before and After callbacks must correspond");
14021402
#endif

llvm/lib/Transforms/Scalar/IndVarSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ bool IndVarSimplify::run(Loop *L) {
19201920

19211921
// Create a rewriter object which we'll use to transform the code with.
19221922
SCEVExpander Rewriter(*SE, DL, "indvars");
1923-
#ifndef NDEBUG
1923+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
19241924
Rewriter.setDebugType(DEBUG_TYPE);
19251925
#endif
19261926

llvm/lib/Transforms/Scalar/LoopPassManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F,
293293
Updater.CurrentL = L;
294294
Updater.SkipCurrentLoop = false;
295295

296-
#ifndef NDEBUG
296+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
297297
// Save a parent loop pointer for asserts.
298298
Updater.ParentL = L->getParentLoop();
299299
#endif

0 commit comments

Comments
 (0)