[llvm] e7e622f - Revert "Move DroppedVariableStats to CodeGen lib (#120650)"
Shubham Sandeep Rastogi via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 19 19:59:42 PST 2024
Author: Shubham Sandeep Rastogi
Date: 2024-12-19T19:59:34-08:00
New Revision: e7e622f153126582670d2d07034e97e1b780a464
URL: https://github.com/llvm/llvm-project/commit/e7e622f153126582670d2d07034e97e1b780a464
DIFF: https://github.com/llvm/llvm-project/commit/e7e622f153126582670d2d07034e97e1b780a464.diff
LOG: Revert "Move DroppedVariableStats to CodeGen lib (#120650)"
This reverts commit 4307198d51487cc16f98eebb2113caf4a1905914.
Broke bot ppc64le-clang-multistage-test:
undefined reference to
`llvm::DroppedVariableStats::populateVarIDSetAndInlinedMap in
In function `llvm::DroppedVariableStatsIR::visitEveryInstruction
Added:
llvm/include/llvm/Passes/DroppedVariableStats.h
llvm/lib/Passes/DroppedVariableStats.cpp
llvm/unittests/IR/DroppedVariableStatsIRTest.cpp
Modified:
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/Passes/CMakeLists.txt
llvm/unittests/CodeGen/CMakeLists.txt
llvm/unittests/IR/CMakeLists.txt
Removed:
llvm/include/llvm/CodeGen/DroppedVariableStats.h
llvm/lib/CodeGen/DroppedVariableStats.cpp
llvm/unittests/CodeGen/DroppedVariableStatsIRTest.cpp
################################################################################
diff --git a/llvm/include/llvm/CodeGen/DroppedVariableStats.h b/llvm/include/llvm/Passes/DroppedVariableStats.h
similarity index 91%
rename from llvm/include/llvm/CodeGen/DroppedVariableStats.h
rename to llvm/include/llvm/Passes/DroppedVariableStats.h
index 8986da53284e87..4555157c942b51 100644
--- a/llvm/include/llvm/CodeGen/DroppedVariableStats.h
+++ b/llvm/include/llvm/Passes/DroppedVariableStats.h
@@ -18,7 +18,6 @@
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
-#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassInstrumentation.h"
@@ -207,33 +206,12 @@ class DroppedVariableStatsIR : public DroppedVariableStats {
virtual void
visitEveryInstruction(unsigned &DroppedCount,
DenseMap<VarID, DILocation *> &InlinedAtsMap,
- VarID Var) override {
- const DIScope *DbgValScope = std::get<0>(Var);
- for (const auto &I : instructions(Func)) {
- auto *DbgLoc = I.getDebugLoc().get();
- if (!DbgLoc)
- continue;
- if (updateDroppedCount(DbgLoc, DbgLoc->getScope(), DbgValScope,
- InlinedAtsMap, Var, DroppedCount))
- break;
- }
- }
+ VarID Var) override;
/// Override base class method to run on #dbg_values specifically.
virtual void visitEveryDebugRecord(
DenseSet<VarID> &VarIDSet,
DenseMap<StringRef, DenseMap<VarID, DILocation *>> &InlinedAtsMap,
- StringRef FuncName, bool Before) override {
- for (const auto &I : instructions(Func)) {
- for (DbgRecord &DR : I.getDbgRecordRange()) {
- if (auto *Dbg = dyn_cast<DbgVariableRecord>(&DR)) {
- auto *DbgVar = Dbg->getVariable();
- auto DbgLoc = DR.getDebugLoc();
- populateVarIDSetAndInlinedMap(DbgVar, DbgLoc, VarIDSet, InlinedAtsMap,
- FuncName, Before);
- }
- }
- }
- }
+ StringRef FuncName, bool Before) override;
template <typename IRUnitT> static const IRUnitT *unwrapIR(Any IR) {
const IRUnitT **IRPtr = llvm::any_cast<const IRUnitT *>(&IR);
diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h
index 12a34c099eaffe..6ba466f9269f09 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -19,13 +19,13 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
-#include "llvm/CodeGen/DroppedVariableStats.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/OptBisect.h"
#include "llvm/IR/PassTimingInfo.h"
#include "llvm/IR/ValueHandle.h"
+#include "llvm/Passes/DroppedVariableStats.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/TimeProfiler.h"
#include "llvm/Transforms/IPO/SampleProfileProbe.h"
diff --git a/llvm/lib/CodeGen/CMakeLists.txt b/llvm/lib/CodeGen/CMakeLists.txt
index 11d8ebf869344b..145fd2fac8b564 100644
--- a/llvm/lib/CodeGen/CMakeLists.txt
+++ b/llvm/lib/CodeGen/CMakeLists.txt
@@ -50,7 +50,6 @@ add_llvm_component_library(LLVMCodeGen
DeadMachineInstructionElim.cpp
DetectDeadLanes.cpp
DFAPacketizer.cpp
- DroppedVariableStats.cpp
DwarfEHPrepare.cpp
EarlyIfConversion.cpp
EdgeBundles.cpp
diff --git a/llvm/lib/Passes/CMakeLists.txt b/llvm/lib/Passes/CMakeLists.txt
index 6425f4934b2103..9e16a446c9b399 100644
--- a/llvm/lib/Passes/CMakeLists.txt
+++ b/llvm/lib/Passes/CMakeLists.txt
@@ -1,5 +1,6 @@
add_llvm_component_library(LLVMPasses
CodeGenPassBuilder.cpp
+ DroppedVariableStats.cpp
OptimizationLevel.cpp
PassBuilder.cpp
PassBuilderBindings.cpp
diff --git a/llvm/lib/CodeGen/DroppedVariableStats.cpp b/llvm/lib/Passes/DroppedVariableStats.cpp
similarity index 84%
rename from llvm/lib/CodeGen/DroppedVariableStats.cpp
rename to llvm/lib/Passes/DroppedVariableStats.cpp
index ef6abad802e4df..5dc6b75fb8ace9 100644
--- a/llvm/lib/CodeGen/DroppedVariableStats.cpp
+++ b/llvm/lib/Passes/DroppedVariableStats.cpp
@@ -11,7 +11,7 @@
///
///===---------------------------------------------------------------------===//
-#include "llvm/CodeGen/DroppedVariableStats.h"
+#include "llvm/Passes/DroppedVariableStats.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Module.h"
@@ -162,3 +162,33 @@ void DroppedVariableStatsIR::registerCallbacks(
PIC.registerAfterPassInvalidatedCallback(
[this](StringRef P, const PreservedAnalyses &PA) { return cleanup(); });
}
+
+void DroppedVariableStatsIR::visitEveryInstruction(
+ unsigned &DroppedCount, DenseMap<VarID, DILocation *> &InlinedAtsMap,
+ VarID Var) {
+ const DIScope *DbgValScope = std::get<0>(Var);
+ for (const auto &I : instructions(Func)) {
+ auto *DbgLoc = I.getDebugLoc().get();
+ if (!DbgLoc)
+ continue;
+ if (updateDroppedCount(DbgLoc, DbgLoc->getScope(), DbgValScope,
+ InlinedAtsMap, Var, DroppedCount))
+ break;
+ }
+}
+
+void DroppedVariableStatsIR::visitEveryDebugRecord(
+ DenseSet<VarID> &VarIDSet,
+ DenseMap<StringRef, DenseMap<VarID, DILocation *>> &InlinedAtsMap,
+ StringRef FuncName, bool Before) {
+ for (const auto &I : instructions(Func)) {
+ for (DbgRecord &DR : I.getDbgRecordRange()) {
+ if (auto *Dbg = dyn_cast<DbgVariableRecord>(&DR)) {
+ auto *DbgVar = Dbg->getVariable();
+ auto DbgLoc = DR.getDebugLoc();
+ populateVarIDSetAndInlinedMap(DbgVar, DbgLoc, VarIDSet, InlinedAtsMap,
+ FuncName, Before);
+ }
+ }
+ }
+}
diff --git a/llvm/unittests/CodeGen/CMakeLists.txt b/llvm/unittests/CodeGen/CMakeLists.txt
index 807fd1a9b7b568..963cdcc0275e16 100644
--- a/llvm/unittests/CodeGen/CMakeLists.txt
+++ b/llvm/unittests/CodeGen/CMakeLists.txt
@@ -27,7 +27,6 @@ add_llvm_unittest(CodeGenTests
CCStateTest.cpp
DIEHashTest.cpp
DIETest.cpp
- DroppedVariableStatsIRTest.cpp
DwarfStringPoolEntryRefTest.cpp
InstrRefLDVTest.cpp
LowLevelTypeTest.cpp
diff --git a/llvm/unittests/IR/CMakeLists.txt b/llvm/unittests/IR/CMakeLists.txt
index 441ef271b20e12..01f02bf5d70ac1 100644
--- a/llvm/unittests/IR/CMakeLists.txt
+++ b/llvm/unittests/IR/CMakeLists.txt
@@ -43,6 +43,7 @@ add_llvm_unittest(IRTests
ShuffleVectorInstTest.cpp
StructuralHashTest.cpp
TimePassesTest.cpp
+ DroppedVariableStatsIRTest.cpp
TypesTest.cpp
UseTest.cpp
UserTest.cpp
diff --git a/llvm/unittests/CodeGen/DroppedVariableStatsIRTest.cpp b/llvm/unittests/IR/DroppedVariableStatsIRTest.cpp
similarity index 100%
rename from llvm/unittests/CodeGen/DroppedVariableStatsIRTest.cpp
rename to llvm/unittests/IR/DroppedVariableStatsIRTest.cpp
More information about the llvm-commits
mailing list