[LLVMbugs] [Bug 21490] New: LTO treats ObjC @selector's as compile time constants, which they are not

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 5 10:26:18 PST 2014


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

            Bug ID: 21490
           Summary: LTO treats ObjC @selector's as compile time constants,
                    which they are not
           Product: new-bugs
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: freik at fb.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

For static/global values initialized with @selector syntax, the link time
optimizer treats them as if they're compile-time constants. This is true for
OSX and iOS.

Compile this -O2 (or -O3) with & without -flto:

#include <stdio.h>
#import <Foundation/Foundation.h>

@interface MyInterface : NSObject
  // This selector also exists on NSString, so it gets adjusted at load time
  -(NSUInteger)length;
@end

static SEL MySel = @selector(length);

int main(int argc, const char * argv[]) {
  if (@selector(length) != MySel) {
    printf("LTO BUG!\n");
    return -1;
  }
  return 0;
}

The workaround for this issue is to use sel_registerName("length") instead of
the @selector syntax, though this is much slower.

-- 
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/20141105/fdf45d3c/attachment.html>


More information about the llvm-bugs mailing list