Index: llvm/include/llvm/Analysis/MemoryBuiltins.h
===================================================================
--- llvm/include/llvm/Analysis/MemoryBuiltins.h
+++ llvm/include/llvm/Analysis/MemoryBuiltins.h
@@ -57,10 +57,6 @@
 bool isAllocationFn(const Value *V,
                     function_ref<const TargetLibraryInfo &(Function &)> GetTLI);
 
-/// Tests if a value is a call or invoke to a function that returns a
-/// NoAlias pointer (including malloc/calloc/realloc/strdup-like functions).
-bool isNoAliasFn(const Value *V, const TargetLibraryInfo *TLI);
-
 /// Tests if a value is a call or invoke to a library function that
 /// allocates uninitialized memory (such as malloc).
 bool isMallocLikeFn(const Value *V, const TargetLibraryInfo *TLI);
Index: llvm/lib/Analysis/MemoryBuiltins.cpp
===================================================================
--- llvm/lib/Analysis/MemoryBuiltins.cpp
+++ llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -222,11 +222,6 @@
   return Result;
 }
 
-static bool hasNoAliasAttr(const Value *V) {
-  const auto *CB = dyn_cast<CallBase>(V);
-  return CB && CB->hasRetAttr(Attribute::NoAlias);
-}
-
 /// Tests if a value is a call or invoke to a library function that
 /// allocates or reallocates memory (either malloc, calloc, realloc, or strdup
 /// like).
@@ -238,15 +233,6 @@
   return getAllocationData(V, AnyAlloc, GetTLI).hasValue();
 }
 
-/// Tests if a value is a call or invoke to a function that returns a
-/// NoAlias pointer (including malloc/calloc/realloc/strdup-like functions).
-bool llvm::isNoAliasFn(const Value *V, const TargetLibraryInfo *TLI) {
-  // it's safe to consider realloc as noalias since accessing the original
-  // pointer is undefined behavior
-  return isAllocationFn(V, TLI) ||
-         hasNoAliasAttr(V);
-}
-
 /// Tests if a value is a call or invoke to a library function that
 /// allocates uninitialized memory (such as malloc).
 bool llvm::isMallocLikeFn(const Value *V, const TargetLibraryInfo *TLI) {
Index: llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -594,7 +594,7 @@
     // turn into undef.  Note that we can bypass the allocation itself when
     // looking for a clobber in many cases; that's an alias property and is
     // handled by BasicAA.
-    if (isa<AllocaInst>(Inst) || isNoAliasFn(Inst, &TLI)) {
+    if (isa<AllocaInst>(Inst) || isNoAliasCall(Inst)) {
       const Value *AccessPtr = getUnderlyingObject(MemLoc.Ptr);
       if (AccessPtr == Inst || BatchAA.isMustAlias(Inst, AccessPtr))
         return MemDepResult::getDef(Inst);
Index: llvm/lib/Transforms/IPO/Attributor.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Attributor.cpp
+++ llvm/lib/Transforms/IPO/Attributor.cpp
@@ -207,7 +207,7 @@
                                     const TargetLibraryInfo *TLI) {
   if (isa<AllocaInst>(Obj))
     return UndefValue::get(&Ty);
-  if (isNoAliasFn(&Obj, TLI)) {
+  if (isAllocationFn(&Obj, TLI)) {
     if (isMallocLikeFn(&Obj, TLI) || isAlignedAllocLikeFn(&Obj, TLI))
       return UndefValue::get(&Ty);
     if (isCallocLikeFn(&Obj, TLI))
@@ -309,8 +309,6 @@
   SmallVector<const AAPointerInfo *> PIs;
   SmallVector<Value *> NewCopies;
 
-  const auto *TLI =
-      A.getInfoCache().getTargetLibraryInfoForFunction(*SI.getFunction());
   for (Value *Obj : Objects) {
     LLVM_DEBUG(dbgs() << "Visit underlying object " << *Obj << "\n");
     if (isa<UndefValue>(Obj))
@@ -328,7 +326,7 @@
       return false;
     }
     if (!isa<AllocaInst>(Obj) && !isa<GlobalVariable>(Obj) &&
-        !isNoAliasFn(Obj, TLI)) {
+        !isNoAliasCall(Obj)) {
       LLVM_DEBUG(dbgs() << "Underlying object is not supported yet: " << *Obj
                         << "\n";);
       return false;
Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5267,9 +5267,6 @@
           continue;
         return false;
       }
-      if (!isa<AllocaInst>(Obj) && !isa<GlobalVariable>(Obj) &&
-          !isNoAliasFn(Obj, TLI))
-        return false;
       Constant *InitialVal = AA::getInitialValueForObj(*Obj, *L.getType(), TLI);
       if (!InitialVal || !Union(*InitialVal))
         return false;
Index: llvm/test/Transforms/GVN/malloc-load-removal.ll
===================================================================
--- llvm/test/Transforms/GVN/malloc-load-removal.ll
+++ llvm/test/Transforms/GVN/malloc-load-removal.ll
@@ -5,7 +5,7 @@
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.8.0"
 
-declare i8* @malloc(i64) nounwind
+declare noalias i8* @malloc(i64) nounwind
 
 define noalias i8* @test1() nounwind uwtable ssp {
 entry:
@@ -30,7 +30,7 @@
 ; CHECK_NO_LIBCALLS: icmp
 }
 
-declare i8* @_Znwm(i64) nounwind
+declare noalias i8* @_Znwm(i64) nounwind
 
 define noalias i8* @test2() nounwind uwtable ssp {
 entry:
@@ -55,7 +55,7 @@
 ; CHECK_NO_LIBCALLS: icmp
 }
 
-declare i8* @aligned_alloc(i64, i64) nounwind
+declare noalias i8* @aligned_alloc(i64, i64) nounwind
 
 define noalias i8* @test3() nounwind uwtable ssp {
 entry:
Index: llvm/unittests/Analysis/MemoryBuiltinsTest.cpp
===================================================================
--- llvm/unittests/Analysis/MemoryBuiltinsTest.cpp
+++ llvm/unittests/Analysis/MemoryBuiltinsTest.cpp
@@ -36,14 +36,12 @@
       CallInst::Create(AllocSizeFn, {ConstantInt::get(ArgTy, 100)}));
 
   const TargetLibraryInfo *TLI = nullptr;
-  EXPECT_FALSE(isNoAliasFn(Caller.get(), TLI));
   EXPECT_FALSE(isMallocLikeFn(Caller.get(), TLI));
   EXPECT_FALSE(isCallocLikeFn(Caller.get(), TLI));
   EXPECT_FALSE(isAllocLikeFn(Caller.get(), TLI));
 
   // FIXME: We might be able to treat allocsize functions as general allocation
-  // functions. For the moment, being conservative seems better (and we'd have
-  // to plumb stuff around `isNoAliasFn`).
+  // functions.
   EXPECT_FALSE(isAllocationFn(Caller.get(), TLI));
 }
 }