brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 75962ae Raw
107 lines · plain
1; REQUIRES: x862 3;; Check that we internalize bitcode symbols (only) where possible, i.e. when4;; they are not referenced by undefined symbols originating from non-bitcode5;; files.6 7; RUN: rm -rf %t; split-file %s %t8; RUN: llvm-as %t/test.s -o %t/test.o9; RUN: llvm-as %t/baz.s -o %t/baz.o10; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/regular.s -o %t/regular.o11; RUN: %lld -lSystem %t/test.o %t/baz.o %t/regular.o -o %t/test -save-temps12; RUN: llvm-dis < %t/test.0.2.internalize.bc | FileCheck %s13; RUN: llvm-objdump --macho --syms %t/test | FileCheck %s --check-prefix=SYMTAB14 15; CHECK: @comm = internal global16; CHECK: @comm_hide = internal global17 18;; Check that main is not internalized. This covers the case of bitcode symbols19;; referenced by undefined symbols that don't belong to any InputFile.20; CHECK: define dso_local void @main()21 22;; Check that the foo and bar functions are correctly internalized.23; CHECK: define internal void @bar()24; CHECK: define internal void @foo()25 26;; Check that a bitcode symbol that is referenced by a regular object file isn't27;; internalized.28; CHECK: define dso_local void @used_in_regular_obj()29 30;; Check that a bitcode symbol that is defined in another bitcode file gets31;; internalized.32; CHECK: define internal void @baz()33 34;; Check that all internalized symbols are not emitted to the symtab35; SYMTAB-LABEL: SYMBOL TABLE:36; SYMTAB-DAG:   g     F __TEXT,__text _main37; SYMTAB-DAG:   g     F __TEXT,__text _used_in_regular_obj38; SYMTAB-DAG:   g     F __TEXT,__text __mh_execute_header39; SYMTAB-DAG:           *UND* dyld_stub_binder40; SYMTAB-EMPTY:41 42; RUN: %lld -lSystem -dylib %t/test.o %t/baz.o %t/regular.o -o %t/test.dylib -save-temps43; RUN: llvm-dis < %t/test.dylib.0.2.internalize.bc | FileCheck %s --check-prefix=DYN44; RUN: llvm-nm -m %t/test.dylib | FileCheck %s --check-prefix=DYN-SYMS \45; RUN:   --implicit-check-not _foo46 47; RUN: %lld -lSystem -export_dynamic %t/test.o %t/baz.o %t/regular.o -o %t/test.extdyn -save-temps48; RUN: llvm-dis < %t/test.extdyn.0.2.internalize.bc49; RUN: llvm-nm -m %t/test.extdyn | FileCheck %s --check-prefix=DYN-SYMS \50; RUN:   --implicit-check-not _foo51 52;; Note that only foo() gets internalized here; everything else that isn't53;; hidden must be exported.54; DYN: @comm = common dso_local global55; DYN: @comm_hide = internal global56; DYN: define dso_local void @main()57; DYN: define dso_local void @bar()58; DYN: define internal void @foo()59; DYN: define dso_local void @used_in_regular_obj()60; DYN: define dso_local void @baz()61 62; DYN-SYMS-DAG: (__TEXT,__text) external _bar63; DYN-SYMS-DAG: (__TEXT,__text) external _baz64; DYN-SYMS-DAG: (__DATA,__common) external _comm65; DYN-SYMS-DAG: (__TEXT,__text) external _main66; DYN-SYMS-DAG: (__TEXT,__text) external _used_in_regular_obj67 68;--- test.s69target triple = "x86_64-apple-macosx10.15.0"70target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"71 72;; Common symbols are always external.73@comm = common global i8 0, align 174@comm_hide = common hidden global i8 0, align 175 76declare void @baz()77 78define void @main() {79  call void @bar()80  call void @baz()81  ret void82}83 84define void @bar() {85  ret void86}87 88define hidden void @foo() {89  ret void90}91 92define void @used_in_regular_obj() {93  ret void94}95 96;--- baz.s97target triple = "x86_64-apple-macosx10.15.0"98target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"99 100define void @baz() {101  ret void102}103 104;--- regular.s105.data106.quad _used_in_regular_obj107