diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -996,20 +996,6 @@ } } - // 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 --- a/llvm/test/Transforms/GVN/nonescaping-malloc.ll +++ b/llvm/test/Transforms/GVN/nonescaping-malloc.ll @@ -35,7 +35,7 @@ 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 @@ %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"* %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