[llvm-bugs] [Bug 33604] New: ThinLTO doesn't know about constant return values

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 26 15:29:25 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33604

            Bug ID: 33604
           Summary: ThinLTO doesn't know about constant return values
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: davide at freebsd.org
                CC: charles.saternos at gmail.com, davidxl at google.com,
                    joker.eph at gmail.com, llvm-bugs at lists.llvm.org,
                    tejohnson at google.com

As Charles, our GSoC student working on ThinLTO was looking for opportunities
to improve ThinLTO, here's something that came to my mind.

I'm not sure whether we want to go in this direction, but it's a start.

$ cat a.c
__attribute__((noinline))
int patatino(void) {
  return 47;
}

$ cat b.c
extern int patatino(void);

int main(void) {
  return patatino();
}

$ ../clang a.c b.c -flto -fuse-ld=lld -Wl,-save-temps -o patatino-lto
$ objdump -d patatino-lto

[...]

0000000000201190 <main>:
  201190:       55                      push   %rbp
  201191:       48 89 e5                mov    %rsp,%rbp
  201194:       48 83 ec 10             sub    $0x10,%rsp
  201198:       c7 45 fc 00 00 00 00    movl   $0x0,-0x4(%rbp)
  20119f:       e8 dc ff ff ff          callq  201180 <patatino>
  2011a4:       b8 2f 00 00 00          mov    $0x2f,%eax
  2011a9:       48 83 c4 10             add    $0x10,%rsp
  2011ad:       5d                      pop    %rbp
  2011ae:       c3                      retq

With ThinLTO:

$ ../clang a.c b.c -flto=thin -fuse-ld=lld -Wl,-save-temps -o patatino-thin
$ $ objdump -d ./patatino-thin

[...]

0000000000201190 <main>:
  201190:       55                      push   %rbp
  201191:       48 89 e5                mov    %rsp,%rbp
  201194:       48 83 ec 10             sub    $0x10,%rsp
  201198:       c7 45 fc 00 00 00 00    movl   $0x0,-0x4(%rbp)
  20119f:       e8 dc ff ff ff          callq  201180 <patatino>
  2011a4:       48 83 c4 10             add    $0x10,%rsp
  2011a8:       5d                      pop    %rbp
  2011a9:       c3                      retq

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170626/3b006c71/attachment-0001.html>


More information about the llvm-bugs mailing list