[PATCH] D53342: [SimplifyLibCalls] Mark known arguments with nonnull
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 14 11:51:05 PDT 2019
xbolva00 added a comment.
Btw
>> We should ditch “removeNonNull” handling since Clang never annotates callsites (Clang only annotates function signatures - currently nonnull is dropped, great!)
I will go this way and remove it. removeNonNull may pessimize things / create compiler infinite loops. Some other may infer that pointer X is nonnull and then InstCombine would remove it in strncpy(D, X, N); // non const N
Imagine
%add.ptr = getelementptr inbounds i8, i8* %string_literal, i64 1
%call2 = call i64 @strlen(i8* nonnull dereferenceable(1) %string_literal) #7
%sub3 = add i64 %call2, -2
%call4 = call i8* @strncpy(i8* nonnull %call1, i8* nonnull %add.ptr, i64 %sub3) #8
This is IR which cause instcombine infinite loop. InstCombine sees that sub3 is not "known zero" and will remove nonnull from add.ptr. As I noted, I am not worried if we remove "removeNonNull", since Clang does not annotate call sites, Clang just emit function signatures (and these do not contain "nonnulls").
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D53342/new/
https://reviews.llvm.org/D53342
More information about the llvm-commits
mailing list