| 1 | // REQUIRES: x86-registered-target |
| 2 | |
| 3 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -o - < %s | FileCheck %s --check-prefix=PLAIN |
| 4 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -ffunction-sections -fno-function-sections -o - < %s | FileCheck %s --check-prefix=PLAIN |
| 5 | |
| 6 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -ffunction-sections -o - < %s | FileCheck %s --check-prefix=FUNC_SECT |
| 7 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fno-function-sections -ffunction-sections -o - < %s | FileCheck %s --check-prefix=FUNC_SECT |
| 8 | |
| 9 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT |
| 10 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fno-data-sections -fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT |
| 11 | |
| 12 | // Try again through a clang invocation of the ThinLTO backend. |
| 13 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 %s -flto=thin -emit-llvm-bc -o %t.o |
| 14 | // RUN: llvm-lto -thinlto -o %t %t.o |
| 15 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -ffunction-sections -o - | FileCheck %s --check-prefix=FUNC_SECT |
| 16 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -fdata-sections -o - | FileCheck %s --check-prefix=DATA_SECT |
| 17 | |
| 18 | const int hello = 123; |
| 19 | void world() {} |
| 20 | |
| 21 | // PLAIN-NOT: section |
| 22 | // PLAIN: world: |
| 23 | // PLAIN: section .rodata, |
| 24 | // PLAIN: hello: |
| 25 | |
| 26 | // FUNC_SECT: section .text.world, |
| 27 | // FUNC_SECT: world: |
| 28 | // FUNC_SECT: section .rodata, |
| 29 | // FUNC_SECT: hello: |
| 30 | |
| 31 | // DATA_SECT-NOT: .section |
| 32 | // DATA_SECT: world: |
| 33 | // DATA_SECT: .section .rodata.hello, |
| 34 | // DATA_SECT: hello: |
| 35 | |