[PATCH] llvm.noalias - ObjectSizeOffsetVisitor should look through them
hfinkel at anl.gov
hfinkel at anl.gov
Thu Apr 30 09:02:47 PDT 2015
Hi chandlerc, reames,
This is part of the series started by D9375, and teaches ObjectSizeOffsetVisitor to look through llvm.noalias when it looks through bitcasts (which is only does via an initial stripping for some reason).
http://reviews.llvm.org/D9391
Files:
lib/Analysis/MemoryBuiltins.cpp
test/Analysis/BasicAA/global-size.ll
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<Instruction>(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"}
+
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9391.24728.patch
Type: text/x-patch
Size: 1671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150430/a17d5aaa/attachment.bin>
More information about the llvm-commits
mailing list