diff options
author | Jeroen Dobbelaere <jeroen.dobbelaere@synopsys.com> | 2021-01-24 13:50:25 +0100 |
---|---|---|
committer | Jeroen Dobbelaere <jeroen.dobbelaere@synopsys.com> | 2021-01-24 13:53:13 +0100 |
commit | 659c7bcde62e96c84f157b1d4ac4f320c56089a1 (patch) | |
tree | 9b91a78c9b61d9d9d1fc8907b93b5479034299ac /llvm/lib/Transforms/Utils/CloneFunction.cpp | |
parent | 774629641bf32503353a179e98aaa3ef055d6870 (diff) | |
download | llvm-659c7bcde62e96c84f157b1d4ac4f320c56089a1.zip llvm-659c7bcde62e96c84f157b1d4ac4f320c56089a1.tar.gz llvm-659c7bcde62e96c84f157b1d4ac4f320c56089a1.tar.bz2 |
[LoopRotate] Use llvm.experimental.noalias.scope.decl for duplicating noalias metadata as needed
Similar to D92887, LoopRotation also needs duplicate the noalias scopes when rotating a `@llvm.experimental.noalias.scope.decl` across a block boundary.
This is based on the version from the Full Restrict paches (D68511).
The problem it fixes also showed up in Transforms/Coroutines/ex5.ll after D93040 (when enabling strict checking with -verify-noalias-scope-decl-dom).
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D94306
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneFunction.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index 3ff1e59..ac474fb 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -968,6 +968,28 @@ void llvm::cloneAndAdaptNoAliasScopes( adaptNoAliasScopes(&I, ClonedScopes, ClonedMVScopes, Context); } +void llvm::cloneAndAdaptNoAliasScopes( + ArrayRef<MetadataAsValue *> NoAliasDeclScopes, Instruction *IStart, + Instruction *IEnd, LLVMContext &Context, StringRef Ext) { + if (NoAliasDeclScopes.empty()) + return; + + DenseMap<MDNode *, MDNode *> ClonedScopes; + DenseMap<MetadataAsValue *, MetadataAsValue *> ClonedMVScopes; + LLVM_DEBUG(dbgs() << "cloneAndAdaptNoAliasScopes: cloning " + << NoAliasDeclScopes.size() << " node(s)\n"); + + cloneNoAliasScopes(NoAliasDeclScopes, ClonedScopes, ClonedMVScopes, Ext, + Context); + // Identify instructions using metadata that needs adaptation + assert(IStart->getParent() == IEnd->getParent() && "different basic block ?"); + auto ItStart = IStart->getIterator(); + auto ItEnd = IEnd->getIterator(); + ++ItEnd; // IEnd is included, increment ItEnd to get the end of the range + for (auto &I : llvm::make_range(ItStart, ItEnd)) + adaptNoAliasScopes(&I, ClonedScopes, ClonedMVScopes, Context); +} + void llvm::identifyNoAliasScopesToClone( ArrayRef<BasicBlock *> BBs, SmallVectorImpl<MetadataAsValue *> &NoAliasDeclScopes) { |