| 1 |
// RUN: %clang_cc1 %s -triple=powerpc-ibm-aix-xcoff -mtocdata=h,g,f,e,d,c,b,a,globalOneWithAlias,globalTwoWithAlias,ll,t3 -verify -emit-llvm -o - | FileCheck %s -check-prefix=CHECK --match-full-lines |
| 2 |
// RUN: %clang_cc1 %s -triple=powerpc-ibm-aix-xcoff -mtocdata -verify=none -emit-llvm -o - | FileCheck %s -check-prefix=CHECK --match-full-lines |
| 3 |
|
| 4 |
// none-no-diagnostics |
| 5 |
|
| 6 |
struct large_struct { |
| 7 |
int x; |
| 8 |
short y; |
| 9 |
short z; |
| 10 |
char c; |
| 11 |
}; |
| 12 |
|
| 13 |
struct large_struct a; // expected-warning {{-mtocdata option is ignored for a because variable is larger than a pointer}} |
| 14 |
long long b = 5; // expected-warning {{-mtocdata option is ignored for b because variable is larger than a pointer}} |
| 15 |
int __attribute__((aligned(128))) c = 0; // expected-warning {{-mtocdata option is ignored for c because variable is aligned wider than a pointer}} |
| 16 |
double d = 2.5; // expected-warning {{-mtocdata option is ignored for d because variable is larger than a pointer}} |
| 17 |
int e __attribute__((section("foo"))) = 10; // expected-warning {{-mtocdata option is ignored for e because variable has a section attribute}} |
| 18 |
__thread int f; // expected-warning {{-mtocdata option is ignored for f because of thread local storage}} |
| 19 |
|
| 20 |
struct SomeStruct; |
| 21 |
extern struct SomeStruct g; // expected-warning {{-mtocdata option is ignored for g because of incomplete type}} |
| 22 |
|
| 23 |
extern int h[]; // expected-warning {{-mtocdata option is ignored for h because of incomplete type}} |
| 24 |
|
| 25 |
struct ty3 { |
| 26 |
int A; |
| 27 |
char C[]; |
| 28 |
}; |
| 29 |
struct ty3 t3 = { 4, "fo" }; // expected-warning {{-mtocdata option is ignored for t3 because it contains a flexible array member}} |
| 30 |
|
| 31 |
int globalOneWithAlias = 10; |
| 32 |
__attribute__((__alias__("globalOneWithAlias"))) extern int aliasOne; // expected-warning {{-mtocdata option is ignored for globalOneWithAlias because the variable has an alias}} |
| 33 |
__attribute__((__alias__("globalTwoWithAlias"))) extern int aliasTwo; // expected-warning {{-mtocdata option is ignored for globalTwoWithAlias because the variable has an alias}} |
| 34 |
int globalTwoWithAlias = 20; |
| 35 |
|
| 36 |
|
| 37 |
int func() { |
| 38 |
return a.x+b+c+d+e+f+h[0]; |
| 39 |
} |
| 40 |
|
| 41 |
struct SomeStruct* getAddress(void) { |
| 42 |
return &g; |
| 43 |
} |
| 44 |
|
| 45 |
int test() { |
| 46 |
return globalOneWithAlias + globalTwoWithAlias + aliasOne + aliasTwo; |
| 47 |
} |
| 48 |
|
| 49 |
long long test2() { |
| 50 |
static long long ll = 5; |
| 51 |
ll++; |
| 52 |
return ll; |
| 53 |
} |
| 54 |
|
| 55 |
// CHECK: @b = global i64 5, align 8 |
| 56 |
// CHECK: @c = global i32 0, align 128 |
| 57 |
// CHECK: @d = global double 2.500000e+00, align 8 |
| 58 |
// CHECK: @e = global i32 10, section "foo", align 4 |
| 59 |
// CHECK: @globalOneWithAlias = global i32 10, align 4 |
| 60 |
// CHECK: @globalTwoWithAlias = global i32 20, align 4 |
| 61 |
// CHECK: @a = global %struct.large_struct zeroinitializer, align 4 |
| 62 |
// CHECK: @f = thread_local global i32 0, align 4 |
| 63 |
// CHECK: @h = external global [0 x i32], align 4 |
| 64 |
// CHECK: @g = external global %struct.SomeStruct, align 1 |
| 65 |
// CHECK: @test2.ll = internal global i64 5, align 8 |
| 66 |
// CHECK: @aliasOne = alias i32, ptr @globalOneWithAlias |
| 67 |
// CHECK: @aliasTwo = alias i32, ptr @globalTwoWithAlias |
| 68 |
// CHECK-NOT: attributes #0 = { "toc-data" } |