LLVM 18.0.0git
LoopVersioningLICM.cpp
Go to the documentation of this file.
1//===- LoopVersioningLICM.cpp - LICM Loop Versioning ----------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// When alias analysis is uncertain about the aliasing between any two accesses,
10// it will return MayAlias. This uncertainty from alias analysis restricts LICM
11// from proceeding further. In cases where alias analysis is uncertain we might
12// use loop versioning as an alternative.
13//
14// Loop Versioning will create a version of the loop with aggressive aliasing
15// assumptions in addition to the original with conservative (default) aliasing
16// assumptions. The version of the loop making aggressive aliasing assumptions
17// will have all the memory accesses marked as no-alias. These two versions of
18// loop will be preceded by a memory runtime check. This runtime check consists
19// of bound checks for all unique memory accessed in loop, and it ensures the
20// lack of memory aliasing. The result of the runtime check determines which of
21// the loop versions is executed: If the runtime check detects any memory
22// aliasing, then the original loop is executed. Otherwise, the version with
23// aggressive aliasing assumptions is used.
24//
25// Following are the top level steps:
26//
27// a) Perform LoopVersioningLICM's feasibility check.
28// b) If loop is a candidate for versioning then create a memory bound check,
29// by considering all the memory accesses in loop body.
30// c) Clone original loop and set all memory accesses as no-alias in new loop.
31// d) Set original loop & versioned loop as a branch target of the runtime check
32// result.
33//
34// It transforms loop as shown below:
35//
36// +----------------+
37// |Runtime Memcheck|
38// +----------------+
39// |
40// +----------+----------------+----------+
41// | |
42// +---------+----------+ +-----------+----------+
43// |Orig Loop Preheader | |Cloned Loop Preheader |
44// +--------------------+ +----------------------+
45// | |
46// +--------------------+ +----------------------+
47// |Orig Loop Body | |Cloned Loop Body |
48// +--------------------+ +----------------------+
49// | |
50// +--------------------+ +----------------------+
51// |Orig Loop Exit Block| |Cloned Loop Exit Block|
52// +--------------------+ +-----------+----------+
53// | |
54// +----------+--------------+-----------+
55// |
56// +-----+----+
57// |Join Block|
58// +----------+
59//
60//===----------------------------------------------------------------------===//
61
64#include "llvm/ADT/StringRef.h"
73#include "llvm/IR/Dominators.h"
74#include "llvm/IR/Instruction.h"
76#include "llvm/IR/LLVMContext.h"
77#include "llvm/IR/MDBuilder.h"
78#include "llvm/IR/Metadata.h"
79#include "llvm/IR/Value.h"
82#include "llvm/Support/Debug.h"
87#include <cassert>
88#include <memory>
89
90using namespace llvm;
91
92#define DEBUG_TYPE "loop-versioning-licm"
93
94static const char *LICMVersioningMetaData = "llvm.loop.licm_versioning.disable";
95
96/// Threshold minimum allowed percentage for possible
97/// invariant instructions in a loop.
98static cl::opt<float>
99 LVInvarThreshold("licm-versioning-invariant-threshold",
100 cl::desc("LoopVersioningLICM's minimum allowed percentage"
101 "of possible invariant instructions per loop"),
102 cl::init(25), cl::Hidden);
103
104/// Threshold for maximum allowed loop nest/depth
106 "licm-versioning-max-depth-threshold",
107 cl::desc(
108 "LoopVersioningLICM's threshold for maximum allowed loop nest/depth"),
109 cl::init(2), cl::Hidden);
110
111namespace {
112
113struct LoopVersioningLICM {
114 // We don't explicitly pass in LoopAccessInfo to the constructor since the
115 // loop versioning might return early due to instructions that are not safe
116 // for versioning. By passing the proxy instead the construction of
117 // LoopAccessInfo will take place only when it's necessary.
118 LoopVersioningLICM(AliasAnalysis *AA, ScalarEvolution *SE,
121 Loop *CurLoop)
122 : AA(AA), SE(SE), LAIs(LAIs), LI(LI), CurLoop(CurLoop),
123 LoopDepthThreshold(LVLoopDepthThreshold),
124 InvariantThreshold(LVInvarThreshold), ORE(ORE) {}
125
126 bool run(DominatorTree *DT);
127
128private:
129 // Current AliasAnalysis information
130 AliasAnalysis *AA;
131
132 // Current ScalarEvolution
133 ScalarEvolution *SE;
134
135 // Current Loop's LoopAccessInfo
136 const LoopAccessInfo *LAI = nullptr;
137
138 // Proxy for retrieving LoopAccessInfo.
140
141 LoopInfo &LI;
142
143 // The current loop we are working on.
144 Loop *CurLoop;
145
146 // Maximum loop nest threshold
147 unsigned LoopDepthThreshold;
148
149 // Minimum invariant threshold
150 float InvariantThreshold;
151
152 // Counter to track num of load & store
153 unsigned LoadAndStoreCounter = 0;
154
155 // Counter to track num of invariant
156 unsigned InvariantCounter = 0;
157
158 // Read only loop marker.
159 bool IsReadOnlyLoop = true;
160
161 // OptimizationRemarkEmitter
163
164 bool isLegalForVersioning();
165 bool legalLoopStructure();
166 bool legalLoopInstructions();
167 bool legalLoopMemoryAccesses();
168 bool isLoopAlreadyVisited();
169 void setNoAliasToLoop(Loop *VerLoop);
170 bool instructionSafeForVersioning(Instruction *I);
171};
172
173} // end anonymous namespace
174
175/// Check loop structure and confirms it's good for LoopVersioningLICM.
176bool LoopVersioningLICM::legalLoopStructure() {
177 // Loop must be in loop simplify form.
178 if (!CurLoop->isLoopSimplifyForm()) {
179 LLVM_DEBUG(dbgs() << " loop is not in loop-simplify form.\n");
180 return false;
181 }
182 // Loop should be innermost loop, if not return false.
183 if (!CurLoop->getSubLoops().empty()) {
184 LLVM_DEBUG(dbgs() << " loop is not innermost\n");
185 return false;
186 }
187 // Loop should have a single backedge, if not return false.
188 if (CurLoop->getNumBackEdges() != 1) {
189 LLVM_DEBUG(dbgs() << " loop has multiple backedges\n");
190 return false;
191 }
192 // Loop must have a single exiting block, if not return false.
193 if (!CurLoop->getExitingBlock()) {
194 LLVM_DEBUG(dbgs() << " loop has multiple exiting block\n");
195 return false;
196 }
197 // We only handle bottom-tested loop, i.e. loop in which the condition is
198 // checked at the end of each iteration. With that we can assume that all
199 // instructions in the loop are executed the same number of times.
200 if (CurLoop->getExitingBlock() != CurLoop->getLoopLatch()) {
201 LLVM_DEBUG(dbgs() << " loop is not bottom tested\n");
202 return false;
203 }
204 // Parallel loops must not have aliasing loop-invariant memory accesses.
205 // Hence we don't need to version anything in this case.
206 if (CurLoop->isAnnotatedParallel()) {
207 LLVM_DEBUG(dbgs() << " Parallel loop is not worth versioning\n");
208 return false;
209 }
210 // Loop depth more then LoopDepthThreshold are not allowed
211 if (CurLoop->getLoopDepth() > LoopDepthThreshold) {
212 LLVM_DEBUG(dbgs() << " loop depth is more then threshold\n");
213 return false;
214 }
215 // We need to be able to compute the loop trip count in order
216 // to generate the bound checks.
217 const SCEV *ExitCount = SE->getBackedgeTakenCount(CurLoop);
218 if (isa<SCEVCouldNotCompute>(ExitCount)) {
219 LLVM_DEBUG(dbgs() << " loop does not has trip count\n");
220 return false;
221 }
222 return true;
223}
224
225/// Check memory accesses in loop and confirms it's good for
226/// LoopVersioningLICM.
227bool LoopVersioningLICM::legalLoopMemoryAccesses() {
228 // Loop over the body of this loop, construct AST.
229 BatchAAResults BAA(*AA);
230 AliasSetTracker AST(BAA);
231 for (auto *Block : CurLoop->getBlocks()) {
232 // Ignore blocks in subloops.
233 if (LI.getLoopFor(Block) == CurLoop)
234 AST.add(*Block);
235 }
236
237 // Memory check:
238 // Transform phase will generate a versioned loop and also a runtime check to
239 // ensure the pointers are independent and they don’t alias.
240 // In version variant of loop, alias meta data asserts that all access are
241 // mutually independent.
242 //
243 // Pointers aliasing in alias domain are avoided because with multiple
244 // aliasing domains we may not be able to hoist potential loop invariant
245 // access out of the loop.
246 //
247 // Iterate over alias tracker sets, and confirm AliasSets doesn't have any
248 // must alias set.
249 bool HasMayAlias = false;
250 bool TypeSafety = false;
251 bool HasMod = false;
252 for (const auto &I : AST) {
253 const AliasSet &AS = I;
254 // Skip Forward Alias Sets, as this should be ignored as part of
255 // the AliasSetTracker object.
256 if (AS.isForwardingAliasSet())
257 continue;
258 // With MustAlias its not worth adding runtime bound check.
259 if (AS.isMustAlias())
260 return false;
261 Value *SomePtr = AS.begin()->getValue();
262 bool TypeCheck = true;
263 // Check for Mod & MayAlias
264 HasMayAlias |= AS.isMayAlias();
265 HasMod |= AS.isMod();
266 for (const auto &A : AS) {
267 Value *Ptr = A.getValue();
268 // Alias tracker should have pointers of same data type.
269 TypeCheck = (TypeCheck && (SomePtr->getType() == Ptr->getType()));
270 }
271 // At least one alias tracker should have pointers of same data type.
272 TypeSafety |= TypeCheck;
273 }
274 // Ensure types should be of same type.
275 if (!TypeSafety) {
276 LLVM_DEBUG(dbgs() << " Alias tracker type safety failed!\n");
277 return false;
278 }
279 // Ensure loop body shouldn't be read only.
280 if (!HasMod) {
281 LLVM_DEBUG(dbgs() << " No memory modified in loop body\n");
282 return false;
283 }
284 // Make sure alias set has may alias case.
285 // If there no alias memory ambiguity, return false.
286 if (!HasMayAlias) {
287 LLVM_DEBUG(dbgs() << " No ambiguity in memory access.\n");
288 return false;
289 }
290 return true;
291}
292
293/// Check loop instructions safe for Loop versioning.
294/// It returns true if it's safe else returns false.
295/// Consider following:
296/// 1) Check all load store in loop body are non atomic & non volatile.
297/// 2) Check function call safety, by ensuring its not accessing memory.
298/// 3) Loop body shouldn't have any may throw instruction.
299/// 4) Loop body shouldn't have any convergent or noduplicate instructions.
300bool LoopVersioningLICM::instructionSafeForVersioning(Instruction *I) {
301 assert(I != nullptr && "Null instruction found!");
302 // Check function call safety
303 if (auto *Call = dyn_cast<CallBase>(I)) {
304 if (Call->isConvergent() || Call->cannotDuplicate()) {
305 LLVM_DEBUG(dbgs() << " Convergent call site found.\n");
306 return false;
307 }
308
309 if (!AA->doesNotAccessMemory(Call)) {
310 LLVM_DEBUG(dbgs() << " Unsafe call site found.\n");
311 return false;
312 }
313 }
314
315 // Avoid loops with possiblity of throw
316 if (I->mayThrow()) {
317 LLVM_DEBUG(dbgs() << " May throw instruction found in loop body\n");
318 return false;
319 }
320 // If current instruction is load instructions
321 // make sure it's a simple load (non atomic & non volatile)
322 if (I->mayReadFromMemory()) {
323 LoadInst *Ld = dyn_cast<LoadInst>(I);
324 if (!Ld || !Ld->isSimple()) {
325 LLVM_DEBUG(dbgs() << " Found a non-simple load.\n");
326 return false;
327 }
328 LoadAndStoreCounter++;
329 Value *Ptr = Ld->getPointerOperand();
330 // Check loop invariant.
331 if (SE->isLoopInvariant(SE->getSCEV(Ptr), CurLoop))
332 InvariantCounter++;
333 }
334 // If current instruction is store instruction
335 // make sure it's a simple store (non atomic & non volatile)
336 else if (I->mayWriteToMemory()) {
337 StoreInst *St = dyn_cast<StoreInst>(I);
338 if (!St || !St->isSimple()) {
339 LLVM_DEBUG(dbgs() << " Found a non-simple store.\n");
340 return false;
341 }
342 LoadAndStoreCounter++;
343 Value *Ptr = St->getPointerOperand();
344 // Check loop invariant.
345 if (SE->isLoopInvariant(SE->getSCEV(Ptr), CurLoop))
346 InvariantCounter++;
347
348 IsReadOnlyLoop = false;
349 }
350 return true;
351}
352
353/// Check loop instructions and confirms it's good for
354/// LoopVersioningLICM.
355bool LoopVersioningLICM::legalLoopInstructions() {
356 // Resetting counters.
357 LoadAndStoreCounter = 0;
358 InvariantCounter = 0;
359 IsReadOnlyLoop = true;
360 using namespace ore;
361 // Iterate over loop blocks and instructions of each block and check
362 // instruction safety.
363 for (auto *Block : CurLoop->getBlocks())
364 for (auto &Inst : *Block) {
365 // If instruction is unsafe just return false.
366 if (!instructionSafeForVersioning(&Inst)) {
367 ORE->emit([&]() {
368 return OptimizationRemarkMissed(DEBUG_TYPE, "IllegalLoopInst", &Inst)
369 << " Unsafe Loop Instruction";
370 });
371 return false;
372 }
373 }
374 // Get LoopAccessInfo from current loop via the proxy.
375 LAI = &LAIs.getInfo(*CurLoop);
376 // Check LoopAccessInfo for need of runtime check.
377 if (LAI->getRuntimePointerChecking()->getChecks().empty()) {
378 LLVM_DEBUG(dbgs() << " LAA: Runtime check not found !!\n");
379 return false;
380 }
381 // Number of runtime-checks should be less then RuntimeMemoryCheckThreshold
382 if (LAI->getNumRuntimePointerChecks() >
385 dbgs() << " LAA: Runtime checks are more than threshold !!\n");
386 ORE->emit([&]() {
387 return OptimizationRemarkMissed(DEBUG_TYPE, "RuntimeCheck",
388 CurLoop->getStartLoc(),
389 CurLoop->getHeader())
390 << "Number of runtime checks "
391 << NV("RuntimeChecks", LAI->getNumRuntimePointerChecks())
392 << " exceeds threshold "
394 });
395 return false;
396 }
397 // Loop should have at least one invariant load or store instruction.
398 if (!InvariantCounter) {
399 LLVM_DEBUG(dbgs() << " Invariant not found !!\n");
400 return false;
401 }
402 // Read only loop not allowed.
403 if (IsReadOnlyLoop) {
404 LLVM_DEBUG(dbgs() << " Found a read-only loop!\n");
405 return false;
406 }
407 // Profitablity check:
408 // Check invariant threshold, should be in limit.
409 if (InvariantCounter * 100 < InvariantThreshold * LoadAndStoreCounter) {
411 dbgs()
412 << " Invariant load & store are less then defined threshold\n");
413 LLVM_DEBUG(dbgs() << " Invariant loads & stores: "
414 << ((InvariantCounter * 100) / LoadAndStoreCounter)
415 << "%\n");
416 LLVM_DEBUG(dbgs() << " Invariant loads & store threshold: "
417 << InvariantThreshold << "%\n");
418 ORE->emit([&]() {
419 return OptimizationRemarkMissed(DEBUG_TYPE, "InvariantThreshold",
420 CurLoop->getStartLoc(),
421 CurLoop->getHeader())
422 << "Invariant load & store "
423 << NV("LoadAndStoreCounter",
424 ((InvariantCounter * 100) / LoadAndStoreCounter))
425 << " are less then defined threshold "
426 << NV("Threshold", InvariantThreshold);
427 });
428 return false;
429 }
430 return true;
431}
432
433/// It checks loop is already visited or not.
434/// check loop meta data, if loop revisited return true
435/// else false.
436bool LoopVersioningLICM::isLoopAlreadyVisited() {
437 // Check LoopVersioningLICM metadata into loop
439 return true;
440 }
441 return false;
442}
443
444/// Checks legality for LoopVersioningLICM by considering following:
445/// a) loop structure legality b) loop instruction legality
446/// c) loop memory access legality.
447/// Return true if legal else returns false.
448bool LoopVersioningLICM::isLegalForVersioning() {
449 using namespace ore;
450 LLVM_DEBUG(dbgs() << "Loop: " << *CurLoop);
451 // Make sure not re-visiting same loop again.
452 if (isLoopAlreadyVisited()) {
454 dbgs() << " Revisiting loop in LoopVersioningLICM not allowed.\n\n");
455 return false;
456 }
457 // Check loop structure leagality.
458 if (!legalLoopStructure()) {
460 dbgs() << " Loop structure not suitable for LoopVersioningLICM\n\n");
461 ORE->emit([&]() {
462 return OptimizationRemarkMissed(DEBUG_TYPE, "IllegalLoopStruct",
463 CurLoop->getStartLoc(),
464 CurLoop->getHeader())
465 << " Unsafe Loop structure";
466 });
467 return false;
468 }
469 // Check loop instruction leagality.
470 if (!legalLoopInstructions()) {
472 dbgs()
473 << " Loop instructions not suitable for LoopVersioningLICM\n\n");
474 return false;
475 }
476 // Check loop memory access leagality.
477 if (!legalLoopMemoryAccesses()) {
479 dbgs()
480 << " Loop memory access not suitable for LoopVersioningLICM\n\n");
481 ORE->emit([&]() {
482 return OptimizationRemarkMissed(DEBUG_TYPE, "IllegalLoopMemoryAccess",
483 CurLoop->getStartLoc(),
484 CurLoop->getHeader())
485 << " Unsafe Loop memory access";
486 });
487 return false;
488 }
489 // Loop versioning is feasible, return true.
490 LLVM_DEBUG(dbgs() << " Loop Versioning found to be beneficial\n\n");
491 ORE->emit([&]() {
492 return OptimizationRemark(DEBUG_TYPE, "IsLegalForVersioning",
493 CurLoop->getStartLoc(), CurLoop->getHeader())
494 << " Versioned loop for LICM."
495 << " Number of runtime checks we had to insert "
496 << NV("RuntimeChecks", LAI->getNumRuntimePointerChecks());
497 });
498 return true;
499}
500
501/// Update loop with aggressive aliasing assumptions.
502/// It marks no-alias to any pairs of memory operations by assuming
503/// loop should not have any must-alias memory accesses pairs.
504/// During LoopVersioningLICM legality we ignore loops having must
505/// aliasing memory accesses.
506void LoopVersioningLICM::setNoAliasToLoop(Loop *VerLoop) {
507 // Get latch terminator instruction.
508 Instruction *I = VerLoop->getLoopLatch()->getTerminator();
509 // Create alias scope domain.
510 MDBuilder MDB(I->getContext());
511 MDNode *NewDomain = MDB.createAnonymousAliasScopeDomain("LVDomain");
512 StringRef Name = "LVAliasScope";
513 MDNode *NewScope = MDB.createAnonymousAliasScope(NewDomain, Name);
514 SmallVector<Metadata *, 4> Scopes{NewScope}, NoAliases{NewScope};
515 // Iterate over each instruction of loop.
516 // set no-alias for all load & store instructions.
517 for (auto *Block : CurLoop->getBlocks()) {
518 for (auto &Inst : *Block) {
519 // Only interested in instruction that may modify or read memory.
520 if (!Inst.mayReadFromMemory() && !Inst.mayWriteToMemory())
521 continue;
522 // Set no-alias for current instruction.
523 Inst.setMetadata(
524 LLVMContext::MD_noalias,
525 MDNode::concatenate(Inst.getMetadata(LLVMContext::MD_noalias),
526 MDNode::get(Inst.getContext(), NoAliases)));
527 // set alias-scope for current instruction.
528 Inst.setMetadata(
529 LLVMContext::MD_alias_scope,
530 MDNode::concatenate(Inst.getMetadata(LLVMContext::MD_alias_scope),
531 MDNode::get(Inst.getContext(), Scopes)));
532 }
533 }
534}
535
536bool LoopVersioningLICM::run(DominatorTree *DT) {
537 // Do not do the transformation if disabled by metadata.
539 return false;
540
541 bool Changed = false;
542
543 // Check feasiblity of LoopVersioningLICM.
544 // If versioning found to be feasible and beneficial then proceed
545 // else simply return, by cleaning up memory.
546 if (isLegalForVersioning()) {
547 // Do loop versioning.
548 // Create memcheck for memory accessed inside loop.
549 // Clone original loop, and set blocks properly.
550 LoopVersioning LVer(*LAI, LAI->getRuntimePointerChecking()->getChecks(),
551 CurLoop, &LI, DT, SE);
552 LVer.versionLoop();
553 // Set Loop Versioning metaData for original loop.
554 addStringMetadataToLoop(LVer.getNonVersionedLoop(), LICMVersioningMetaData);
555 // Set Loop Versioning metaData for version loop.
556 addStringMetadataToLoop(LVer.getVersionedLoop(), LICMVersioningMetaData);
557 // Set "llvm.mem.parallel_loop_access" metaData to versioned loop.
558 // FIXME: "llvm.mem.parallel_loop_access" annotates memory access
559 // instructions, not loops.
560 addStringMetadataToLoop(LVer.getVersionedLoop(),
561 "llvm.mem.parallel_loop_access");
562 // Update version loop with aggressive aliasing assumption.
563 setNoAliasToLoop(LVer.getVersionedLoop());
564 Changed = true;
565 }
566 return Changed;
567}
568
569namespace llvm {
570
573 LPMUpdater &U) {
574 AliasAnalysis *AA = &LAR.AA;
575 ScalarEvolution *SE = &LAR.SE;
576 DominatorTree *DT = &LAR.DT;
577 const Function *F = L.getHeader()->getParent();
579
580 LoopAccessInfoManager LAIs(*SE, *AA, *DT, LAR.LI, nullptr);
581 if (!LoopVersioningLICM(AA, SE, &ORE, LAIs, LAR.LI, &L).run(DT))
582 return PreservedAnalyses::all();
584}
585} // namespace llvm
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static cl::opt< bool > NoAliases("csky-no-aliases", cl::desc("Disable the emission of assembler pseudo instructions"), cl::init(false), cl::Hidden)
#define LLVM_DEBUG(X)
Definition: Debug.h:101
std::string Name
This is the interface for a simple mod/ref and alias analysis over globals.
static const char * LICMVersioningMetaData
static cl::opt< unsigned > LVLoopDepthThreshold("licm-versioning-max-depth-threshold", cl::desc("LoopVersioningLICM's threshold for maximum allowed loop nest/depth"), cl::init(2), cl::Hidden)
Threshold for maximum allowed loop nest/depth.
static cl::opt< float > LVInvarThreshold("licm-versioning-invariant-threshold", cl::desc("LoopVersioningLICM's minimum allowed percentage" "of possible invariant instructions per loop"), cl::init(25), cl::Hidden)
Threshold minimum allowed percentage for possible invariant instructions in a loop.
#define DEBUG_TYPE
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
This file contains the declarations for metadata subclasses.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
iterator begin() const
bool isMayAlias() const
bool isForwardingAliasSet() const
Return true if this alias set should be ignored as part of the AliasSetTracker object.
bool isMustAlias() const
bool isMod() const
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:620
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.h:127
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
An instruction for reading from memory.
Definition: Instructions.h:177
Value * getPointerOperand()
Definition: Instructions.h:264
bool isSimple() const
Definition: Instructions.h:256
Drive the analysis of memory accesses in the loop.
BlockT * getLoopLatch() const
If there is a single latch block for this loop, return it.
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &LAR, LPMUpdater &U)
This class emits a version of the loop where run-time checks ensure that may-alias pointers can't ove...
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:47
Metadata node.
Definition: Metadata.h:950
static MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
Definition: Metadata.cpp:1007
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1416
The optimization diagnostic interface.
Diagnostic information for missed-optimization remarks.
Diagnostic information for applied optimization remarks.
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
This class represents an analyzed expression in the program.
The main scalar evolution driver.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
An instruction for storing to memory.
Definition: Instructions.h:301
bool isSimple() const
Definition: Instructions.h:382
Value * getPointerOperand()
Definition: Instructions.h:393
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
LLVM Value Representation.
Definition: Value.h:74
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:445
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
DiagnosticInfoOptimizationBase::Argument NV
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::optional< const MDOperand * > findStringMetadataForLoop(const Loop *TheLoop, StringRef Name)
Find string metadata for loop.
Definition: LoopInfo.cpp:1052
void addStringMetadataToLoop(Loop *TheLoop, const char *MDString, unsigned V=0)
Set input string into loop metadata by keeping other values intact.
Definition: LoopUtils.cpp:214
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
TransformationMode hasLICMVersioningTransformation(const Loop *L)
Definition: LoopUtils.cpp:437
@ TM_Disable
The transformation should not be applied.
Definition: LoopUtils.h:284
PreservedAnalyses getLoopPassPreservedAnalyses()
Returns the minimum set of Analyses that all loop passes must preserve.
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
static unsigned RuntimeMemoryCheckThreshold
\When performing memory disambiguation checks at runtime do not make more than this number of compari...