[llvm-dev] analysis based on nonnull attribute
Sanjay Patel via llvm-dev
llvm-dev at lists.llvm.org
Wed Dec 14 13:47:03 PST 2016
Does the nonnull parameter attribute give us information about subsequent
uses of that value outside of the function that has the attribute?
Example:
define i1 @bar(i32* nonnull %x) { ; %x must be non-null in this function
%y = load i32, i32* %x
%z = icmp ugt i32 %y, 23
ret i1 %z
}
define i1 @foo(i32* %x) {
%d = call i1 @bar(i32* %x)
%null_check = icmp eq i32* %x, null ; check if null after call that
guarantees non-null?
br i1 %null_check, label %t, label %f
t:
ret i1 1
f:
ret i1 %d
}
$ opt -inline nonnull.ll -S
...
define i1 @foo(i32* %x) {
%y.i = load i32, i32* %x ; inlined and non-null knowledge is lost?
%z.i = icmp ugt i32 %y.i, 23
%null_check = icmp eq i32* %x, null
br i1 %null_check, label %t, label %f
t:
ret i1 true
f:
ret i1 %z.i
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161214/4620b87a/attachment.html>
More information about the llvm-dev
mailing list