2019-09-07 06:55:26 +08:00
|
|
|
// Sparc64 doesn't support musttail (yet), so it uses method cloning for
|
|
|
|
// variadic thunks. Use it for testing.
|
|
|
|
// RUN: %clang_cc1 %s -triple=sparc64-pc-linux-gnu -munwind-tables -emit-llvm -o - \
|
|
|
|
// RUN: | FileCheck --check-prefixes=CHECK,CHECK-CLONE,CHECK-NONOPT %s
|
|
|
|
// RUN: %clang_cc1 %s -triple=sparc64-pc-linux-gnu -debug-info-kind=standalone -dwarf-version=5 -munwind-tables -emit-llvm -o - \
|
|
|
|
// RUN: | FileCheck --check-prefixes=CHECK,CHECK-CLONE,CHECK-NONOPT,CHECK-DBG %s
|
|
|
|
// RUN: %clang_cc1 %s -triple=sparc64-pc-linux-gnu -munwind-tables -emit-llvm -o - -O1 -disable-llvm-passes \
|
|
|
|
// RUN: | FileCheck --check-prefixes=CHECK,CHECK-CLONE,CHECK-OPT %s
|
|
|
|
|
|
|
|
// Test x86_64, which uses musttail for variadic thunks.
|
|
|
|
// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - -O1 -disable-llvm-passes \
|
|
|
|
// RUN: | FileCheck --check-prefixes=CHECK,CHECK-TAIL,CHECK-OPT %s
|
|
|
|
|
|
|
|
// Finally, reuse these tests for the MS ABI.
|
|
|
|
// RUN: %clang_cc1 %s -triple=x86_64-windows-msvc -munwind-tables -emit-llvm -o - -O1 -disable-llvm-passes \
|
|
|
|
// RUN: | FileCheck --check-prefixes=WIN64 %s
|
|
|
|
|
2010-03-24 08:41:37 +08:00
|
|
|
|
|
|
|
namespace Test1 {
|
|
|
|
|
|
|
|
// Check that we emit a non-virtual thunk for C::f.
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B {
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct C : A, B {
|
|
|
|
virtual void c();
|
2020-09-29 16:24:54 +08:00
|
|
|
|
2010-03-24 08:41:37 +08:00
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define void @_ZThn8_N5Test11C1fEv(
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
|
|
|
// CHECK: ret void
|
2019-09-07 06:55:26 +08:00
|
|
|
//
|
|
|
|
// WIN64-LABEL: define dso_local void @"?f@C@Test1@@UEAAXXZ"(
|
|
|
|
// WIN64-LABEL: define linkonce_odr dso_local void @"?f@C@Test1@@W7EAAXXZ"(
|
|
|
|
// WIN64: getelementptr i8, i8* {{.*}}, i32 -8
|
|
|
|
// WIN64: ret void
|
2010-03-24 08:41:37 +08:00
|
|
|
void C::f() { }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Test2 {
|
|
|
|
|
|
|
|
// Check that we emit a thunk for B::f since it's overriding a virtual base.
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B : virtual A {
|
|
|
|
virtual void b();
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define void @_ZTv0_n24_N5Test21B1fEv(
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
|
|
|
// CHECK: ret void
|
2010-03-24 08:41:37 +08:00
|
|
|
void B::f() { }
|
|
|
|
|
2019-09-07 06:55:26 +08:00
|
|
|
// No thunk is used for this case in the MS ABI.
|
|
|
|
// WIN64-LABEL: define dso_local void @"?f@B@Test2@@UEAAXXZ"(
|
|
|
|
// WIN64-NOT: define {{.*}} void @"?f@B@Test2
|
|
|
|
|
2010-03-24 08:41:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Test3 {
|
|
|
|
|
|
|
|
// Check that we emit a covariant thunk for B::f.
|
|
|
|
|
|
|
|
struct V1 { };
|
|
|
|
struct V2 : virtual V1 { };
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
virtual V1 *f();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B : A {
|
|
|
|
virtual void b();
|
2020-09-29 16:24:54 +08:00
|
|
|
|
2010-03-24 08:41:37 +08:00
|
|
|
virtual V2 *f();
|
|
|
|
};
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define %{{.*}}* @_ZTch0_v0_n24_N5Test31B1fEv(
|
2019-09-07 06:55:26 +08:00
|
|
|
// WIN64: define weak_odr dso_local %{{.*}} @"?f@B@Test3@@QEAAPEAUV1@2@XZ"(
|
2010-03-24 08:41:37 +08:00
|
|
|
V2 *B::f() { return 0; }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Test4 {
|
|
|
|
|
|
|
|
// Check that the thunk for 'C::f' has the same visibility as the function itself.
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B {
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct __attribute__((visibility("protected"))) C : A, B {
|
|
|
|
virtual void c();
|
2020-09-29 16:24:54 +08:00
|
|
|
|
2010-03-24 08:41:37 +08:00
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define protected void @_ZThn8_N5Test41C1fEv(
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
|
|
|
// CHECK: ret void
|
2010-03-24 08:41:37 +08:00
|
|
|
void C::f() { }
|
|
|
|
|
2019-09-07 06:55:26 +08:00
|
|
|
// Visibility doesn't matter on COFF, but whatever. We could add an ELF test
|
|
|
|
// mode later.
|
|
|
|
// WIN64-LABEL: define protected void @"?f@C@Test4@@UEAAXXZ"(
|
|
|
|
// WIN64-LABEL: define linkonce_odr protected void @"?f@C@Test4@@W7EAAXXZ"(
|
2010-03-24 08:41:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check that the thunk gets internal linkage.
|
2011-02-19 10:53:41 +08:00
|
|
|
namespace Test4B {
|
|
|
|
struct A {
|
|
|
|
virtual void f();
|
|
|
|
};
|
2010-03-24 08:41:37 +08:00
|
|
|
|
2011-02-19 10:53:41 +08:00
|
|
|
struct B {
|
|
|
|
virtual void f();
|
|
|
|
};
|
2010-03-24 08:41:37 +08:00
|
|
|
|
2011-02-19 10:53:41 +08:00
|
|
|
namespace {
|
|
|
|
struct C : A, B {
|
|
|
|
virtual void c();
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
void C::c() {}
|
|
|
|
void C::f() {}
|
2010-03-24 08:41:37 +08:00
|
|
|
|
2011-02-19 10:53:41 +08:00
|
|
|
// Force C::f to be used.
|
2020-09-29 16:24:54 +08:00
|
|
|
void f() {
|
|
|
|
C c;
|
2011-02-19 10:53:41 +08:00
|
|
|
c.f();
|
|
|
|
}
|
2010-03-24 08:41:37 +08:00
|
|
|
}
|
2019-09-07 06:55:26 +08:00
|
|
|
// Not sure why this isn't delayed like in Itanium.
|
2019-09-07 08:41:08 +08:00
|
|
|
// WIN64-LABEL: define internal void @"?f@C@?A{{.*}}@Test4B@@UEAAXXZ"(
|
2010-03-28 04:50:27 +08:00
|
|
|
|
|
|
|
namespace Test5 {
|
|
|
|
|
|
|
|
// Check that the thunk for 'B::f' gets the same linkage as the function itself.
|
|
|
|
struct A {
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B : virtual A {
|
|
|
|
virtual void f() { }
|
|
|
|
};
|
|
|
|
|
|
|
|
void f(B b) {
|
|
|
|
b.f();
|
|
|
|
}
|
2019-09-07 06:55:26 +08:00
|
|
|
// No thunk in MS ABI in this case.
|
2010-03-28 04:50:27 +08:00
|
|
|
}
|
|
|
|
|
2010-05-20 13:54:35 +08:00
|
|
|
namespace Test6 {
|
|
|
|
struct X {
|
|
|
|
X();
|
|
|
|
X(const X&);
|
|
|
|
X &operator=(const X&);
|
|
|
|
~X();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct P {
|
|
|
|
P();
|
|
|
|
P(const P&);
|
|
|
|
~P();
|
|
|
|
X first;
|
|
|
|
X second;
|
|
|
|
};
|
|
|
|
|
|
|
|
P getP();
|
|
|
|
|
|
|
|
struct Base1 {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
virtual X f() { return X(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Base2 {
|
|
|
|
float real;
|
2010-03-28 04:50:27 +08:00
|
|
|
|
2010-05-20 13:54:35 +08:00
|
|
|
virtual X f() { return X(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Thunks : Base1, Base2 {
|
|
|
|
long l;
|
|
|
|
|
|
|
|
virtual X f();
|
|
|
|
};
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define void @_ZThn16_N5Test66Thunks1fEv
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
2010-05-20 13:54:35 +08:00
|
|
|
// CHECK-NOT: memcpy
|
2020-09-29 16:24:54 +08:00
|
|
|
// CHECK: {{call void @_ZN5Test66Thunks1fEv.*sret align 1}}
|
2010-05-20 13:54:35 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
X Thunks::f() { return X(); }
|
2019-09-07 06:55:26 +08:00
|
|
|
|
2020-09-29 16:24:54 +08:00
|
|
|
// WIN64-LABEL: define linkonce_odr dso_local void @"?f@Thunks@Test6@@WBA@EAA?AUX@2@XZ"({{.*}} sret align 1 %{{.*}})
|
2019-09-07 06:55:26 +08:00
|
|
|
// WIN64-NOT: memcpy
|
2020-09-29 16:24:54 +08:00
|
|
|
// WIN64: tail call void @"?f@Thunks@Test6@@UEAA?AUX@2@XZ"({{.*}} sret align 1 %{{.*}})
|
2010-05-20 13:54:35 +08:00
|
|
|
}
|
|
|
|
|
2010-05-22 01:55:12 +08:00
|
|
|
namespace Test7 {
|
|
|
|
// PR7188
|
|
|
|
struct X {
|
|
|
|
X();
|
|
|
|
X(const X&);
|
|
|
|
X &operator=(const X&);
|
|
|
|
~X();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Small { short s; };
|
|
|
|
struct Large {
|
|
|
|
char array[1024];
|
|
|
|
};
|
|
|
|
|
|
|
|
class A {
|
|
|
|
protected:
|
|
|
|
virtual void foo() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class B : public A {
|
|
|
|
protected:
|
|
|
|
virtual void bar() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class C : public A {
|
|
|
|
protected:
|
|
|
|
virtual void baz(X, X&, _Complex float, Small, Small&, Large) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class D : public B,
|
|
|
|
public C {
|
|
|
|
|
|
|
|
void foo() {}
|
|
|
|
void bar() {}
|
|
|
|
void baz(X, X&, _Complex float, Small, Small&, Large);
|
|
|
|
};
|
|
|
|
|
|
|
|
void D::baz(X, X&, _Complex float, Small, Small&, Large) { }
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define void @_ZThn8_N5Test71D3bazENS_1XERS1_CfNS_5SmallERS4_NS_5LargeE(
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
2010-05-22 01:55:12 +08:00
|
|
|
// CHECK-NOT: memcpy
|
|
|
|
// CHECK: ret void
|
|
|
|
void testD() { D d; }
|
2019-09-07 06:55:26 +08:00
|
|
|
|
|
|
|
// MS C++ ABI doesn't use a thunk, so this case isn't interesting.
|
2010-05-22 01:55:12 +08:00
|
|
|
}
|
|
|
|
|
2010-05-27 06:34:26 +08:00
|
|
|
namespace Test8 {
|
|
|
|
struct NonPOD { ~NonPOD(); int x, y, z; };
|
|
|
|
struct A { virtual void foo(); };
|
|
|
|
struct B { virtual void bar(NonPOD); };
|
|
|
|
struct C : A, B { virtual void bar(NonPOD); static void helper(NonPOD); };
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @_ZN5Test81C6helperENS_6NonPODE([[NONPODTYPE:%.*]]*
|
2010-05-27 06:34:26 +08:00
|
|
|
void C::helper(NonPOD var) {}
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define void @_ZThn8_N5Test81C3barENS_6NonPODE(
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NOT: load [[NONPODTYPE]], [[NONPODTYPE]]*
|
2010-05-27 06:34:26 +08:00
|
|
|
// CHECK-NOT: memcpy
|
|
|
|
// CHECK: ret void
|
|
|
|
void C::bar(NonPOD var) {}
|
2019-09-07 06:55:26 +08:00
|
|
|
|
|
|
|
// MS C++ ABI doesn't use a thunk, so this case isn't interesting.
|
2010-05-27 06:34:26 +08:00
|
|
|
}
|
|
|
|
|
2010-06-03 05:22:02 +08:00
|
|
|
// PR7241: Emitting thunks for a method shouldn't require the vtable for
|
|
|
|
// that class to be emitted.
|
|
|
|
namespace Test9 {
|
|
|
|
struct A { virtual ~A() { } };
|
|
|
|
struct B : A { virtual void test() const {} };
|
|
|
|
struct C : B { C(); ~C(); };
|
|
|
|
struct D : C { D() {} };
|
|
|
|
void test() {
|
|
|
|
D d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-05 07:46:35 +08:00
|
|
|
namespace Test10 {
|
|
|
|
struct A { virtual void foo(); };
|
|
|
|
struct B { virtual void foo(); };
|
|
|
|
struct C : A, B { void foo() {} };
|
|
|
|
|
2014-02-08 08:41:16 +08:00
|
|
|
// Test later.
|
2010-08-05 07:46:35 +08:00
|
|
|
void test() {
|
|
|
|
C c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-09 09:18:05 +08:00
|
|
|
// PR7611
|
|
|
|
namespace Test11 {
|
|
|
|
struct A { virtual A* f(); };
|
|
|
|
struct B : virtual A { virtual A* f(); };
|
|
|
|
struct C : B { virtual C* f(); };
|
|
|
|
C* C::f() { return 0; }
|
|
|
|
|
2011-05-07 01:27:27 +08:00
|
|
|
// C::f itself.
|
|
|
|
// CHECK: define {{.*}} @_ZN6Test111C1fEv(
|
|
|
|
|
2010-11-09 09:18:05 +08:00
|
|
|
// The this-adjustment and return-adjustment thunk required when
|
|
|
|
// C::f appears in a vtable where A is at a nonzero offset from C.
|
|
|
|
// CHECK: define {{.*}} @_ZTcv0_n24_v0_n32_N6Test111C1fEv(
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
|
|
|
// CHECK: ret
|
2010-11-09 09:18:05 +08:00
|
|
|
|
|
|
|
// The return-adjustment thunk required when C::f appears in a vtable
|
|
|
|
// where A is at a zero offset from C.
|
|
|
|
// CHECK: define {{.*}} @_ZTch0_v0_n32_N6Test111C1fEv(
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
|
|
|
// CHECK: ret
|
2019-09-07 06:55:26 +08:00
|
|
|
|
|
|
|
// WIN64-LABEL: define dso_local %{{.*}}* @"?f@C@Test11@@UEAAPEAU12@XZ"(i8*
|
|
|
|
|
|
|
|
// WIN64-LABEL: define weak_odr dso_local %{{.*}}* @"?f@C@Test11@@QEAAPEAUA@2@XZ"(i8*
|
|
|
|
// WIN64: call %{{.*}}* @"?f@C@Test11@@UEAAPEAU12@XZ"(i8* %{{.*}})
|
|
|
|
//
|
|
|
|
// Match the vbtable return adjustment.
|
|
|
|
// WIN64: load i32*, i32** %{{[^,]*}}, align 8
|
|
|
|
// WIN64: getelementptr inbounds i32, i32* %{{[^,]*}}, i32 1
|
|
|
|
// WIN64: load i32, i32* %{{[^,]*}}, align 4
|
2010-11-09 09:18:05 +08:00
|
|
|
}
|
|
|
|
|
2011-05-07 01:27:27 +08:00
|
|
|
// Varargs thunk test.
|
|
|
|
namespace Test12 {
|
|
|
|
struct A {
|
|
|
|
virtual A* f(int x, ...);
|
|
|
|
};
|
|
|
|
struct B {
|
|
|
|
virtual B* f(int x, ...);
|
|
|
|
};
|
|
|
|
struct C : A, B {
|
|
|
|
virtual void c();
|
|
|
|
virtual C* f(int x, ...);
|
|
|
|
};
|
2019-09-07 06:55:26 +08:00
|
|
|
C* makeC();
|
|
|
|
C* C::f(int x, ...) { return makeC(); }
|
2011-05-07 01:27:27 +08:00
|
|
|
|
|
|
|
// C::f
|
|
|
|
// CHECK: define {{.*}} @_ZN6Test121C1fEiz
|
|
|
|
|
|
|
|
// Varargs thunk; check that both the this and covariant adjustments
|
|
|
|
// are generated.
|
|
|
|
// CHECK: define {{.*}} @_ZTchn8_h8_N6Test121C1fEiz
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 -8
|
|
|
|
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 8
|
2019-09-07 06:55:26 +08:00
|
|
|
|
|
|
|
// The vtable layout goes:
|
|
|
|
// C vtable in A:
|
|
|
|
// - f impl, no adjustment
|
|
|
|
// C vtable in B:
|
|
|
|
// - f thunk 2, covariant, clone
|
|
|
|
// - f thunk 2, musttail this adjust to impl
|
|
|
|
// FIXME: The weak_odr linkage is probably not necessary and just an artifact
|
|
|
|
// of Itanium ABI details.
|
|
|
|
// WIN64-LABEL: define dso_local {{.*}} @"?f@C@Test12@@UEAAPEAU12@HZZ"(
|
|
|
|
// WIN64: call %{{.*}}* @"?makeC@Test12@@YAPEAUC@1@XZ"()
|
|
|
|
//
|
|
|
|
// This thunk needs return adjustment, clone.
|
|
|
|
// WIN64-LABEL: define weak_odr dso_local {{.*}} @"?f@C@Test12@@W7EAAPEAUB@2@HZZ"(
|
|
|
|
// WIN64: call %{{.*}}* @"?makeC@Test12@@YAPEAUC@1@XZ"()
|
|
|
|
// WIN64: getelementptr inbounds i8, i8* %{{.*}}, i32 8
|
|
|
|
//
|
|
|
|
// Musttail call back to the A implementation after this adjustment from B to A.
|
|
|
|
// WIN64-LABEL: define linkonce_odr dso_local %{{.*}}* @"?f@C@Test12@@W7EAAPEAU12@HZZ"(
|
|
|
|
// WIN64: getelementptr i8, i8* %{{[^,]*}}, i32 -8
|
|
|
|
// WIN64: musttail call {{.*}} @"?f@C@Test12@@UEAAPEAU12@HZZ"(
|
|
|
|
C c;
|
2011-05-07 01:27:27 +08:00
|
|
|
}
|
|
|
|
|
2012-09-14 09:45:09 +08:00
|
|
|
// PR13832
|
|
|
|
namespace Test13 {
|
|
|
|
struct B1 {
|
|
|
|
virtual B1 &foo1();
|
|
|
|
};
|
|
|
|
struct Pad1 {
|
|
|
|
virtual ~Pad1();
|
|
|
|
};
|
|
|
|
struct Proxy1 : Pad1, B1 {
|
|
|
|
virtual ~Proxy1();
|
|
|
|
};
|
|
|
|
struct D : virtual Proxy1 {
|
|
|
|
virtual ~D();
|
|
|
|
virtual D &foo1();
|
|
|
|
};
|
|
|
|
D& D::foo1() {
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
// CHECK: define {{.*}} @_ZTcvn8_n32_v8_n24_N6Test131D4foo1Ev
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 -8
|
|
|
|
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 -32
|
|
|
|
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 -24
|
|
|
|
// CHECK: getelementptr inbounds i8, i8* {{.*}}, i64 8
|
2012-09-14 09:45:09 +08:00
|
|
|
// CHECK: ret %"struct.Test13::D"*
|
2019-09-07 06:55:26 +08:00
|
|
|
|
2020-05-19 02:29:11 +08:00
|
|
|
// WIN64-LABEL: define weak_odr dso_local nonnull align 8 dereferenceable(8) %"struct.Test13::D"* @"?foo1@D@Test13@@$4PPPPPPPE@A@EAAAEAUB1@2@XZ"(
|
2019-09-07 06:55:26 +08:00
|
|
|
// This adjustment.
|
|
|
|
// WIN64: getelementptr inbounds i8, i8* {{.*}}, i64 -12
|
|
|
|
// Call implementation.
|
|
|
|
// WIN64: call {{.*}} @"?foo1@D@Test13@@UEAAAEAU12@XZ"(i8* {{.*}})
|
|
|
|
// Virtual + nonvirtual return adjustment.
|
|
|
|
// WIN64: load i32*, i32** %{{[^,]*}}, align 8
|
|
|
|
// WIN64: getelementptr inbounds i32, i32* %{{[^,]*}}, i32 1
|
|
|
|
// WIN64: load i32, i32* %{{[^,]*}}, align 4
|
|
|
|
// WIN64: getelementptr inbounds i8, i8* %{{[^,]*}}, i32 %{{[^,]*}}
|
2012-09-14 09:45:09 +08:00
|
|
|
}
|
|
|
|
|
2012-09-22 04:39:32 +08:00
|
|
|
namespace Test14 {
|
|
|
|
class A {
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
class B {
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
class C : public A, public B {
|
|
|
|
virtual void f();
|
|
|
|
};
|
|
|
|
void C::f() {
|
|
|
|
}
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @_ZThn8_N6Test141C1fEv({{.*}}) unnamed_addr [[NUW:#[0-9]+]]
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
|
|
|
// CHECK: ret void
|
2012-09-22 04:39:32 +08:00
|
|
|
}
|
|
|
|
|
2013-12-08 00:12:52 +08:00
|
|
|
// Varargs non-covariant thunk test.
|
|
|
|
// PR18098
|
|
|
|
namespace Test15 {
|
|
|
|
struct A {
|
|
|
|
virtual ~A();
|
|
|
|
};
|
|
|
|
struct B {
|
|
|
|
virtual void f(int x, ...);
|
|
|
|
};
|
|
|
|
struct C : A, B {
|
|
|
|
virtual void c();
|
|
|
|
virtual void f(int x, ...);
|
|
|
|
};
|
|
|
|
void C::c() {}
|
|
|
|
|
|
|
|
// C::c
|
2019-09-07 06:55:26 +08:00
|
|
|
// CHECK-CLONE: declare void @_ZN6Test151C1fEiz
|
2013-12-08 00:12:52 +08:00
|
|
|
// non-virtual thunk to C::f
|
2019-09-07 06:55:26 +08:00
|
|
|
// CHECK-CLONE: declare void @_ZThn8_N6Test151C1fEiz
|
|
|
|
|
|
|
|
// If we have musttail, then we emit the thunk as available_externally.
|
|
|
|
// CHECK-TAIL: declare void @_ZN6Test151C1fEiz
|
|
|
|
// CHECK-TAIL: define available_externally void @_ZThn8_N6Test151C1fEiz({{.*}})
|
|
|
|
// CHECK-TAIL: musttail call void (%"struct.Test15::C"*, i32, ...) @_ZN6Test151C1fEiz({{.*}}, ...)
|
|
|
|
|
|
|
|
// MS C++ ABI doesn't use a thunk, so this case isn't interesting.
|
2013-12-08 00:12:52 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 22:48:06 +08:00
|
|
|
namespace Test16 {
|
|
|
|
struct A {
|
|
|
|
virtual ~A();
|
|
|
|
};
|
|
|
|
struct B {
|
|
|
|
virtual void foo();
|
|
|
|
};
|
|
|
|
struct C : public A, public B {
|
|
|
|
void foo() {}
|
|
|
|
};
|
|
|
|
struct D : public C {
|
|
|
|
~D();
|
|
|
|
};
|
|
|
|
D::~D() {}
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define linkonce_odr void @_ZThn8_N6Test161C3fooEv({{.*}}) {{.*}} comdat
|
2019-07-30 06:49:55 +08:00
|
|
|
// CHECK-DBG-NOT: dbg.declare
|
|
|
|
// CHECK: ret void
|
2015-07-15 22:48:06 +08:00
|
|
|
}
|
|
|
|
|
2019-09-07 06:55:26 +08:00
|
|
|
namespace Test17 {
|
|
|
|
class A {
|
|
|
|
virtual void f(const char *, ...);
|
|
|
|
};
|
|
|
|
class B {
|
|
|
|
virtual void f(const char *, ...);
|
|
|
|
};
|
|
|
|
class C : A, B {
|
|
|
|
virtual void anchor();
|
|
|
|
void f(const char *, ...) override;
|
|
|
|
};
|
|
|
|
// Key method and object anchor vtable for Itanium and MSVC.
|
|
|
|
void C::anchor() {}
|
|
|
|
C c;
|
|
|
|
|
|
|
|
// CHECK-CLONE-LABEL: declare void @_ZThn8_N6Test171C1fEPKcz(
|
|
|
|
|
|
|
|
// CHECK-TAIL-LABEL: define available_externally void @_ZThn8_N6Test171C1fEPKcz(
|
|
|
|
// CHECK-TAIL: getelementptr inbounds i8, i8* %{{.*}}, i64 -8
|
|
|
|
// CHECK-TAIL: musttail call {{.*}} @_ZN6Test171C1fEPKcz({{.*}}, ...)
|
|
|
|
|
|
|
|
// MSVC-LABEL: define linkonce_odr dso_local void @"?f@C@Test17@@G7EAAXPEBDZZ"
|
|
|
|
// MSVC-SAME: (%"class.Test17::C"* %this, i8* %[[ARG:[^,]+]], ...)
|
|
|
|
// MSVC: getelementptr i8, i8* %{{.*}}, i32 -8
|
|
|
|
// MSVC: musttail call void (%"class.Test17::C"*, i8*, ...) @"?f@C@Test17@@EEAAXPEBDZZ"(%"class.Test17::C"* %{{.*}}, i8* %[[ARG]], ...)
|
|
|
|
}
|
|
|
|
|
2010-05-27 06:34:26 +08:00
|
|
|
/**** The following has to go at the end of the file ****/
|
|
|
|
|
2015-09-15 08:37:06 +08:00
|
|
|
// checking without opt
|
|
|
|
// CHECK-NONOPT-LABEL: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv(
|
|
|
|
// CHECK-NONOPT-NOT: comdat
|
|
|
|
|
|
|
|
// This is from Test5:
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-NONOPT-LABEL: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv
|
2015-09-15 08:37:06 +08:00
|
|
|
|
|
|
|
// This is from Test10:
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-NONOPT-LABEL: define linkonce_odr void @_ZN6Test101C3fooEv
|
|
|
|
// CHECK-NONOPT-LABEL: define linkonce_odr void @_ZThn8_N6Test101C3fooEv
|
2015-09-15 08:37:06 +08:00
|
|
|
|
|
|
|
// Checking with opt
|
|
|
|
// CHECK-OPT-LABEL: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv(%"struct.Test4B::(anonymous namespace)::C"* %this) unnamed_addr #0 align 2
|
|
|
|
|
2015-08-28 05:35:41 +08:00
|
|
|
// This is from Test5:
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-OPT-LABEL: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv
|
2015-08-28 05:35:41 +08:00
|
|
|
|
2014-02-08 08:41:16 +08:00
|
|
|
// This is from Test10:
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-OPT-LABEL: define linkonce_odr void @_ZN6Test101C3fooEv
|
|
|
|
// CHECK-OPT-LABEL: define linkonce_odr void @_ZThn8_N6Test101C3fooEv
|
2014-02-08 08:41:16 +08:00
|
|
|
|
2019-09-07 06:55:26 +08:00
|
|
|
// This is from Test10:
|
|
|
|
// WIN64-LABEL: define linkonce_odr dso_local void @"?foo@C@Test10@@UEAAXXZ"(
|
|
|
|
// WIN64-LABEL: define linkonce_odr dso_local void @"?foo@C@Test10@@W7EAAXXZ"(
|
|
|
|
|
2017-05-29 13:38:20 +08:00
|
|
|
// CHECK-NONOPT: attributes [[NUW]] = { noinline nounwind optnone uwtable{{.*}} }
|
Cleanup the handling of noinline function attributes, -fno-inline,
-fno-inline-functions, -O0, and optnone.
These were really, really tangled together:
- We used the noinline LLVM attribute for -fno-inline
- But not for -fno-inline-functions (breaking LTO)
- But we did use it for -finline-hint-functions (yay, LTO is happy!)
- But we didn't for -O0 (LTO is sad yet again...)
- We had weird structuring of CodeGenOpts with both an inlining
enumeration and a boolean. They interacted in weird ways and
needlessly.
- A *lot* of set smashing went on with setting these, and then got worse
when we considered optnone and other inlining-effecting attributes.
- A bunch of inline affecting attributes were managed in a completely
different place from -fno-inline.
- Even with -fno-inline we failed to put the LLVM noinline attribute
onto many generated function definitions because they didn't show up
as AST-level functions.
- If you passed -O0 but -finline-functions we would run the normal
inliner pass in LLVM despite it being in the O0 pipeline, which really
doesn't make much sense.
- Lastly, we used things like '-fno-inline' to manipulate the pass
pipeline which forced the pass pipeline to be much more
parameterizable than it really needs to be. Instead we can *just* use
the optimization level to select a pipeline and control the rest via
attributes.
Sadly, this causes a bunch of churn in tests because we don't run the
optimizer in the tests and check the contents of attribute sets. It
would be awesome if attribute sets were a bit more FileCheck friendly,
but oh well.
I think this is a significant improvement and should remove the semantic
need to change what inliner pass we run in order to comply with the
requested inlining semantics by relying completely on attributes. It
also cleans up tho optnone and related handling a bit.
One unfortunate aspect of this is that for generating alwaysinline
routines like those in OpenMP we end up removing noinline and then
adding alwaysinline. I tried a bunch of other approaches, but because we
recompute function attributes from scratch and don't have a declaration
here I couldn't find anything substantially cleaner than this.
Differential Revision: https://reviews.llvm.org/D28053
llvm-svn: 290398
2016-12-23 09:24:49 +08:00
|
|
|
// CHECK-OPT: attributes [[NUW]] = { nounwind uwtable{{.*}} }
|