Skip to content

Commit e7e622f

Browse files
Revert "Move DroppedVariableStats to CodeGen lib (#120650)"
This reverts commit 4307198. Broke bot ppc64le-clang-multistage-test: undefined reference to `llvm::DroppedVariableStats::populateVarIDSetAndInlinedMap in In function `llvm::DroppedVariableStatsIR::visitEveryInstruction
1 parent 08db696 commit e7e622f

File tree

8 files changed

+36
-28
lines changed

8 files changed

+36
-28
lines changed

llvm/include/llvm/CodeGen/DroppedVariableStats.h renamed to llvm/include/llvm/Passes/DroppedVariableStats.h

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "llvm/IR/DebugInfoMetadata.h"
1919
#include "llvm/IR/DiagnosticInfo.h"
2020
#include "llvm/IR/Function.h"
21-
#include "llvm/IR/InstIterator.h"
2221
#include "llvm/IR/Module.h"
2322
#include "llvm/IR/PassInstrumentation.h"
2423

@@ -207,33 +206,12 @@ class DroppedVariableStatsIR : public DroppedVariableStats {
207206
virtual void
208207
visitEveryInstruction(unsigned &DroppedCount,
209208
DenseMap<VarID, DILocation *> &InlinedAtsMap,
210-
VarID Var) override {
211-
const DIScope *DbgValScope = std::get<0>(Var);
212-
for (const auto &I : instructions(Func)) {
213-
auto *DbgLoc = I.getDebugLoc().get();
214-
if (!DbgLoc)
215-
continue;
216-
if (updateDroppedCount(DbgLoc, DbgLoc->getScope(), DbgValScope,
217-
InlinedAtsMap, Var, DroppedCount))
218-
break;
219-
}
220-
}
209+
VarID Var) override;
221210
/// Override base class method to run on #dbg_values specifically.
222211
virtual void visitEveryDebugRecord(
223212
DenseSet<VarID> &VarIDSet,
224213
DenseMap<StringRef, DenseMap<VarID, DILocation *>> &InlinedAtsMap,
225-
StringRef FuncName, bool Before) override {
226-
for (const auto &I : instructions(Func)) {
227-
for (DbgRecord &DR : I.getDbgRecordRange()) {
228-
if (auto *Dbg = dyn_cast<DbgVariableRecord>(&DR)) {
229-
auto *DbgVar = Dbg->getVariable();
230-
auto DbgLoc = DR.getDebugLoc();
231-
populateVarIDSetAndInlinedMap(DbgVar, DbgLoc, VarIDSet, InlinedAtsMap,
232-
FuncName, Before);
233-
}
234-
}
235-
}
236-
}
214+
StringRef FuncName, bool Before) override;
237215

238216
template <typename IRUnitT> static const IRUnitT *unwrapIR(Any IR) {
239217
const IRUnitT **IRPtr = llvm::any_cast<const IRUnitT *>(&IR);

llvm/include/llvm/Passes/StandardInstrumentations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
#include "llvm/ADT/SmallVector.h"
2020
#include "llvm/ADT/StringRef.h"
2121
#include "llvm/ADT/StringSet.h"
22-
#include "llvm/CodeGen/DroppedVariableStats.h"
2322
#include "llvm/CodeGen/MachineBasicBlock.h"
2423
#include "llvm/IR/BasicBlock.h"
2524
#include "llvm/IR/DebugInfoMetadata.h"
2625
#include "llvm/IR/OptBisect.h"
2726
#include "llvm/IR/PassTimingInfo.h"
2827
#include "llvm/IR/ValueHandle.h"
28+
#include "llvm/Passes/DroppedVariableStats.h"
2929
#include "llvm/Support/CommandLine.h"
3030
#include "llvm/Support/TimeProfiler.h"
3131
#include "llvm/Transforms/IPO/SampleProfileProbe.h"

llvm/lib/CodeGen/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ add_llvm_component_library(LLVMCodeGen
5050
DeadMachineInstructionElim.cpp
5151
DetectDeadLanes.cpp
5252
DFAPacketizer.cpp
53-
DroppedVariableStats.cpp
5453
DwarfEHPrepare.cpp
5554
EarlyIfConversion.cpp
5655
EdgeBundles.cpp

llvm/lib/Passes/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
add_llvm_component_library(LLVMPasses
22
CodeGenPassBuilder.cpp
3+
DroppedVariableStats.cpp
34
OptimizationLevel.cpp
45
PassBuilder.cpp
56
PassBuilderBindings.cpp

llvm/lib/CodeGen/DroppedVariableStats.cpp renamed to llvm/lib/Passes/DroppedVariableStats.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
///
1212
///===---------------------------------------------------------------------===//
1313

14-
#include "llvm/CodeGen/DroppedVariableStats.h"
14+
#include "llvm/Passes/DroppedVariableStats.h"
1515
#include "llvm/IR/DebugInfoMetadata.h"
1616
#include "llvm/IR/InstIterator.h"
1717
#include "llvm/IR/Module.h"
@@ -162,3 +162,33 @@ void DroppedVariableStatsIR::registerCallbacks(
162162
PIC.registerAfterPassInvalidatedCallback(
163163
[this](StringRef P, const PreservedAnalyses &PA) { return cleanup(); });
164164
}
165+
166+
void DroppedVariableStatsIR::visitEveryInstruction(
167+
unsigned &DroppedCount, DenseMap<VarID, DILocation *> &InlinedAtsMap,
168+
VarID Var) {
169+
const DIScope *DbgValScope = std::get<0>(Var);
170+
for (const auto &I : instructions(Func)) {
171+
auto *DbgLoc = I.getDebugLoc().get();
172+
if (!DbgLoc)
173+
continue;
174+
if (updateDroppedCount(DbgLoc, DbgLoc->getScope(), DbgValScope,
175+
InlinedAtsMap, Var, DroppedCount))
176+
break;
177+
}
178+
}
179+
180+
void DroppedVariableStatsIR::visitEveryDebugRecord(
181+
DenseSet<VarID> &VarIDSet,
182+
DenseMap<StringRef, DenseMap<VarID, DILocation *>> &InlinedAtsMap,
183+
StringRef FuncName, bool Before) {
184+
for (const auto &I : instructions(Func)) {
185+
for (DbgRecord &DR : I.getDbgRecordRange()) {
186+
if (auto *Dbg = dyn_cast<DbgVariableRecord>(&DR)) {
187+
auto *DbgVar = Dbg->getVariable();
188+
auto DbgLoc = DR.getDebugLoc();
189+
populateVarIDSetAndInlinedMap(DbgVar, DbgLoc, VarIDSet, InlinedAtsMap,
190+
FuncName, Before);
191+
}
192+
}
193+
}
194+
}

llvm/unittests/CodeGen/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ add_llvm_unittest(CodeGenTests
2727
CCStateTest.cpp
2828
DIEHashTest.cpp
2929
DIETest.cpp
30-
DroppedVariableStatsIRTest.cpp
3130
DwarfStringPoolEntryRefTest.cpp
3231
InstrRefLDVTest.cpp
3332
LowLevelTypeTest.cpp

llvm/unittests/IR/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ add_llvm_unittest(IRTests
4343
ShuffleVectorInstTest.cpp
4444
StructuralHashTest.cpp
4545
TimePassesTest.cpp
46+
DroppedVariableStatsIRTest.cpp
4647
TypesTest.cpp
4748
UseTest.cpp
4849
UserTest.cpp

0 commit comments

Comments
 (0)