[PATCH] D94180: [SimplifyCFG] Optimize CFG when null is passed to a function with nonnull argument.
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 7 09:33:07 PST 2021
xbolva00 added a comment.
define void @test9_gep_mismatch(i1 %X, i8* %Y, i8* %P) {
; CHECK-LABEL: @test9_gep_mismatch(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[X:%.*]], i8* null, i8* [[Y:%.*]]
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, i8* [[P:%.*]], i64 0
; CHECK-NEXT: [[TMP0:%.*]] = call i8* @foo(i8* [[GEP]])
; CHECK-NEXT: ret void
;
entry:
br i1 %X, label %if, label %else
if:
br label %else
else:
%phi = phi i8* [ %Y, %entry ], [ null, %if ]
%gep = getelementptr inbounds i8, i8* %phi, i64 7
call i8* @foo(i8* %gep)
ret void
}
So for this case,
Use is
call i8* @foo(i8* %gep)
I is
%gep = getelementptr inbounds i8, i8* %phi, i64 7
and V is a incoming value from phi. We bailt out if V is not constant, it needs to be null value.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94180/new/
https://reviews.llvm.org/D94180
More information about the llvm-commits
mailing list