https://bugs.llvm.org/show_bug.cgi?id=34966

            Bug ID: 34966
           Summary: Missing static function with thinlto on AArch64 when
                    an extern function with same name exists.
           Product: tools
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: lto
          Assignee: unassignedb...@nondot.org
          Reporter: hiradi...@msn.com
                CC: llvm-bugs@lists.llvm.org

The static/internal function with thinlto gets skipped and results in a
miscompile. A reduced test case is as follows:


$cat static.c 

static int __attribute__((__noinline__)) f(int i) {
  volatile int j = i+10;
  return j;
}

int ext() {
  return f(100);
}

$ cat non-static.c 
int f(void) { return 32; }

$ cat reference.c 
int f();
int ext();

int main(void) {
  return f()+ ext();
}

$ cat run.sh

CC=~/llvm/build/bin/clang
LARGS=~/llvm/build/lib/libLTO.dylib

LFLAGS='-fobjc-arc -Xlinker -lto_library -Xlinker'
CFLAGS='--save-temps -v -Xlinker -save-temps'

ARCH='-arch arm64 -isysroot
/Applications/Xcode_9.0.0_fb.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk'

$CC -Oz -flto=thin static.c non-static.c reference.c $ARCH $CFLAGS $LFLAGS
$LARGS

Only one function '_f' is there and the static function 'f' is gone.
$ objdump -d a.out | grep _.*
Disassembly of section __TEXT,__text:
__text:
_ext:
_f:
_main:


However, when you target x86_64 (just remove the ARGS from command line)

$ objdump -d a.out | grep ^_.*
__text:
_ext:
_f.llvm.4247299495:
_f:
_main:

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to