[llvm-bugs] [Bug 32752] New: ThinLTO missing optimization on Globals
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Apr 22 22:40:31 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=32752
Bug ID: 32752
Summary: ThinLTO missing optimization on Globals
Product: new-bugs
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: mehdi.amini at apple.com
CC: llvm-bugs at lists.llvm.org
This examples shows some current limitations of ThinLTO with globals:
// globalopt0.c
int g0 = 0, g1 = 22, g2;
extern void foo1(void);
int main() {
g0 = 1;
g1 = 22;
g2 = 1;
foo1();
return g0 + g1;
}
// globalopt1.c
extern int g0, g1, g2;
void __attribute__((noinline)) foo1(void) {
g0 = 0;
g1 = 22;
g2 = 4;
}
Build with:
$ clang globalopt0.c -c -flto=thin -O3
$ clang globalopt1.c -c -flto=thin -O3
$ clang globalopt0.o globalopt1.o -O3 -o globalopt -Wl,-save-temps
Some potential optimizations:
- g0’s type can be changed to i1 because only two values (0 or 1) are stored to
it.
- g1 should be optimized away because only one value (22) is stored.
- g2 should be optimized away because it’s store-only.
--
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/20170423/43ba9770/attachment.html>
More information about the llvm-bugs
mailing list