[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
// RUN: %clang_cc1 -triple=x86_64-linux-gnu -emit-llvm -fstrict-vtable-pointers -o - %s \
|
|
|
|
// RUN: | FileCheck --check-prefixes=CHECK,CHECK-STRICT %s
|
|
|
|
// RUN: %clang_cc1 -triple=x86_64-linux-gnu -emit-llvm -o - %s \
|
|
|
|
// RUN: | FileCheck --check-prefixes=CHECK,CHECK-NONSTRICT %s
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Positive Cases
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
struct TestVirtualFn {
|
|
|
|
virtual void foo() {}
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_virtual_fn
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_virtual_fn(TestVirtualFn *p) {
|
|
|
|
// CHECK: store [[TYPE:%[^ ]+]] %p, [[TYPE]]* %p.addr
|
|
|
|
// CHECK-NEXT: [[TMP0:%.*]] = load [[TYPE]], [[TYPE]]* %p.addr
|
|
|
|
|
|
|
|
// CHECK-NONSTRICT-NEXT: store [[TYPE]] [[TMP0]], [[TYPE]]* %d
|
|
|
|
|
|
|
|
// CHECK-STRICT-NEXT: [[TMP1:%.*]] = bitcast [[TYPE]] [[TMP0]] to i8*
|
|
|
|
// CHECK-STRICT-NEXT: [[TMP2:%.*]] = call i8* @llvm.launder.invariant.group.p0i8(i8* [[TMP1]])
|
|
|
|
// CHECK-STRICT-NEXT: [[TMP3:%.*]] = bitcast i8* [[TMP2]] to [[TYPE]]
|
|
|
|
// CHECK-STRICT-NEXT: store [[TYPE]] [[TMP3]], [[TYPE]]* %d
|
|
|
|
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
TestVirtualFn *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestPolyBase : TestVirtualFn {
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_poly_base
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_poly_base(TestPolyBase *p) {
|
|
|
|
// CHECK-STRICT-NOT: ret void
|
|
|
|
// CHECK-STRICT: @llvm.launder.invariant.group
|
|
|
|
|
|
|
|
// CHECK-NONSTRICT-NOT: @llvm.launder.invariant.group
|
|
|
|
|
|
|
|
// CHECK: ret void
|
|
|
|
TestPolyBase *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestBase {};
|
|
|
|
struct TestVirtualBase : virtual TestBase {};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_virtual_base
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_virtual_base(TestVirtualBase *p) {
|
|
|
|
// CHECK-STRICT-NOT: ret void
|
|
|
|
// CHECK-STRICT: @llvm.launder.invariant.group
|
|
|
|
|
|
|
|
// CHECK-NONSTRICT-NOT: @llvm.launder.invariant.group
|
|
|
|
|
|
|
|
// CHECK: ret void
|
|
|
|
TestVirtualBase *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Negative Cases
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_ommitted_one
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_ommitted_one(int *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NEXT: %p.addr = alloca i32*
|
|
|
|
// CHECK-NEXT: %d = alloca i32*
|
|
|
|
// CHECK-NEXT: store i32* %p, i32** %p.addr, align 8
|
|
|
|
// CHECK-NEXT: [[TMP:%.*]] = load i32*, i32** %p.addr
|
|
|
|
// CHECK-NEXT: store i32* [[TMP]], i32** %d
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
int *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestNoInvariant {
|
|
|
|
int x;
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_ommitted_two
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_ommitted_two(TestNoInvariant *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: llvm.launder.invariant.group
|
|
|
|
// CHECK-NEXT: %p.addr = alloca [[TYPE:%.*]], align 8
|
|
|
|
// CHECK-NEXT: %d = alloca [[TYPE]]
|
|
|
|
// CHECK-NEXT: store [[TYPE]] %p, [[TYPE]]* %p.addr
|
|
|
|
// CHECK-NEXT: [[TMP:%.*]] = load [[TYPE]], [[TYPE]]* %p.addr
|
|
|
|
// CHECK-NEXT: store [[TYPE]] [[TMP]], [[TYPE]]* %d
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
TestNoInvariant *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestVirtualMember {
|
|
|
|
TestVirtualFn member;
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_virtual_member
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_virtual_member(TestVirtualMember *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NONSTRICT-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK-STRICT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestVirtualMember *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestVirtualMemberDepth2 {
|
|
|
|
TestVirtualMember member;
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_virtual_member_depth_2
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_virtual_member_depth_2(TestVirtualMemberDepth2 *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NONSTRICT-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK-STRICT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestVirtualMemberDepth2 *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestVirtualReferenceMember {
|
|
|
|
TestVirtualFn &member;
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_virtual_reference_member
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_virtual_reference_member(TestVirtualReferenceMember *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestVirtualReferenceMember *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestRecursiveMember {
|
|
|
|
TestRecursiveMember() : member(*this) {}
|
|
|
|
TestRecursiveMember &member;
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_recursive_member
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_recursive_member(TestRecursiveMember *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestRecursiveMember *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestVirtualRecursiveMember {
|
|
|
|
TestVirtualRecursiveMember() : member(*this) {}
|
|
|
|
TestVirtualRecursiveMember &member;
|
|
|
|
virtual void foo();
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_virtual_recursive_member
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_virtual_recursive_member(TestVirtualRecursiveMember *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NONSTRICT-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK-STRICT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestVirtualRecursiveMember *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_array(
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_array(TestVirtualFn (&Arr)[5]) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NONSTRICT-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK-STRICT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestVirtualFn *d = __builtin_launder(Arr);
|
|
|
|
}
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_array_nested(
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_array_nested(TestVirtualFn (&Arr)[5][2]) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NONSTRICT-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK-STRICT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
using RetTy = TestVirtualFn(*)[2];
|
|
|
|
RetTy d = __builtin_launder(Arr);
|
|
|
|
}
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_array_no_invariant(
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_array_no_invariant(TestNoInvariant (&Arr)[5]) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestNoInvariant *d = __builtin_launder(Arr);
|
|
|
|
}
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_array_nested_no_invariant(
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_array_nested_no_invariant(TestNoInvariant (&Arr)[5][2]) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
using RetTy = TestNoInvariant(*)[2];
|
|
|
|
RetTy d = __builtin_launder(Arr);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Member>
|
|
|
|
struct WithMember {
|
|
|
|
Member mem;
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct WithMember<TestVirtualFn[5]>;
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_member_array(
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_member_array(WithMember<TestVirtualFn[5]> *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NONSTRICT-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK-STRICT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
auto *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
template struct WithMember<TestVirtualFn[5][2]>;
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_member_array_nested(
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_member_array_nested(WithMember<TestVirtualFn[5][2]> *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NONSTRICT-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK-STRICT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
auto *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
template struct WithMember<TestNoInvariant[5]>;
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_member_array_no_invariant(
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_member_array_no_invariant(WithMember<TestNoInvariant[5]> *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
auto *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
template struct WithMember<TestNoInvariant[5][2]>;
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_member_array_nested_no_invariant(
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_member_array_nested_no_invariant(WithMember<TestNoInvariant[5][2]> *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
auto *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
struct WithBase : T {};
|
|
|
|
|
|
|
|
template struct WithBase<TestNoInvariant>;
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_base_no_invariant(
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_base_no_invariant(WithBase<TestNoInvariant> *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
auto *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
template struct WithBase<TestVirtualFn>;
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_base(
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_base(WithBase<TestVirtualFn> *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NONSTRICT-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK-STRICT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
auto *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// The test cases in this namespace technically need to be laundered according
|
|
|
|
/// to the language in the standard (ie they have const or reference subobjects)
|
|
|
|
/// but LLVM doesn't currently optimize on these cases -- so Clang emits
|
|
|
|
/// __builtin_launder as a nop.
|
|
|
|
///
|
|
|
|
/// NOTE: Adding optimizations for these cases later is an LTO ABI break. That's
|
|
|
|
/// probably OK for now -- but is something to keep in mind.
|
|
|
|
namespace pessimizing_cases {
|
|
|
|
|
|
|
|
struct TestConstMember {
|
|
|
|
const int x;
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_const_member
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_const_member(TestConstMember *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestConstMember *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestConstSubobject {
|
|
|
|
TestConstMember x;
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_const_subobject
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_const_subobject(TestConstSubobject *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestConstSubobject *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestConstObject {
|
|
|
|
const struct TestConstMember x;
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_const_object
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_const_object(TestConstObject *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestConstObject *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestReferenceMember {
|
|
|
|
int &x;
|
|
|
|
};
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test_builtin_launder_reference_member
|
[Clang] Add __builtin_launder
Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.
I'm not exactly sure what magic `__builtin_launder` requires, but based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.
Reviewers: rnk, majnemer, rsmith
Reviewed By: rsmith
Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40218
llvm-svn: 349195
2018-12-15 05:11:28 +08:00
|
|
|
extern "C" void test_builtin_launder_reference_member(TestReferenceMember *p) {
|
|
|
|
// CHECK: entry
|
|
|
|
// CHECK-NOT: @llvm.launder.invariant.group
|
|
|
|
// CHECK: ret void
|
|
|
|
TestReferenceMember *d = __builtin_launder(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace pessimizing_cases
|