aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorBryce Wilson <bryce@brycemw.ca>2022-01-14 14:42:53 -0800
committerBryce Wilson <bryce@brycemw.ca>2022-01-14 14:42:53 -0800
commitdd13744bfb0a85851dbd554138e25767bb0f35b6 (patch)
tree086d72beb301d9e03216c1290102a936bf078c9b /llvm/lib/Analysis/BasicAliasAnalysis.cpp
parentdc6404615d56cc620541f109feb35833211c3e88 (diff)
downloadllvm-dd13744bfb0a85851dbd554138e25767bb0f35b6.zip
llvm-dd13744bfb0a85851dbd554138e25767bb0f35b6.tar.gz
llvm-dd13744bfb0a85851dbd554138e25767bb0f35b6.tar.bz2
Revert "[BasicAliasAnalysis] Remove isMallocOrCallocLikeFn"
This reverts commit 1f2cfc4fdc1eefb2c5f562c77a5fe7e916bbf670.
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/BasicAliasAnalysis.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 9485565..fa9ccb0 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -996,6 +996,20 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
}
}
+ // If the call is malloc/calloc like, we can assume that it doesn't
+ // modify any IR visible value. This is only valid because we assume these
+ // routines do not read values visible in the IR. TODO: Consider special
+ // casing realloc and strdup routines which access only their arguments as
+ // well. Or alternatively, replace all of this with inaccessiblememonly once
+ // that's implemented fully.
+ if (isMallocOrCallocLikeFn(Call, &TLI)) {
+ // Be conservative if the accessed pointer may alias the allocation -
+ // fallback to the generic handling below.
+ if (getBestAAResults().alias(MemoryLocation::getBeforeOrAfter(Call), Loc,
+ AAQI) == AliasResult::NoAlias)
+ return ModRefInfo::NoModRef;
+ }
+
// The semantics of memcpy intrinsics either exactly overlap or do not
// overlap, i.e., source and destination of any given memcpy are either
// no-alias or must-alias.