aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2014-09-01 09:01:39 +0000
committerHal Finkel <hfinkel@anl.gov>2014-09-01 09:01:39 +0000
commit0c083024f0fdaa958ec8b1a8cd5b27dc53bf68af (patch)
treeb8e70c0bfaf8bc42943206a14bc7dd4491303f6e /llvm/lib/Transforms/Utils/InlineFunction.cpp
parentfc243d54d2048bec081a6c0257288306960f3e49 (diff)
downloadllvm-0c083024f0fdaa958ec8b1a8cd5b27dc53bf68af.zip
llvm-0c083024f0fdaa958ec8b1a8cd5b27dc53bf68af.tar.gz
llvm-0c083024f0fdaa958ec8b1a8cd5b27dc53bf68af.tar.bz2
Feed AA to the inliner and use AA->getModRefBehavior in AddAliasScopeMetadata
This feeds AA through the IFI structure into the inliner so that AddAliasScopeMetadata can use AA->getModRefBehavior to figure out which functions only access their arguments (instead of just hard-coding some knowledge of memory intrinsics). Most of the information is only available from BasicAA; this is important for preserving alias scoping information for target-specific intrinsics when doing the noalias parameter attribute to metadata conversion. llvm-svn: 216866
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index d885541..f2930dc 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -394,7 +394,7 @@ static void CloneAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap) {
/// parameters with noalias metadata specifying the new scope, and tag all
/// non-derived loads, stores and memory intrinsics with the new alias scopes.
static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
- const DataLayout *DL) {
+ const DataLayout *DL, AliasAnalysis *AA) {
if (!EnableNoAliasConversion)
return;
@@ -458,6 +458,7 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
if (!NI)
continue;
+ bool IsArgMemOnlyCall = false, IsFuncCall = false;
SmallVector<const Value *, 2> PtrArgs;
if (const LoadInst *LI = dyn_cast<LoadInst>(I))
@@ -477,23 +478,28 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
if (ICS.doesNotAccessMemory())
continue;
+ IsFuncCall = true;
+ if (AA) {
+ AliasAnalysis::ModRefBehavior MRB = AA->getModRefBehavior(ICS);
+ if (MRB == AliasAnalysis::OnlyAccessesArgumentPointees ||
+ MRB == AliasAnalysis::OnlyReadsArgumentPointees)
+ IsArgMemOnlyCall = true;
+ }
+
for (ImmutableCallSite::arg_iterator AI = ICS.arg_begin(),
- AE = ICS.arg_end(); AI != AE; ++AI)
+ 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,
+ // However, if we know that the call only accesses pointer arguments,
// then we only need to check the pointer arguments.
+ if (IsArgMemOnlyCall && !(*AI)->getType()->isPointerTy())
+ continue;
+
PtrArgs.push_back(*AI);
+ }
}
- bool IsFuncCall = isa<CallInst>(I) || isa<InvokeInst>(I);
- // FIXME: We should have a way to access the
- // IntrReadArgMem/IntrReadWriteArgMem properties of intrinsics, and we
- // should have a way to determine that for regular functions too. For
- // now, just do this for the memory intrinsics we understand.
- bool IsArgMemOnlyCall = isa<MemIntrinsic>(I);
-
// If we found no pointers, then this instruction is not suitable for
// pairing with an instruction to receive aliasing metadata.
// However, if this is a call, this we might just alias with none of the
@@ -975,7 +981,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
CloneAliasScopeMetadata(CS, VMap);
// Add noalias metadata if necessary.
- AddAliasScopeMetadata(CS, VMap, IFI.DL);
+ AddAliasScopeMetadata(CS, VMap, IFI.DL, IFI.AA);
}
// If there are any alloca instructions in the block that used to be the entry