Skip to content

Commit 5215430

Browse files
DomTree
1 parent 519f46b commit 5215430

File tree

5 files changed

+1871
-5
lines changed

5 files changed

+1871
-5
lines changed

NewPMExample/FunctionPass.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "llvm/Analysis/Verifier.h"
99
#include "llvm/IR/BasicBlock.h"
1010
#include "llvm/IR/CFG.h"
11+
#include "llvm/IR/IRBuilder.h"
1112
#include "llvm/IR/PassManager.h"
1213
#include "llvm/Passes/PassBuilder.h"
1314
#include "llvm/Passes/PassPlugin.h"
@@ -37,11 +38,19 @@ struct PrinterPass final : public PassInfoMixin<PrinterPass> {
3738
LoopInfo &getLI = FAM.getResult<llvm::LoopAnalysis>(F);
3839
DominatorTree &DT = FAM.getResult<DominatorTreeAnalysis>(F);
3940

41+
/**
42+
* @brief Loop Info Analysis
43+
*/
4044
if (getLI.empty())
4145
std::cout << "No Loops ! \n\n";
4246
else
4347
getLI.print(errs());
4448

49+
/**
50+
* @brief Print Dominator Tree to llvm::errs()
51+
*/
52+
DT.print(errs());
53+
4554
std::cout << "Function: " << F.getName().str() << std::endl;
4655
for (Function::iterator BB = F.begin(); BB != F.end(); BB++) {
4756
std::cout << "\tBasic Block : " << BB->getName().str()
@@ -52,6 +61,7 @@ struct PrinterPass final : public PassInfoMixin<PrinterPass> {
5261
auto phi = dyn_cast<PHINode>(I);
5362
if (phi != NULL)
5463
errs() << "\t\tPhi Alloca : " << phi << "\n";
64+
5565
for (Use &U : I->operands()) {
5666
Value *v = U.get();
5767
if (v != NULL)

NewPMExample/cfg_example1.pdf

17.3 KB
Binary file not shown.

NewPMExample/domtree.pdf

14.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)