diff options
| author | Hal Finkel <hfinkel@anl.gov> | 2014-07-24 12:16:19 +0000 |
|---|---|---|
| committer | Hal Finkel <hfinkel@anl.gov> | 2014-07-24 12:16:19 +0000 |
| commit | cc39b675308922229f7e16ceb47e8d9b5b2e8dcd (patch) | |
| tree | 8f00abe761e89b654d46a79dd14dcd45a3d27777 /llvm/lib/Transforms/Scalar/LICM.cpp | |
| parent | 545ff90d47c241e5dc6869be9377a75f718aa4c1 (diff) | |
| download | bcm5719-llvm-cc39b675308922229f7e16ceb47e8d9b5b2e8dcd.tar.gz bcm5719-llvm-cc39b675308922229f7e16ceb47e8d9b5b2e8dcd.zip | |
AA metadata refactoring (introduce AAMDNodes)
In order to enable the preservation of noalias function parameter information
after inlining, and the representation of block-level __restrict__ pointer
information (etc.), additional kinds of aliasing metadata will be introduced.
This metadata needs to be carried around in AliasAnalysis::Location objects
(and MMOs at the SDAG level), and so we need to generalize the current scheme
(which is hard-coded to just one TBAA MDNode*).
This commit introduces only the necessary refactoring to allow for the
introduction of other aliasing metadata types, but does not actually introduce
any (that will come in a follow-up commit). What it does introduce is a new
AAMDNodes structure to hold all of the aliasing metadata nodes associated with
a particular memory-accessing instruction, and uses that structure instead of
the raw MDNode* in AliasAnalysis::Location, etc.
No functionality change intended.
llvm-svn: 213859
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LICM.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LICM.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index abcceb20050..1673c0f40ff 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -180,9 +180,9 @@ namespace { /// store into the memory location pointed to by V. /// bool pointerInvalidatedByLoop(Value *V, uint64_t Size, - const MDNode *TBAAInfo) { + const AAMDNodes &AAInfo) { // Check to see if any of the basic blocks in CurLoop invalidate *V. - return CurAST->getAliasSetForPointer(V, Size, TBAAInfo).isMod(); + return CurAST->getAliasSetForPointer(V, Size, AAInfo).isMod(); } bool canSinkOrHoistInst(Instruction &I); @@ -448,8 +448,11 @@ bool LICM::canSinkOrHoistInst(Instruction &I) { uint64_t Size = 0; if (LI->getType()->isSized()) Size = AA->getTypeStoreSize(LI->getType()); - return !pointerInvalidatedByLoop(LI->getOperand(0), Size, - LI->getMetadata(LLVMContext::MD_tbaa)); + + AAMDNodes AAInfo; + LI->getAAMetadata(AAInfo); + + return !pointerInvalidatedByLoop(LI->getOperand(0), Size, AAInfo); } else if (CallInst *CI = dyn_cast<CallInst>(&I)) { // Don't sink or hoist dbg info; it's legal, but not useful. if (isa<DbgInfoIntrinsic>(I)) @@ -690,7 +693,7 @@ namespace { LoopInfo &LI; DebugLoc DL; int Alignment; - MDNode *TBAATag; + AAMDNodes AATags; Value *maybeInsertLCSSAPHI(Value *V, BasicBlock *BB) const { if (Instruction *I = dyn_cast<Instruction>(V)) @@ -714,10 +717,10 @@ namespace { SmallVectorImpl<BasicBlock *> &LEB, SmallVectorImpl<Instruction *> &LIP, PredIteratorCache &PIC, AliasSetTracker &ast, LoopInfo &li, DebugLoc dl, int alignment, - MDNode *TBAATag) + const AAMDNodes &AATags) : LoadAndStorePromoter(Insts, S), SomePtr(SP), PointerMustAliases(PMA), LoopExitBlocks(LEB), LoopInsertPts(LIP), PredCache(PIC), AST(ast), - LI(li), DL(dl), Alignment(alignment), TBAATag(TBAATag) {} + LI(li), DL(dl), Alignment(alignment), AATags(AATags) {} bool isInstInList(Instruction *I, const SmallVectorImpl<Instruction*> &) const override { @@ -743,7 +746,7 @@ namespace { StoreInst *NewSI = new StoreInst(LiveInValue, Ptr, InsertPos); NewSI->setAlignment(Alignment); NewSI->setDebugLoc(DL); - if (TBAATag) NewSI->setMetadata(LLVMContext::MD_tbaa, TBAATag); + if (AATags) NewSI->setAAMetadata(AATags); } } @@ -798,11 +801,11 @@ void LICM::PromoteAliasSet(AliasSet &AS, // We start with an alignment of one and try to find instructions that allow // us to prove better alignment. unsigned Alignment = 1; - MDNode *TBAATag = nullptr; + AAMDNodes AATags; // Check that all of the pointers in the alias set have the same type. We // cannot (yet) promote a memory location that is loaded and stored in - // different sizes. While we are at it, collect alignment and TBAA info. + // different sizes. While we are at it, collect alignment and AA info. for (AliasSet::iterator ASI = AS.begin(), E = AS.end(); ASI != E; ++ASI) { Value *ASIV = ASI->getValue(); PointerMustAliases.insert(ASIV); @@ -855,13 +858,12 @@ void LICM::PromoteAliasSet(AliasSet &AS, } else return; // Not a load or store. - // Merge the TBAA tags. + // Merge the AA tags. if (LoopUses.empty()) { - // On the first load/store, just take its TBAA tag. - TBAATag = UI->getMetadata(LLVMContext::MD_tbaa); - } else if (TBAATag) { - TBAATag = MDNode::getMostGenericTBAA(TBAATag, - UI->getMetadata(LLVMContext::MD_tbaa)); + // On the first load/store, just take its AA tags. + UI->getAAMetadata(AATags); + } else if (AATags) { + UI->getAAMetadata(AATags, /* Merge = */ true); } LoopUses.push_back(UI); @@ -896,7 +898,7 @@ void LICM::PromoteAliasSet(AliasSet &AS, SmallVector<PHINode*, 16> NewPHIs; SSAUpdater SSA(&NewPHIs); LoopPromoter Promoter(SomePtr, LoopUses, SSA, PointerMustAliases, ExitBlocks, - InsertPts, PIC, *CurAST, *LI, DL, Alignment, TBAATag); + InsertPts, PIC, *CurAST, *LI, DL, Alignment, AATags); // Set up the preheader to have a definition of the value. It is the live-out // value from the preheader that uses in the loop will use. @@ -905,7 +907,7 @@ void LICM::PromoteAliasSet(AliasSet &AS, Preheader->getTerminator()); PreheaderLoad->setAlignment(Alignment); PreheaderLoad->setDebugLoc(DL); - if (TBAATag) PreheaderLoad->setMetadata(LLVMContext::MD_tbaa, TBAATag); + if (AATags) PreheaderLoad->setAAMetadata(AATags); SSA.AddAvailableValue(Preheader, PreheaderLoad); // Rewrite all the loads in the loop and remember all the definitions from |

