Skip to content

Commit 16d9528

Browse files
Revert "Add a pass to collect dropped var stats for MIR (#120501)"
This reverts commit 223c764. Reverted due to vuildbot failure: flang-aarch64-libcxx Linking CXX shared library lib/libLLVMAnalysis.so.20.0git FAILED: lib/libLLVMAnalysis.so.20.0git
1 parent 223c764 commit 16d9528

File tree

7 files changed

+3
-1194
lines changed

7 files changed

+3
-1194
lines changed

llvm/include/llvm/Analysis/DroppedVariableStats.h

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
///===---------------------------------------------------------------------===//
88
/// \file
99
/// Dropped Variable Statistics for Debug Information. Reports any number
10-
/// of #dbg_values or DBG_VALUEs that get dropped due to an optimization pass.
10+
/// of #dbg_value that get dropped due to an optimization pass.
1111
///
1212
///===---------------------------------------------------------------------===//
1313

@@ -219,52 +219,6 @@ class DroppedVariableStatsIR : public DroppedVariableStats {
219219
}
220220
};
221221

222-
/// A class to collect and print dropped debug information due to MIR
223-
/// optimization passes. After every MIR pass is run, it will print how many
224-
/// #DBG_VALUEs were dropped due to that pass.
225-
class DroppedVariableStatsMIR : public DroppedVariableStats {
226-
public:
227-
DroppedVariableStatsMIR() : llvm::DroppedVariableStats(false) {}
228-
229-
void runBeforePass(StringRef PassID, MachineFunction *MF) {
230-
if (PassID == "Debug Variable Analysis")
231-
return;
232-
setup();
233-
return runOnMachineFunction(MF, true);
234-
}
235-
236-
void runAfterPass(StringRef PassID, MachineFunction *MF) {
237-
if (PassID == "Debug Variable Analysis")
238-
return;
239-
runOnMachineFunction(MF, false);
240-
calculateDroppedVarStatsOnMachineFunction(MF, PassID, MF->getName().str());
241-
cleanup();
242-
}
243-
244-
private:
245-
const MachineFunction *MFunc;
246-
/// Populate DebugVariablesBefore, DebugVariablesAfter, InlinedAts before or
247-
/// after a pass has run to facilitate dropped variable calculation for an
248-
/// llvm::MachineFunction.
249-
void runOnMachineFunction(const MachineFunction *MF, bool Before);
250-
/// Iterate over all Instructions in a MachineFunction and report any dropped
251-
/// debug information.
252-
void calculateDroppedVarStatsOnMachineFunction(const MachineFunction *MF,
253-
StringRef PassID,
254-
StringRef FuncOrModName);
255-
/// Override base class method to run on an llvm::MachineFunction
256-
/// specifically.
257-
virtual void
258-
visitEveryInstruction(unsigned &DroppedCount,
259-
DenseMap<VarID, DILocation *> &InlinedAtsMap,
260-
VarID Var) override;
261-
/// Override base class method to run on DBG_VALUEs specifically.
262-
virtual void visitEveryDebugRecord(
263-
DenseSet<VarID> &VarIDSet,
264-
DenseMap<StringRef, DenseMap<VarID, DILocation *>> &InlinedAtsMap,
265-
StringRef FuncName, bool Before) override;
266-
};
267-
268222
} // namespace llvm
269223

270224
#endif

llvm/include/llvm/CodeGen/MachineFunctionPass.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#ifndef LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
1919
#define LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
2020

21-
#include "llvm/Analysis/DroppedVariableStats.h"
2221
#include "llvm/CodeGen/MachineFunction.h"
2322
#include "llvm/Pass.h"
2423

@@ -68,7 +67,6 @@ class MachineFunctionPass : public FunctionPass {
6867
MachineFunctionProperties RequiredProperties;
6968
MachineFunctionProperties SetProperties;
7069
MachineFunctionProperties ClearedProperties;
71-
DroppedVariableStatsMIR DroppedVarStatsMF;
7270

7371
/// createPrinterPass - Get a machine function printer pass.
7472
Pass *createPrinterPass(raw_ostream &O,

llvm/lib/Analysis/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ add_llvm_component_library(LLVMAnalysis
5050
CycleAnalysis.cpp
5151
DDG.cpp
5252
DDGPrinter.cpp
53-
DroppedVariableStats.cpp
5453
ConstraintSystem.cpp
5554
Delinearization.cpp
5655
DemandedBits.cpp

llvm/lib/Analysis/DroppedVariableStats.cpp

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
///===---------------------------------------------------------------------===//
88
/// \file
99
/// Dropped Variable Statistics for Debug Information. Reports any number
10-
/// of #dbg_values or DBG_VALUEs that get dropped due to an optimization pass.
10+
/// of #dbg_value that get dropped due to an optimization pass.
1111
///
1212
///===---------------------------------------------------------------------===//
1313

@@ -192,64 +192,3 @@ void DroppedVariableStatsIR::visitEveryDebugRecord(
192192
}
193193
}
194194
}
195-
196-
void DroppedVariableStatsMIR::runOnMachineFunction(const MachineFunction *MF,
197-
bool Before) {
198-
auto &DebugVariables = DebugVariablesStack.back()[&MF->getFunction()];
199-
auto FuncName = MF->getName();
200-
MFunc = MF;
201-
run(DebugVariables, FuncName, Before);
202-
}
203-
204-
void DroppedVariableStatsMIR::calculateDroppedVarStatsOnMachineFunction(
205-
const MachineFunction *MF, StringRef PassID, StringRef FuncOrModName) {
206-
MFunc = MF;
207-
StringRef FuncName = MF->getName();
208-
const Function *Func = &MF->getFunction();
209-
DebugVariables &DbgVariables = DebugVariablesStack.back()[Func];
210-
calculateDroppedStatsAndPrint(DbgVariables, FuncName, PassID, FuncOrModName,
211-
"MachineFunction", Func);
212-
}
213-
214-
void DroppedVariableStatsMIR::visitEveryInstruction(
215-
unsigned &DroppedCount, DenseMap<VarID, DILocation *> &InlinedAtsMap,
216-
VarID Var) {
217-
unsigned PrevDroppedCount = DroppedCount;
218-
const DIScope *DbgValScope = std::get<0>(Var);
219-
for (const auto &MBB : *MFunc) {
220-
for (const auto &MI : MBB) {
221-
if (!MI.isDebugInstr()) {
222-
auto *DbgLoc = MI.getDebugLoc().get();
223-
if (!DbgLoc)
224-
continue;
225-
226-
auto *Scope = DbgLoc->getScope();
227-
if (updateDroppedCount(DbgLoc, Scope, DbgValScope, InlinedAtsMap, Var,
228-
DroppedCount))
229-
break;
230-
}
231-
}
232-
if (PrevDroppedCount != DroppedCount) {
233-
PrevDroppedCount = DroppedCount;
234-
break;
235-
}
236-
}
237-
}
238-
239-
void DroppedVariableStatsMIR::visitEveryDebugRecord(
240-
DenseSet<VarID> &VarIDSet,
241-
DenseMap<StringRef, DenseMap<VarID, DILocation *>> &InlinedAtsMap,
242-
StringRef FuncName, bool Before) {
243-
for (const auto &MBB : *MFunc) {
244-
for (const auto &MI : MBB) {
245-
if (MI.isDebugValueLike()) {
246-
auto *DbgVar = MI.getDebugVariable();
247-
if (!DbgVar)
248-
continue;
249-
auto DbgLoc = MI.getDebugLoc();
250-
populateVarIDSetAndInlinedMap(DbgVar, DbgLoc, VarIDSet, InlinedAtsMap,
251-
FuncName, Before);
252-
}
253-
}
254-
}
255-
}

llvm/lib/CodeGen/MachineFunctionPass.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@
3232
using namespace llvm;
3333
using namespace ore;
3434

35-
static cl::opt<bool> DroppedVarStatsMIR(
36-
"dropped-variable-stats-mir", cl::Hidden,
37-
cl::desc("Dump dropped debug variables stats for MIR passes"),
38-
cl::init(false));
39-
4035
Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O,
4136
const std::string &Banner) const {
4237
return createMachineFunctionPrinterPass(O, Banner);
@@ -96,15 +91,7 @@ bool MachineFunctionPass::runOnFunction(Function &F) {
9691

9792
MFProps.reset(ClearedProperties);
9893

99-
bool RV;
100-
if (DroppedVarStatsMIR) {
101-
auto PassName = getPassName();
102-
DroppedVarStatsMF.runBeforePass(PassName, &MF);
103-
RV = runOnMachineFunction(MF);
104-
DroppedVarStatsMF.runAfterPass(PassName, &MF);
105-
} else {
106-
RV = runOnMachineFunction(MF);
107-
}
94+
bool RV = runOnMachineFunction(MF);
10895

10996
if (ShouldEmitSizeRemarks) {
11097
// We wanted size remarks. Check if there was a change to the number of

llvm/unittests/MIR/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ set(LLVM_LINK_COMPONENTS
1414
)
1515

1616
add_llvm_unittest(MIRTests
17-
DroppedVariableStatsMIRTest.cpp
1817
MachineMetadata.cpp
1918
MachineStableHashTest.cpp
2019
)

0 commit comments

Comments
 (0)