teak-llvm/clang/test/CodeGenObjC/nontrivial-c-struct-within-struct-name.m
Shoaib Meenai 155e26f0f4 [CodeGen] Add additional mangling for struct members of non trivial structs
In https://bugs.llvm.org/show_bug.cgi?id=41206 we observe bad codegen
when embedding a non-trivial C struct within a C struct. This is due to
the fact that name mangling for non-trivial structs marks the two
structs as identical. This diff contains a fix for this issue.

Patch by Dan Zimmerman <daniel.zimmerman@me.com>.

Differential Revision: https://reviews.llvm.org/D59873

llvm-svn: 357184
2019-03-28 17:01:20 +00:00

45 lines
1.3 KiB
Objective-C

// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -emit-llvm -o - %s | FileCheck %s
@class I;
typedef struct {
I *name;
} Foo;
typedef struct {
Foo foo;
} Bar;
typedef struct {
Bar bar;
} Baz;
I *getI();
void f() {
Foo foo = {getI()};
Bar bar = {foo};
Baz baz = {bar};
}
// CHECK: define linkonce_odr hidden void @__destructor_8_S_S_s0(i8** %[[DST:.*]])
// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
// CHECK: call void @__destructor_8_S_s0(i8** %[[V0]])
// CHECK: ret void
// CHECK: define linkonce_odr hidden void @__destructor_8_S_s0(i8** %[[DST:.*]])
// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
// CHECK: call void @__destructor_8_s0(i8** %[[V0]])
// CHECK: ret void
// CHECK: define linkonce_odr hidden void @__destructor_8_s0(i8** %dst)
// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
// CHECK: call void @llvm.objc.storeStrong(i8** %[[V0]], i8* null)
// CHECK: ret void