From 249755cedb17ffa707253edcef1a388f807caa35 Mon Sep 17 00:00:00 2001 From: Shubham Sandeep Rastogi Date: Tue, 3 Dec 2024 12:37:30 -0800 Subject: Reland "Add a pass to collect dropped var stats for MIR" (#117044) Moved the MIR Test to the unittests/CodeGen folder This is patch is part of a stack of patches, and follows https://github.com/llvm/llvm-project/pull/117042 I moved the MIR test to the unittests/CodeGen folder I am trying to reland https://github.com/llvm/llvm-project/pull/115566 --- llvm/lib/CodeGen/MachineFunctionPass.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/MachineFunctionPass.cpp') diff --git a/llvm/lib/CodeGen/MachineFunctionPass.cpp b/llvm/lib/CodeGen/MachineFunctionPass.cpp index 62ac3e32d24d..e803811643f8 100644 --- a/llvm/lib/CodeGen/MachineFunctionPass.cpp +++ b/llvm/lib/CodeGen/MachineFunctionPass.cpp @@ -32,6 +32,11 @@ using namespace llvm; using namespace ore; +static cl::opt DroppedVarStatsMIR( + "dropped-variable-stats-mir", cl::Hidden, + cl::desc("Dump dropped debug variables stats for MIR passes"), + cl::init(false)); + Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O, const std::string &Banner) const { return createMachineFunctionPrinterPass(O, Banner); @@ -91,7 +96,15 @@ bool MachineFunctionPass::runOnFunction(Function &F) { MFProps.reset(ClearedProperties); - bool RV = runOnMachineFunction(MF); + bool RV; + if (DroppedVarStatsMIR) { + auto PassName = getPassName(); + DroppedVarStatsMF.runBeforePass(PassName, &MF); + RV = runOnMachineFunction(MF); + DroppedVarStatsMF.runAfterPass(PassName, &MF); + } else { + RV = runOnMachineFunction(MF); + } if (ShouldEmitSizeRemarks) { // We wanted size remarks. Check if there was a change to the number of -- cgit v1.2.3