[PATCH] D100724: [SimplifyLibCalls] Transform printf("%s", str"\n") --> puts(str).

Dawid Jurczak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 18 08:34:16 PDT 2021


yurai007 marked an inline comment as done.
yurai007 added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:2397
   // printf("foo\n") --> puts("foo")
   if (FormatStr[FormatStr.size() - 1] == '\n' &&
       FormatStr.find('%') == StringRef::npos) { // No format characters.
----------------
xbolva00 wrote:
> xbolva00 wrote:
> > yurai007 wrote:
> > > xbolva00 wrote:
> > > > Can you change this to FormatStr.back() ?
> > > Sure.
> > Thanks, otherwise it is OK from me.
> > 
> > Mayybe @spatel / @fhahn / @efriedma take a second look?
> I was wondering if we can check content of "str.1" and yes! with --check-globals flag
> 
> Can you run ./update_test_checks.py --check-globals /home/xbolva00/p.ll llvm/test/Transforms/InstCombine/printf-2.ll ? It would be ideal to have check for content of str.1 too.
Ok. Now test has extra strings checking (hope did it correctly). It extends patch scope a little bit so I updated 'summary' and commit message.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100724/new/

https://reviews.llvm.org/D100724



More information about the llvm-commits mailing list