Index: lib/Analysis/MemoryBuiltins.cpp =================================================================== --- lib/Analysis/MemoryBuiltins.cpp +++ lib/Analysis/MemoryBuiltins.cpp @@ -392,7 +392,7 @@ IntTyBits = DL.getPointerTypeSizeInBits(V->getType()); Zero = APInt::getNullValue(IntTyBits); - V = V->stripPointerCasts(); + V = V->stripPointerCasts(/*LookThroughNoAlias*/true); if (Instruction *I = dyn_cast(V)) { // If we have already seen this instruction, bail out. Cycles can happen in // unreachable code after constant propagation. @@ -612,7 +612,7 @@ return std::make_pair(ConstantInt::get(Context, Const.first), ConstantInt::get(Context, Const.second)); - V = V->stripPointerCasts(); + V = V->stripPointerCasts(/*LookThroughNoAlias*/true); // check cache CacheMapTy::iterator CacheIt = CacheMap.find(V); Index: test/Analysis/BasicAA/global-size.ll =================================================================== --- test/Analysis/BasicAA/global-size.ll +++ test/Analysis/BasicAA/global-size.ll @@ -16,6 +16,17 @@ ; CHECK: ret i16 0 } +; CHECK-LABEL: @test1a( +define i16 @test1a(i32* %P) { + %b = call i16* @llvm.noalias.p0i16(i16* @B, metadata !1) + %X = load i16, i16* %b + store i32 7, i32* %P + %Y = load i16, i16* %b + %Z = sub i16 %Y, %X + ret i16 %Z +; CHECK: ret i16 0 +} + @B_as1 = addrspace(1) global i16 8 define i16 @test1_as1(i32 addrspace(1)* %P) { @@ -50,3 +61,8 @@ ; CHECK: ret i8 %C } +declare i16* @llvm.noalias.p0i16(i16*, metadata) nounwind + +!0 = !{!0, !"some domain"} +!1 = !{!1, !0, !"some scope"} +