[llvm-bugs] [Bug 33648] New: ThinLTO doesn't apply interprocedural FunctionAttrs optimization

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 29 13:09:57 PDT 2017


            Bug ID: 33648
           Summary: ThinLTO doesn't apply interprocedural FunctionAttrs
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: charles.saternos at gmail.com
                CC: llvm-bugs at lists.llvm.org

LTO will apply the funcitonattrs pass, but ThinLTO can't apply this
optimization right now.

$ cat a.cc
#include <stdio.h>
#include <assert.h>

int some_global = 100;
const int garr[] = {1,2,3};
int garr2[] = {1,2,3};

int a() {
    return 10;

void b(const int **x) {
    printf("%p", x[0]);

const int *c(const int *x) { // alias
    return &some_global;

int *d(int **x) { // alias, readonly arg
    return x[0];
$ cat b.cc
#include <stdio.h>

extern int a();
extern void b(const int **x);
extern const int *c(const int *x);
extern int *d(int **x);

int main(void) {
  const int arr2[] = {1,2};
  int x = 3;
  int y = 4;
  int *arr[] = {&x, &y};
  printf("%d\n", a());
  b((const int **) arr);
  printf("%p\n", c(&x));
  printf("%p\n", d(arr));

$ ../build/bin/clang++ a.cc b.cc -O3 --for-linker=-mllvm --for-linker=-stats
-flto=thin -fuse-ld=lld -o thin &>&1 | grep funcitonattrs
# nothing
$ ../build/bin/clang++ a.cc b.cc -O3 --for-linker=-mllvm --for-linker=-stats
-flto -fuse-ld=lld -o lto &>&1 | grep funcitonattrs

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/20170629/50f3cde3/attachment.html>

More information about the llvm-bugs mailing list