@@ -164,7 +164,6 @@ struct LoopVersioningLICM {
164164 bool legalLoopInstructions ();
165165 bool legalLoopMemoryAccesses ();
166166 bool isLoopAlreadyVisited ();
167- void setNoAliasToLoop (Loop *VerLoop);
168167 bool instructionSafeForVersioning (Instruction *I);
169168};
170169
@@ -508,44 +507,6 @@ bool LoopVersioningLICM::isLegalForVersioning() {
508507 return true ;
509508}
510509
511- // / Update loop with aggressive aliasing assumptions.
512- // / It marks no-alias to any pairs of memory operations by assuming
513- // / loop should not have any must-alias memory accesses pairs.
514- // / During LoopVersioningLICM legality we ignore loops having must
515- // / aliasing memory accesses.
516- void LoopVersioningLICM::setNoAliasToLoop (Loop *VerLoop) {
517- // Get latch terminator instruction.
518- Instruction *I = VerLoop->getLoopLatch ()->getTerminator ();
519- // Create alias scope domain.
520- MDBuilder MDB (I->getContext ());
521- MDNode *NewDomain = MDB.createAnonymousAliasScopeDomain (" LVDomain" );
522- StringRef Name = " LVAliasScope" ;
523- MDNode *NewScope = MDB.createAnonymousAliasScope (NewDomain, Name);
524- SmallVector<Metadata *, 4 > Scopes{NewScope}, NoAliases{NewScope};
525- auto &Pointers = LAI->getRuntimePointerChecking ()->Pointers ;
526-
527- // Iterate over each instruction of loop.
528- // set no-alias for all load & store instructions.
529- for (auto *Block : CurLoop->getBlocks ()) {
530- for (auto &Inst : *Block) {
531- // We can only add noalias to pointers that we've inserted checks for
532- Value *V = getLoadStorePointerOperand (&Inst);
533- if (!V || !any_of (Pointers, [&](auto &P) { return P.PointerValue == V; }))
534- continue ;
535- // Set no-alias for current instruction.
536- Inst.setMetadata (
537- LLVMContext::MD_noalias,
538- MDNode::concatenate (Inst.getMetadata (LLVMContext::MD_noalias),
539- MDNode::get (Inst.getContext (), NoAliases)));
540- // set alias-scope for current instruction.
541- Inst.setMetadata (
542- LLVMContext::MD_alias_scope,
543- MDNode::concatenate (Inst.getMetadata (LLVMContext::MD_alias_scope),
544- MDNode::get (Inst.getContext (), Scopes)));
545- }
546- }
547- }
548-
549510bool LoopVersioningLICM::run (DominatorTree *DT) {
550511 // Do not do the transformation if disabled by metadata.
551512 if (hasLICMVersioningTransformation (CurLoop) & TM_Disable)
@@ -573,7 +534,7 @@ bool LoopVersioningLICM::run(DominatorTree *DT) {
573534 addStringMetadataToLoop (LVer.getVersionedLoop (),
574535 " llvm.mem.parallel_loop_access" );
575536 // Update version loop with aggressive aliasing assumption.
576- setNoAliasToLoop ( LVer.getVersionedLoop () );
537+ LVer.annotateLoopWithNoAlias ( );
577538 Changed = true ;
578539 }
579540 return Changed;
0 commit comments