summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2014-08-14 16:44:03 +0000
committerHal Finkel <hfinkel@anl.gov>2014-08-14 16:44:03 +0000
commitd2dee16c27c13d20d1dc97db308fb9145a3e9607 (patch)
treeb530291f1217d11dde2527fbb9c670277cb86c7b /llvm/lib/Transforms/Utils
parent6cd101a32514a5ebd0900a637ee2762adda740f9 (diff)
downloadbcm5719-llvm-d2dee16c27c13d20d1dc97db308fb9145a3e9607.tar.gz
bcm5719-llvm-d2dee16c27c13d20d1dc97db308fb9145a3e9607.zip
Add noalias metadata for general calls (not just memory intrinsics) during inlining
When preserving noalias function parameter attributes by adding noalias metadata in the inliner, we should do this for general function calls (not just memory intrinsics). The logic is very similar to what already existed (except that we want to add this metadata even for functions taking no relevant parameters). This metadata can be used by ModRef queries in the caller after inlining. This addresses the first part of PR20500. Adding noalias metadata during inlining is still turned off by default. llvm-svn: 215657
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 4fa27673ca7..f6289b5c891 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -449,17 +449,28 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
PtrArgs.push_back(CXI->getPointerOperand());
else if (const AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(I))
PtrArgs.push_back(RMWI->getPointerOperand());
- else if (const MemIntrinsic *MI = dyn_cast<MemIntrinsic>(I)) {
- PtrArgs.push_back(MI->getRawDest());
- if (const MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI))
- PtrArgs.push_back(MTI->getRawSource());
+ else if (ImmutableCallSite ICS = ImmutableCallSite(I)) {
+ // If we know that the call does not access memory, then we'll still
+ // know that about the inlined clone of this call site, and we don't
+ // need to add metadata.
+ if (ICS.doesNotAccessMemory())
+ continue;
+
+ for (ImmutableCallSite::arg_iterator AI = ICS.arg_begin(),
+ AE = ICS.arg_end(); AI != AE; ++AI)
+ // We need to check the underlying objects of all arguments, not just
+ // the pointer arguments, because we might be passing pointers as
+ // integers, etc.
+ // FIXME: If we know that the call only accesses pointer arguments,
+ // then we only need to check the pointer arguments.
+ PtrArgs.push_back(*AI);
}
// If we found no pointers, then this instruction is not suitable for
// pairing with an instruction to receive aliasing metadata.
- // Simplification during cloning could make this happen, and skip these
- // cases for now.
- if (PtrArgs.empty())
+ // However, if this is a call, this we might just alias with none of the
+ // noalias arguments.
+ if (PtrArgs.empty() && !isa<CallInst>(I) && !isa<InvokeInst>(I))
continue;
// It is possible that there is only one underlying object, but you
OpenPOWER on IntegriCloud