[llvm-dev] Missed strlen optimizations

Dávid Bolvanský via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 20 09:07:09 PDT 2018


Hello,

Code: https://godbolt.org/g/EG4Wi6

unsigned fff3(void) {
    char buf[10] = "";
    return strlen(buf);
}

Since we are memset-ing before strlen call, we could replace strlen with
just 0.

Has LLVM any API to get "last instruction before strlen" which modifies
strlen argument "buf"? So we can check "yes, it is memset there, replace
strlen with zero" ?


Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180420/30e7381b/attachment.html>


More information about the llvm-dev mailing list