Skip to content

Commit b6097c8

Browse files
cjdbSterling-Augustine
authored andcommitted
Revert "Fix LLVM_ENABLE_ABI_BREAKING_CHECKS macro check: use #if inst… (llvm#110923)
…ead of #ifdef (llvm#110883)" This reverts commit 1905cdb, which causes lots of failures where LLVM doesn't have the right header guards. The errors can be seen on [BuildKite](https://buildkite.com/llvm-project/upstream-bazel/builds/112362#01924eae-231c-4d06-ba87-2c538cf40e04), where the source uses `#ifndef NDEBUG`, but the content in question is defined when `LLVM_ENABLE_ABI_BREAKING_CHECKS == 1`. For example, `llvm/include/llvm/Support/GenericDomTreeConstruction.h` has the following: ```cpp // Helper struct used during edge insertions. struct InsertionInfo { // ... #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS SmallVector<TreeNodePtr, 8> VisitedUnaffected; #endif }; // ... InsertionInfo II; // ... #ifndef NDEBUG II.VisitedUnaffected.push_back(SuccTN); #endif ```
1 parent 586f974 commit b6097c8

File tree

13 files changed

+32
-32
lines changed

13 files changed

+32
-32
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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
587+
#ifndef NDEBUG
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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
174+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
175175
SmallVector<StringRef, 8> PassStack;
176176
#endif
177177

llvm/include/llvm/Support/GenericDomTreeConstruction.h

Lines changed: 2 additions & 2 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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
643+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
644644
SmallVector<TreeNodePtr, 8> VisitedUnaffected;
645645
#endif
646646
};
@@ -915,7 +915,7 @@ struct SemiNCAInfo {
915915
LLVM_DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> "
916916
<< BlockNamePrinter(To) << "\n");
917917

918-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
918+
#ifdef 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-
SmallSet<AssertingVH<const BasicBlock>, 16> LoopHeaders;
93-
#else
9492
SmallPtrSet<const BasicBlock *, 16> LoopHeaders;
93+
#else
94+
SmallSet<AssertingVH<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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
259+
#ifdef 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 LLVM_ENABLE_ABI_BREAKING_CHECKS && !defined(NDEBUG)
298+
#if defined(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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
350+
#ifdef 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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
171+
#ifdef 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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
187+
#ifdef 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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
197+
#ifdef 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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
11728+
#ifndef NDEBUG
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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
1361+
#ifdef 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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
1390+
#ifdef 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-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
1399+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
14001400
assert(PassStack.pop_back_val() == P &&
14011401
"Before and After callbacks must correspond");
14021402
#endif

llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "llvm/Support/raw_ostream.h"
2929
#include "llvm/Transforms/Utils/LoopUtils.h"
3030

31-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
31+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
3232
#define SCEV_DEBUG_WITH_TYPE(TYPE, X) DEBUG_WITH_TYPE(TYPE, X)
3333
#else
3434
#define SCEV_DEBUG_WITH_TYPE(TYPE, X)

mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Identifier {
7575
template <typename T>
7676
explicit Identifier(T value)
7777
: value(llvm::PointerLikeTypeTraits<T>::getAsVoidPointer(value)) {
78-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
78+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
7979
idType = llvm::getTypeName<T>();
8080
#endif
8181
}
@@ -84,7 +84,7 @@ class Identifier {
8484
/// the type of the identifier used to create it.
8585
template <typename T>
8686
T getValue() const {
87-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
87+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
8888
assert(llvm::getTypeName<T>() == idType &&
8989
"Identifier was initialized with a different type than the one used "
9090
"to retrieve it.");
@@ -108,7 +108,7 @@ class Identifier {
108108
/// The value of the identifier.
109109
void *value = nullptr;
110110

111-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
111+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
112112
/// TypeID of the identifiers in space. This should be used in asserts only.
113113
llvm::StringRef idType;
114114
#endif

mlir/include/mlir/Dialect/Transform/Interfaces/TransformInterfaces.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class TransformState {
196196
/// should be emitted when the value is used.
197197
using InvalidatedHandleMap = DenseMap<Value, std::function<void(Location)>>;
198198

199-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
199+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
200200
/// Debug only: A timestamp is associated with each transform IR value, so
201201
/// that invalid iterator usage can be detected more reliably.
202202
using TransformIRTimestampMapping = DenseMap<Value, int64_t>;
@@ -211,7 +211,7 @@ class TransformState {
211211
ValueMapping values;
212212
ValueMapping reverseValues;
213213

214-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
214+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
215215
TransformIRTimestampMapping timestamps;
216216
void incrementTimestamp(Value value) { ++timestamps[value]; }
217217
#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS
@@ -248,7 +248,7 @@ class TransformState {
248248
auto getPayloadOps(Value value) const {
249249
ArrayRef<Operation *> view = getPayloadOpsView(value);
250250

251-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
251+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
252252
// Memorize the current timestamp and make sure that it has not changed
253253
// when incrementing or dereferencing the iterator returned by this
254254
// function. The timestamp is incremented when the "direct" mapping is
@@ -259,7 +259,7 @@ class TransformState {
259259
// When ops are replaced/erased, they are replaced with nullptr (until
260260
// the data structure is compacted). Do not enumerate these ops.
261261
return llvm::make_filter_range(view, [=](Operation *op) {
262-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
262+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
263263
[[maybe_unused]] bool sameTimestamp =
264264
currentTimestamp == this->getMapping(value).timestamps.lookup(value);
265265
assert(sameTimestamp && "iterator was invalidated during iteration");
@@ -277,7 +277,7 @@ class TransformState {
277277
auto getPayloadValues(Value handleValue) const {
278278
ArrayRef<Value> view = getPayloadValuesView(handleValue);
279279

280-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
280+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
281281
// Memorize the current timestamp and make sure that it has not changed
282282
// when incrementing or dereferencing the iterator returned by this
283283
// function. The timestamp is incremented when the "values" mapping is

mlir/include/mlir/IR/PDLPatternMatch.h.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ template <typename PDLFnT, std::size_t... I>
625625
void assertArgs(PatternRewriter &rewriter, ArrayRef<PDLValue> values,
626626
std::index_sequence<I...>) {
627627
// We only want to do verification in debug builds, same as with `assert`.
628-
#ifndef NDEBUG
628+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
629629
using FnTraitsT = llvm::function_traits<PDLFnT>;
630630
auto errorFn = [&](const Twine &msg) -> LogicalResult {
631631
llvm::report_fatal_error(msg);

mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void transform::TransformState::forgetMapping(Value opHandle,
330330
for (Operation *op : mappings.direct[opHandle])
331331
dropMappingEntry(mappings.reverse, op, opHandle);
332332
mappings.direct.erase(opHandle);
333-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
333+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
334334
// Payload IR is removed from the mapping. This invalidates the respective
335335
// iterators.
336336
mappings.incrementTimestamp(opHandle);
@@ -342,7 +342,7 @@ void transform::TransformState::forgetMapping(Value opHandle,
342342
for (Value resultHandle : resultHandles) {
343343
Mappings &localMappings = getMapping(resultHandle);
344344
dropMappingEntry(localMappings.values, resultHandle, opResult);
345-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
345+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
346346
// Payload IR is removed from the mapping. This invalidates the respective
347347
// iterators.
348348
mappings.incrementTimestamp(resultHandle);
@@ -358,7 +358,7 @@ void transform::TransformState::forgetValueMapping(
358358
for (Value payloadValue : mappings.reverseValues[valueHandle])
359359
dropMappingEntry(mappings.reverseValues, payloadValue, valueHandle);
360360
mappings.values.erase(valueHandle);
361-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
361+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
362362
// Payload IR is removed from the mapping. This invalidates the respective
363363
// iterators.
364364
mappings.incrementTimestamp(valueHandle);
@@ -372,7 +372,7 @@ void transform::TransformState::forgetValueMapping(
372372
dropMappingEntry(localMappings.direct, opHandle, payloadOp);
373373
dropMappingEntry(localMappings.reverse, payloadOp, opHandle);
374374

375-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
375+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
376376
// Payload IR is removed from the mapping. This invalidates the respective
377377
// iterators.
378378
localMappings.incrementTimestamp(opHandle);
@@ -452,7 +452,7 @@ transform::TransformState::replacePayloadValue(Value value, Value replacement) {
452452
// between the handles and the IR objects
453453
if (!replacement) {
454454
dropMappingEntry(mappings.values, handle, value);
455-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
455+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
456456
// Payload IR is removed from the mapping. This invalidates the respective
457457
// iterators.
458458
mappings.incrementTimestamp(handle);
@@ -804,7 +804,7 @@ checkRepeatedConsumptionInOperand(ArrayRef<T> payload,
804804
void transform::TransformState::compactOpHandles() {
805805
for (Value handle : opHandlesToCompact) {
806806
Mappings &mappings = getMapping(handle, /*allowOutOfScope=*/true);
807-
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
807+
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
808808
if (llvm::find(mappings.direct[handle], nullptr) !=
809809
mappings.direct[handle].end())
810810
// Payload IR is removed from the mapping. This invalidates the respective

0 commit comments

Comments
 (0)