diff options
Diffstat (limited to 'test/CodeGen/compound-literal.c')
-rw-r--r-- | test/CodeGen/compound-literal.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/CodeGen/compound-literal.c b/test/CodeGen/compound-literal.c index 85138bfaf5e0..6507341ce2c1 100644 --- a/test/CodeGen/compound-literal.c +++ b/test/CodeGen/compound-literal.c @@ -1,5 +1,10 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s +// Capture the type and name so matching later is cleaner. +struct CompoundTy { int a; }; +// CHECK: @MyCLH = constant [[MY_CLH:[^,]+]] +const struct CompoundTy *const MyCLH = &(struct CompoundTy){3}; + int* a = &(int){1}; struct s {int a, b, c;} * b = &(struct s) {1, 2, 3}; _Complex double * x = &(_Complex double){1.0f}; @@ -66,3 +71,14 @@ struct G g(int x, int y, int z) { // CHECK-NEXT: [[T0:%.*]] = load i48, i48* [[COERCE_TEMP]] // CHECK-NEXT: ret i48 [[T0]] } + +// We had a bug where we'd emit a new GlobalVariable for each time we used a +// const pointer to a variable initialized by a compound literal. +// CHECK-LABEL: define i32 @compareMyCLH() #0 +int compareMyCLH() { + // CHECK: store i8* bitcast ([[MY_CLH]] to i8*) + const void *a = MyCLH; + // CHECK: store i8* bitcast ([[MY_CLH]] to i8*) + const void *b = MyCLH; + return a == b; +} |