2019-06-18 05:08:30 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++98 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
|
|
|
|
|
|
|
|
struct A { int x, y[3]; };
|
|
|
|
struct B { A a; };
|
|
|
|
|
[CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition
Summary:
Clang -fpic defaults to -fno-semantic-interposition (GCC -fpic defaults
to -fsemantic-interposition).
Users need to specify -fsemantic-interposition to get semantic
interposition behavior.
Semantic interposition is currently a best-effort feature. There may
still be some cases where it is not handled well.
Reviewers: peter.smith, rnk, serge-sans-paille, sfertile, jfb, jdoerfert
Subscribers: dschuff, jyknight, dylanmckay, nemanjai, jvesely, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, arphaman, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73865
2020-02-03 04:23:47 +08:00
|
|
|
// CHECK: @b = dso_local global %{{[^ ]*}} { %{{[^ ]*}} { i32 1, [3 x i32] [i32 2, i32 5, i32 4] } }
|
2019-06-18 05:08:30 +08:00
|
|
|
B b = {(A){1, 2, 3, 4}, .a.y[1] = 5};
|
|
|
|
|
|
|
|
union U {
|
|
|
|
int n;
|
|
|
|
float f;
|
|
|
|
};
|
|
|
|
struct C {
|
|
|
|
int x;
|
|
|
|
U u[3];
|
|
|
|
};
|
|
|
|
struct D {
|
|
|
|
C c;
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: @d1 = {{.*}} { i32 1, [3 x %[[U:.*]]] [%[[U]] { i32 2 }, %[[U]] { i32 5 }, %[[U]] { i32 4 }] }
|
|
|
|
D d1 = {(C){1, {{.n=2}, {.f=3}, {.n=4}}}, .c.u[1].n = 5};
|
|
|
|
|
|
|
|
// CHECK: @d2 = {{.*}} { i32 1, { %[[U]], float, %[[U]] } { %[[U]] { i32 2 }, float 5.{{0*}}e+00, %[[U]] { i32 4 } } }
|
|
|
|
D d2 = {(C){1, 2, 3, 4}, .c.u[1].f = 5};
|
|
|
|
|
|
|
|
struct Bitfield {
|
|
|
|
int a : 3;
|
|
|
|
int b : 4;
|
|
|
|
int c : 5;
|
|
|
|
};
|
|
|
|
struct WithBitfield {
|
|
|
|
int n;
|
|
|
|
Bitfield b;
|
|
|
|
};
|
|
|
|
// CHECK: @bitfield = {{.*}} { i32 1, { i8, i8, [2 x i8] } { i8 42, i8 2, [2 x i8] undef } }
|
|
|
|
WithBitfield bitfield = {1, (Bitfield){2, 3, 4}, .b.b = 5};
|
|
|
|
|
|
|
|
struct String {
|
|
|
|
const char buffer[12];
|
|
|
|
};
|
|
|
|
struct WithString {
|
|
|
|
String str;
|
|
|
|
};
|
|
|
|
// CHECK: @string = {{.*}} [12 x i8] c"Hello World\00" } }
|
|
|
|
WithString string = {(String){"hello world"}, .str.buffer[0] = 'H', .str.buffer[6] = 'W'};
|
|
|
|
|
|
|
|
struct LargeArray {
|
|
|
|
int arr[4096];
|
|
|
|
};
|
|
|
|
struct WithLargeArray {
|
|
|
|
LargeArray arr;
|
|
|
|
};
|
[CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition
Summary:
Clang -fpic defaults to -fno-semantic-interposition (GCC -fpic defaults
to -fsemantic-interposition).
Users need to specify -fsemantic-interposition to get semantic
interposition behavior.
Semantic interposition is currently a best-effort feature. There may
still be some cases where it is not handled well.
Reviewers: peter.smith, rnk, serge-sans-paille, sfertile, jfb, jdoerfert
Subscribers: dschuff, jyknight, dylanmckay, nemanjai, jvesely, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, arphaman, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73865
2020-02-03 04:23:47 +08:00
|
|
|
// CHECK: @large = dso_local global { { <{ [11 x i32], [4085 x i32] }> } } { { <{ [11 x i32], [4085 x i32] }> } { <{ [11 x i32], [4085 x i32] }> <{ [11 x i32] [i32 1, i32 2, i32 3, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 10], [4085 x i32] zeroinitializer }> } }
|
2019-06-18 05:08:30 +08:00
|
|
|
WithLargeArray large = {(LargeArray){1, 2, 3}, .arr.arr[10] = 10};
|
|
|
|
|
|
|
|
union OverwritePaddingWithBitfield {
|
|
|
|
struct Padding { unsigned : 8; char c; } padding;
|
|
|
|
char bitfield : 3;
|
|
|
|
};
|
|
|
|
struct WithOverwritePaddingWithBitfield {
|
|
|
|
OverwritePaddingWithBitfield a;
|
|
|
|
};
|
[CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition
Summary:
Clang -fpic defaults to -fno-semantic-interposition (GCC -fpic defaults
to -fsemantic-interposition).
Users need to specify -fsemantic-interposition to get semantic
interposition behavior.
Semantic interposition is currently a best-effort feature. There may
still be some cases where it is not handled well.
Reviewers: peter.smith, rnk, serge-sans-paille, sfertile, jfb, jdoerfert
Subscribers: dschuff, jyknight, dylanmckay, nemanjai, jvesely, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, arphaman, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73865
2020-02-03 04:23:47 +08:00
|
|
|
// CHECK: @overwrite_padding = dso_local global { { i8, i8 } } { { i8, i8 } { i8 3, i8 1 } }
|
2019-06-18 05:08:30 +08:00
|
|
|
WithOverwritePaddingWithBitfield overwrite_padding = {(OverwritePaddingWithBitfield){1}, .a.bitfield = 3};
|