[PATCH] [SCCP] Calculate Null Pointer Comparisons
Sanjoy Das
sanjoy at playingwithpointers.com
Mon May 11 10:41:52 PDT 2015
I'm not sure that this is doing the right thing -- I don't think simply //producing// `undef` implies undefined behavior.
For instance, in
declare void @g()
define i1 @test_postdominate(i8* %mem) {
%test = icmp eq i8* %mem, null
br i1 %test, label %a, label %b
a:
call void @g()
br label %c
b:
br label %c
c:
%join = phi i8* [ %mem, %a ], [ null, %b ]
%gep = getelementptr inbounds i8, i8* %join, i64 4
ret i1 %test
}
if `%mem` is `null`, then we have to execute the call to `@g`, but this pass make the branch into `a` dead (so `@f` never calls `@g`). The fact that `%gep` is `undef` (or poison) does not make this program undefined. In fact, if `inbounds` GEP instructions could invoke UB, then we would not be able to hoist such instructions out of loops.
http://reviews.llvm.org/D9634
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list