[LLVMdev] Another missed optimization opportunity?

Cameron McInally cameron.mcinally at nyu.edu
Wed Apr 24 11:35:20 PDT 2013


Hey Scott,

On Wed, Apr 24, 2013 at 1:40 PM, Scott Pakin <pakin at lanl.gov> wrote:
...

>
> Is there some semantic reason that the increments aren't allowed to be
> combined, or is this a missed optimization opportunity in LLVM?
>
>
I believe that the wildcard is the extern keyword.

Since the external symbol isn't resolved until link time, I suspect that it
would be a legal C program to do something like (maybe the language lawyers
know better though):

XXX> cat test.c
extern int x;

int kung( ) {
  return x;
}

XXX> cat foo.c
extern int kung();

volatile int x;

int main() {
  x = 0;
  return kung();
}

Ugly programming, but I see no way of the linker having enough information
to determine that the extern should be volatile and issue an warning/error.

One more reason to use explicit barriers instead of volatile. ;)

-Cameron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130424/1eca8f0d/attachment.html>


More information about the llvm-dev mailing list