Skip to content

Commit d42e0d1

Browse files
committed
Included the DebugRecordDeleter pass into the -O2 pipeline.
1 parent 5e5886e commit d42e0d1

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@
148148
#include "llvm/Transforms/Vectorize/SLPVectorizer.h"
149149
#include "llvm/Transforms/Vectorize/VectorCombine.h"
150150

151+
#include "llvm/Transforms/Utils/DebugRecordDeleter.h"
152+
151153
using namespace llvm;
152154

153155
namespace llvm {
@@ -1676,6 +1678,11 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
16761678
// Now add the optimization pipeline.
16771679
MPM.addPass(buildModuleOptimizationPipeline(Level, Phase));
16781680

1681+
// Include the DebugRecordDeleter passinto the -O2 pipeline.
1682+
if(Level == OptimizationLevel::O2) {
1683+
MPM.addPass(DebugRecordDeleterPass());
1684+
}
1685+
16791686
if (PGOOpt && PGOOpt->PseudoProbeForProfiling &&
16801687
PGOOpt->Action == PGOOptions::SampleUse)
16811688
MPM.addPass(PseudoProbeUpdatePass());
@@ -1684,7 +1691,7 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
16841691
addAnnotationRemarksPass(MPM);
16851692

16861693
if (isLTOPreLink(Phase))
1687-
addRequiredLTOPreLinkPasses(MPM);
1694+
addRequiredLTOPreLinkPasses(MPM);
16881695
return MPM;
16891696
}
16901697

llvm/lib/Transforms/Utils/DebugRecordCounter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ PreservedAnalyses DebugRecordCounterPass::run(Module &M, ModuleAnalysisManager &
1818
for(Instruction &I : BB) {
1919
for(DbgVariableRecord &DVR : filterDbgVars(I.getDbgRecordRange())) {
2020
if(DVR.isDbgDeclare()) dbg_declares++;
21-
if(DVR.isDbgValue()) dbg_values++;
22-
if(DVR.isDbgAssign()) dbg_assigns++;
21+
if(DVR.isDbgValue()) dbg_values++;
22+
if(DVR.isDbgAssign()) dbg_assigns++;
2323
}
2424
}
2525
}
26-
errs() << "\t#dbg_value: " << dbg_values << "\n";
26+
errs() << "\t#dbg_value: " << dbg_values << "\n";
2727
errs() << "\t#dbg_declare: " << dbg_declares << "\n";
28-
errs() << "\t#dbg_assign: " << dbg_assigns << "\n";
28+
errs() << "\t#dbg_assign: " << dbg_assigns << "\n";
2929
}
3030
return PreservedAnalyses::all();
3131
}

llvm/lib/Transforms/Utils/DebugRecordDeleter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include "llvm/IR/DebugInfo.h"
55
#include "llvm/IR/DebugInfoMetadata.h"
66

7+
#include "llvm/Passes/PassBuilder.h"
8+
#include "llvm/Passes/PassPlugin.h"
9+
#include "llvm/Passes/OptimizationLevel.h"
10+
711
using namespace llvm;
812

913
// build/bin/opt -S /home/ana-marija/Documents/foo_00.ll -passes=dbg-deleter

0 commit comments

Comments
 (0)