[llvm-bugs] [Bug 32581] New: restrict pointers from structures passed by value ignored

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 8 11:08:17 PDT 2017


http://bugs.llvm.org/show_bug.cgi?id=32581

            Bug ID: 32581
           Summary: restrict pointers from structures passed by value
                    ignored
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: llvm-bugs at lists.llvm.org

A restrict pointer as a structure member passed by value to a function is
associated with the same block as a similar pointer passed as a scalar to that
function. It is observed that the optimization opportunity associated with such
a structure member is lost in the translation to the IR.

Note: the specific IR surrounding the parameter of structure type is dependent
on the target ABI. For ppc64le, this depends on the size of the structure type.

Online compiler: https://wandbox.org/permlink/lmzxbVOXYswJPsoe

### SOURCE (<stdin>):
typedef struct S {
  int *restrict p;
} S;

void f(S s, int *q) {
  extern void who_goes_there();
  *s.p = 1;
  *q = 2;
  if (*s.p != 1) { who_goes_there(); }
}


### COMPILER INVOCATION:
clang -x c -std=c11 -O2 -c -o a.o -


### ACTUAL OUTPUT (a.o):
(Contains reference to who_goes_there).


### EXPECTED OUTPUT:
No reference to who_goes_there.


### COMPILER VERSION INFO (clang -v):
clang version 5.0.0 (https://github.com/llvm-mirror/clang.git
af734ef76cc33a4d5f10cc7c799687b5997703f1)
(https://github.com/llvm-mirror/llvm.git
1afcae44d92c906c595bd0b2b365dfd58b8657f9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

-- 
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/20170408/0aa151f6/attachment.html>


More information about the llvm-bugs mailing list