[llvm] 1f2cfc4 - [BasicAliasAnalysis] Remove isMallocOrCallocLikeFn
Bryce Wilson via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 14 12:22:12 PST 2022
Author: Bryce Wilson
Date: 2022-01-14T12:22:01-08:00
New Revision: 1f2cfc4fdc1eefb2c5f562c77a5fe7e916bbf670
URL: https://github.com/llvm/llvm-project/commit/1f2cfc4fdc1eefb2c5f562c77a5fe7e916bbf670
DIFF: https://github.com/llvm/llvm-project/commit/1f2cfc4fdc1eefb2c5f562c77a5fe7e916bbf670.diff
LOG: [BasicAliasAnalysis] Remove isMallocOrCallocLikeFn
Allocation functions should be marked with onlyAccessesInaccessibleMemory (when that is correct for the given function) which is checked elsewhere so this check is no longer needed.
Differential Revision: https://reviews.llvm.org/D117180
Added:
Modified:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Transforms/GVN/nonescaping-malloc.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index fa9ccb095a21d..9485565bb57b7 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -996,20 +996,6 @@ 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.
diff --git a/llvm/test/Transforms/GVN/nonescaping-malloc.ll b/llvm/test/Transforms/GVN/nonescaping-malloc.ll
index fd61835e14a40..9eaf54c7a3d6c 100644
--- a/llvm/test/Transforms/GVN/nonescaping-malloc.ll
+++ b/llvm/test/Transforms/GVN/nonescaping-malloc.ll
@@ -35,7 +35,7 @@ entry:
declare i64 @strlen(i8* nocapture) nounwind readonly
-declare noalias i8* @malloc(i64) nounwind
+declare noalias i8* @malloc(i64) nounwind inaccessiblememonly
declare i32 @_ZN4llvm13StringMapImpl15LookupBucketForENS_9StringRefE(%"struct.llvm::StringMapImpl"*, i64, i64)
@@ -66,7 +66,7 @@ bb4.i: ; preds = %entry
%tmp4.i.i = sub i32 %tmp1.i.i, %tmp3.i.i
%tmp5.i.i = add i32 %tmp4.i.i, 17
%tmp8.i.i = zext i32 %tmp5.i.i to i64
- %tmp.i20.i.i = tail call noalias i8* @malloc(i64 %tmp8.i.i) nounwind
+ %tmp.i20.i.i = tail call noalias i8* @malloc(i64 %tmp8.i.i) nounwind inaccessiblememonly
%tmp10.i.i = bitcast i8* %tmp.i20.i.i to %"struct.llvm::StringMapEntry<void*>"*
%tmp12.i.i = icmp eq i8* %tmp.i20.i.i, null
br i1 %tmp12.i.i, label %_ZN4llvm14StringMapEntryIPvE6CreateINS_15MallocAllocatorES1_EEPS2_PKcS7_RT_T0_.exit.i, label %bb.i.i
More information about the llvm-commits
mailing list