[PATCH] D65593: [Attributor][MustExec] Deduce dereferenceable and nonnull attribute by exploring path
Hideto Ueno via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 10:38:48 PDT 2019
uenoku created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.
In this patch, `MustBeExecutedContextExplorer` is extended to traverse the path and nonnull and dereferenceable are deduced more. This patch introduces a prototype for traversing path and geting information.
For example,
I_1
I_2
if(...){
T_1
}else{
F_1
}
E_1
E_2
...
If we assume that I_1 is executed and all instructions are `willreturn` and `nounwind`, we can get following formula(P is a function that takes Instruction and returns some State(Formula)).
P(I_1) \/P(l_2) \/ (P(T_1) /\ P(F_1)) \/ P(E_1) \/ P(E_2)
This enables us this deduction:
define void @f7(i8* %a, i8 %c) {
%cmp = icmp eq i8 %c, 0
tail call void @fun1(i8* dereferenceable(4) %a)
br i1 %cmp, label %cont.then, label %cont.else
cont.then:
tail call void @fun1(i8* dereferenceable(12) %a)
br label %cont2
cont.else:
tail call void @fun1(i8* dereferenceable(16) %a)
br label %cont2
cont2:
tail call void @fun1(i8* dereferenceable(8) %a)
ret void
}
; -> %a is dereferenceable(12)
Currently, the state(`ASBool, ASDeref`) is implemented new for an experiment but, needless to say, the state is very similar to `Attributor::AbstractState` so I think it is better to reuse `AbstractState`.
https://reviews.llvm.org/D65593
Files:
llvm/include/llvm/Analysis/MustExecute.h
llvm/lib/Analysis/MustExecute.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/test/Transforms/FunctionAttrs/dereferenceable.ll
llvm/test/Transforms/FunctionAttrs/nonnull.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65593.212845.patch
Type: text/x-patch
Size: 13320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190801/a4dbec50/attachment.bin>
More information about the llvm-commits
mailing list