LLVM: lib/Analysis/RegionPass.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

24

25using namespace llvm;

26

27#define DEBUG_TYPE "regionpassmgr"

28

29

30

31

32

34

36 RI = nullptr;

37 CurrentRegion = nullptr;

38}

39

40

42 RQ.push_back(&R);

43 for (const auto &E : R)

45}

46

47

50 Info.setPreservesAll();

51}

52

53

54

56 RI = &getAnalysis().getRegionInfo();

57 bool Changed = false;

58

59

61

63

64 if (RQ.empty())

65 return false;

66

67

68 for (Region *R : RQ) {

71 Changed |= RP->doInitialization(R, *this);

72 }

73 }

74

75

76 while (!RQ.empty()) {

77

78 CurrentRegion = RQ.back();

79

80

83

88 }

89

91

92 bool LocalChanged = false;

93 {

95

97#ifdef EXPENSIVE_CHECKS

98 uint64_t RefHash = P->structuralHash(F);

99#endif

100 LocalChanged = P->runOnRegion(CurrentRegion, *this);

101

102#ifdef EXPENSIVE_CHECKS

103 if (!LocalChanged && (RefHash != P->structuralHash(F))) {

104 llvm::errs() << "Pass modifies its input and doesn't report it: "

105 << P->getPassName() << "\n";

106 llvm_unreachable("Pass modifies its input and doesn't report it");

107 }

108#endif

109

110 Changed |= LocalChanged;

111 }

112

114 if (LocalChanged)

118 }

119

120

121

122

123

124

125 {

128 }

129

130

132

133 if (LocalChanged)

138 ? ""

141 }

142

143

144 RQ.pop_back();

145

146

148 }

149

150

153 Changed |= P->doFinalization();

154 }

155

156

157 LLVM_DEBUG(dbgs() << "\nRegion tree of function " << F.getName()

158 << " after all region Pass:\n";

159 RI->dump(); dbgs() << "\n";);

160

161 return Changed;

162}

163

164

169 P->dumpPassStructure(Offset + 1);

171 }

172}

173

174namespace {

175

176

177class PrintRegionPass : public RegionPass {

178private:

179 std::string Banner;

180 raw_ostream &Out;

181

182public:

183 static char ID;

184 PrintRegionPass(const std::string &B, raw_ostream &o)

186

187 void getAnalysisUsage(AnalysisUsage &AU) const override {

189 }

190

193 return false;

194 Out << Banner;

195 for (const auto *BB : R->blocks()) {

196 if (BB)

197 BB->print(Out);

198 else

199 Out << "Printing Block";

200 }

201

202 return false;

203 }

204

205 StringRef getPassName() const override { return "Print Region IR"; }

206};

207

208char PrintRegionPass::ID = 0;

209}

210

211

212

213

214

215

216

217

218

219

221

222

223 while (!PMS.empty() &&

225 PMS.pop();

226

227

228

229

230

233 PMS.pop();

234}

235

236

239

240 while (!PMS.empty() &&

242 PMS.pop();

243

245

246

249 else {

250

251 assert (!PMS.empty() && "Unable to create Region Pass Manager");

253

254

257

258

261

262

263

265

266

267 PMS.push(RGPM);

268 }

269

270 RGPM->add(this);

271}

272

273

275 const std::string &Banner) const {

276 return new PrintRegionPass(Banner, O);

277}

278

280 return "region";

281}

282

284 Function &F = *R.getEntry()->getParent();

285 OptPassGate &Gate = F.getContext().getOptPassGate();

288 return true;

289

290 if (F.hasOptNone()) {

291

292 if (R.getEntry() == &F.getEntryBlock())

294 << "' on function " << F.getName() << "\n");

295 return true;

296 }

297 return false;

298}

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

Analysis containing CSE Info

static std::string getDescription(const CallGraphSCC &SCC)

static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")

This file declares the interface for bisecting optimizations.

This header defines classes/functions to handle pass execution timing information with interfaces for...

static void addRegionIntoQueue(Region &R, std::deque< Region * > &RQ)

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

Represent the analysis usage information of a pass.

void setPreservesAll()

Set by analyses that do not transform their input at all.

FunctionPass class - This class is used to implement most global optimizations.

Extensions to this class implement mechanisms to disable passes and individual optimizations at compi...

virtual bool isEnabled() const

isEnabled() should return true before calling shouldRunPass().

virtual bool shouldRunPass(const StringRef PassName, StringRef IRDescription)

IRDescription is a textual description of the IR unit the pass is running over.

PMDataManager provides the common place to manage the analysis data used by pass managers.

void removeDeadPasses(Pass *P, StringRef Msg, enum PassDebuggingString)

Remove dead passes used by P.

void dumpLastUses(Pass *P, unsigned Offset) const

void recordAvailableAnalysis(Pass *P)

Augment AvailableAnalysis by adding analysis made available by pass P.

bool isPassDebuggingExecutionsOrMore() const

isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions or higher is specified.

PMTopLevelManager * getTopLevelManager()

void dumpRequiredSet(const Pass *P) const

void initializeAnalysisImpl(Pass *P)

All Required analyses should be available to the pass as it runs! Here we fill in the AnalysisImpls m...

void verifyPreservedAnalysis(Pass *P)

verifyPreservedAnalysis – Verify analysis presreved by pass P.

bool preserveHigherLevelAnalysis(Pass *P)

unsigned getNumContainedPasses() const

virtual PassManagerType getPassManagerType() const

void add(Pass *P, bool ProcessAnalysis=true)

Add pass P into the PassVector.

void populateInheritedAnalysis(PMStack &PMS)

void dumpPreservedSet(const Pass *P) const

void removeNotPreservedAnalysis(Pass *P)

Remove Analysis that is not preserved by the pass.

void dumpPassInfo(Pass *P, enum PassDebuggingString S1, enum PassDebuggingString S2, StringRef Msg)

PMStack - This class implements a stack data structure of PMDataManager pointers.

PMDataManager * top() const

void push(PMDataManager *PM)

PMTopLevelManager manages LastUser info and collects common APIs used by top level pass managers.

void addIndirectPassManager(PMDataManager *Manager)

void schedulePass(Pass *P)

Schedule pass P for execution.

PassManagerPrettyStackEntry - This is used to print informative information about what pass is runnin...

Pass interface - Implemented by all 'passes'.

virtual StringRef getPassName() const

getPassName - Return a nice clean name for a pass.

The pass manager to schedule RegionPasses.

void dumpPassStructure(unsigned Offset) override

Print passes managed by this manager.

Pass * getContainedPass(unsigned N)

Get passes contained by this manager.

void getAnalysisUsage(AnalysisUsage &Info) const override

Pass Manager itself does not invalidate any analysis info.

bool runOnFunction(Function &F) override

Execute all of the passes scheduled for execution.

std::string getNameStr() const

Returns the name of the Region.

void verifyRegion() const

Verify if the region is a correct region.

BlockT * getEntry() const

Get the entry BasicBlock of the Region.

void clearNodeCache()

Clear the Node Cache for all Regions.

RegionT * getTopLevelRegion() const

A pass that runs on each Region in a function.

void preparePassManager(PMStack &PMS) override

Check if available pass managers are suitable for this pass or not.

bool skipRegion(Region &R) const

Optional passes call this function to check whether the pass should be skipped.

void assignPassManager(PMStack &PMS, PassManagerType PMT=PMT_RegionPassManager) override

Assign pass manager to manage this pass.

Pass * createPrinterPass(raw_ostream &O, const std::string &Banner) const override

Get a pass to print the LLVM IR in the region.

StringRef - Represent a constant reference to a string, i.e.

The TimeRegion class is used as a helper class to call the startTimer() and stopTimer() methods of th...

This class implements an extremely fast bulk output stream that can only output to a stream.

raw_ostream & indent(unsigned NumSpaces)

indent - Insert 'NumSpaces' spaces.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

This is an optimization pass for GlobalISel generic memory operations.

PassManagerType

Different types of internal pass managers.

@ PMT_RegionPassManager

RGPassManager.

Timer * getPassTimer(Pass *)

Request the timer for this legacy-pass-manager's pass instance.

raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

bool isFunctionInPrintList(StringRef FunctionName)

raw_fd_ostream & errs()

This returns a reference to a raw_ostream for standard error.