brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · 57ad89c Raw
91 lines · plain
1; REQUIRES: x862 3;; NOTE: We deviate significantly from ld64's behavior here. We treat common4;; bitcode symbols like regular common symbols, but ld64 gives them different5;; (and IMO very strange) precedence. This test documents the differences.6 7; RUN: rm -rf %t; split-file %s %t8; RUN: opt -module-summary %t/test.ll -o %t/test.o9; RUN: opt -module-summary %t/same-size.ll -o %t/same-size.o10; RUN: opt -module-summary %t/smaller-size.ll -o %t/smaller-size.o11; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/same-size.s -o %t/same-size-asm.o12; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/smaller-size.s -o %t/smaller-size-asm.o13 14;; ld64: Common bitcode symbols all have equal precedence, regardless of size or15;; alignment.16;; lld: We pick the symbol with the larger size, regardless of alignment.17; RUN: %lld -dylib %t/test.o %t/smaller-size.o -order_file %t/order -o %t/test18; RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=2 -D#ALIGN=819; RUN: %lld -dylib %t/smaller-size.o %t/test.o -order_file %t/order -o %t/test20; RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=2 -D#ALIGN=821; COM (ld64): llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=1 -D#ALIGN=1622 23;; ld64: Common bitcode symbols all have equal precedence, regardless of size or24;; alignment.25;; lld: When the sizes are equal, we pick the symbol whose file occurs later in26;; the command-line argument list.27; RUN: %lld -dylib %t/test.o %t/same-size.o -order_file %t/order -o %t/test28; RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=2 -D#ALIGN=1629; COM (ld64): llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=2 -D#ALIGN=830; RUN: %lld -dylib %t/same-size.o %t/test.o -order_file %t/order -o %t/test31; RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=2 -D#ALIGN=832 33;; ld64: Non-bitcode common symbols take precedence.34;; lld: We pick the symbol with the larger size, regardless of alignment.35; RUN: %lld -dylib %t/test.o %t/smaller-size-asm.o -order_file %t/order -o %t/test36; RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=2 -D#ALIGN=837; COM (ld64): llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=1 -D#ALIGN=1638; RUN: %lld -dylib %t/smaller-size-asm.o %t/test.o -order_file %t/order -o %t/test39; RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=2 -D#ALIGN=840; COM (ld64): llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=1 -D#ALIGN=1641 42; RUN: %lld -dylib %t/test.o %t/same-size-asm.o -order_file %t/order -o %t/test43; RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=2 -D#ALIGN=1644; RUN: %lld -dylib %t/same-size-asm.o %t/test.o -order_file %t/order -o %t/test45; RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=2 -D#ALIGN=846; COM (ld64): llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#SIZE=2 -D#ALIGN=1647 48; CHECK-LABEL: Sections:49; CHECK:       __common      {{[0-9a-f]+}} [[#%x, COMMON_START:]]  BSS50;51; CHECK-LABEL: SYMBOL TABLE:52; CHECK-DAG:   [[#%.16x, COMMON_START]]         g     O __DATA,__common _check_size53; CHECK-DAG:   [[#%.16x, COMMON_START + SIZE]]  g     O __DATA,__common _end_marker54; CHECK-DAG:   [[#%.16x, COMMON_START + ALIGN]] g     O __DATA,__common _check_alignment55 56;--- order57;; Order is important as we determine the size of a given symbol via the58;; address of the next symbol.59_check_size60_end_marker61_check_alignment62 63;--- smaller-size.ll64target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"65target triple = "x86_64-apple-macosx10.15.0"66 67@check_size = common global i8 0, align 168@check_alignment = common global i8 0, align 1669 70;--- same-size.ll71target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"72target triple = "x86_64-apple-macosx10.15.0"73 74@check_size = common global i16 0, align 175@check_alignment = common global i16 0, align 1676 77;--- smaller-size.s78.comm _check_size, 1, 179.comm _check_alignment, 1, 480 81;--- same-size.s82.comm _check_size, 2, 183.comm _check_alignment, 2, 484 85;--- test.ll86target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"87target triple = "x86_64-apple-macosx10.15.0"88@check_size = common global i16 0, align 189@end_marker = common global i8 090@check_alignment = common global i16 0, align 891