mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 06:56:06 +00:00

This relands commit 13dd65b3a1a3ac049b5f3a9712059f7c61649bea. The original commit contained a test, which failed when compiled for a MACH-O target. This patch changes the test to run for x86_64-linux instead of `%itanium_abi_triple`, to avoid having invalid syntax for MACH-O sections. The patch itself does not care about section attribute syntax and a x86 backend does not even need to be included in the build. Differential Revision: https://reviews.llvm.org/D102693
26 lines
710 B
C++
26 lines
710 B
C++
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
|
|
|
|
__attribute__((section("A")))
|
|
const int a = 1;
|
|
const int *f() { return &a; }
|
|
// CHECK: @_ZL1a = internal constant i32 1, section "A"
|
|
|
|
int init();
|
|
__attribute__((section("B")))
|
|
const int b = init();
|
|
// Even if it's const-qualified, it must not be LLVM IR `constant` since it's
|
|
// dynamically initialised.
|
|
// CHECK: @_ZL1b = internal global i32 0, section "B"
|
|
|
|
__attribute__((section("C")))
|
|
int c = 2;
|
|
// CHECK: @c = {{.*}}global i32 2, section "C"
|
|
|
|
__attribute__((section("D")))
|
|
int d = init();
|
|
// CHECK: @d = {{.*}}global i32 0, section "D"
|
|
|
|
__attribute__((section("E")))
|
|
int e;
|
|
// CHECK: @e = {{.*}}global i32 0, section "E", align 4
|