| 1 |
// RUN: %clang_cc1 -emit-llvm -fms-extensions %s -triple=x86_64-pc-windows-msvc -o - | FileCheck --check-prefixes=CHECK,X64 %s |
| 2 |
// RUN: %clang_cc1 -emit-llvm -fms-extensions %s -triple=i386-pc-windows-msvc -o - | FileCheck --check-prefixes=CHECK,X86 %s |
| 3 |
|
| 4 |
struct Base { |
| 5 |
virtual ~Base() {} |
| 6 |
}; |
| 7 |
|
| 8 |
struct A final : Base { |
| 9 |
virtual ~A(); |
| 10 |
}; |
| 11 |
|
| 12 |
struct B : Base { virtual ~B() final {} }; |
| 13 |
|
| 14 |
struct D { virtual ~D() final = 0; }; |
| 15 |
|
| 16 |
void case1(A *arg) { |
| 17 |
delete[] arg; |
| 18 |
} |
| 19 |
// X64-LABEL: define {{.*}} void @"?case1@@YAXPEAUA@@@Z" |
| 20 |
// X64-SAME: (ptr noundef %[[ARG:.*]]) |
| 21 |
// X86-LABEL: define {{.*}} void @"?case1@@YAXPAUA@@@Z" |
| 22 |
// X86-SAME: (ptr noundef %[[ARG:.*]]) |
| 23 |
// CHECK: entry: |
| 24 |
// CHECK-NEXT: %[[ARGADDR:.*]] = alloca ptr |
| 25 |
// CHECK-NEXT: store ptr %[[ARG]], ptr %[[ARGADDR]], |
| 26 |
// CHECK-NEXT: %[[ARR:.*]] = load ptr, ptr %[[ARGADDR]] |
| 27 |
// CHECK-NEXT: %[[ISNULL:.*]] = icmp eq ptr %[[ARR]], null |
| 28 |
// CHECK-NEXT: br i1 %[[ISNULL]], label %delete.end2, label %delete.notnull |
| 29 |
// CHECK: delete.notnull: |
| 30 |
// X64-NEXT: %[[COOKIEADDR:.*]] = getelementptr inbounds i8, ptr %[[ARR]], i64 -8 |
| 31 |
// X86-NEXT: %[[COOKIEADDR:.*]] = getelementptr inbounds i8, ptr %0, i32 -4 |
| 32 |
// X64-NEXT: %[[COOKIE:.*]] = load i64, ptr %[[COOKIEADDR]] |
| 33 |
// X86-NEXT: %[[COOKIE:.*]] = load i32, ptr %[[COOKIEADDR]] |
| 34 |
// X64-NEXT: %[[END:.*]] = getelementptr inbounds %struct.A, ptr %[[ARR]], i64 %[[COOKIE]] |
| 35 |
// X86-NEXT: %[[END:.*]] = getelementptr inbounds %struct.A, ptr %[[ARR]], i32 %[[COOKIE]] |
| 36 |
// CHECK-NEXT: %[[ISEMPTY:.*]] = icmp eq ptr %[[ARR]], %[[END]] |
| 37 |
// CHECK-NEXT: br i1 %arraydestroy.isempty, label %arraydestroy.done1, label %arraydestroy.body |
| 38 |
// CHECK: arraydestroy.body: |
| 39 |
// CHECK-NEXT: %arraydestroy.elementPast = phi ptr [ %delete.end, %delete.notnull ], [ %arraydestroy.element, %arraydestroy.body ] |
| 40 |
// X64-NEXT: %arraydestroy.element = getelementptr inbounds %struct.A, ptr %arraydestroy.elementPast, i64 -1 |
| 41 |
// X86-NEXT: %arraydestroy.element = getelementptr inbounds %struct.A, ptr %arraydestroy.elementPast, i32 -1 |
| 42 |
// X64-NEXT: call void @"??1A@@UEAA@XZ"(ptr noundef nonnull align 8 dereferenceable(8) %arraydestroy.element) |
| 43 |
// X86-NEXT: call x86_thiscallcc void @"??1A@@UAE@XZ"(ptr noundef nonnull align 4 dereferenceable(4) %arraydestroy.element) |
| 44 |
// CHECK-NEXT: %arraydestroy.done = icmp eq ptr %arraydestroy.element, %0 |
| 45 |
// CHECK-NEXT: br i1 %arraydestroy.done, label %arraydestroy.done1, label %arraydestroy.body |
| 46 |
// CHECK: arraydestroy.done1: |
| 47 |
// X64-NEXT: %[[HOWMANYELEMS:.*]] = mul i64 8, %[[COOKIE]] |
| 48 |
// X86-NEXT: %[[HOWMANYELEMS:.*]] = mul i32 4, %[[COOKIE]] |
| 49 |
// X64-NEXT: %[[SIZEPLUSCOOKIE:.*]] = add i64 %[[HOWMANYELEMS]], 8 |
| 50 |
// X86-NEXT: %[[SIZEPLUSCOOKIE:.*]] = add i32 %[[HOWMANYELEMS]], 4 |
| 51 |
// X64-NEXT: call void @"??_V@YAXPEAX_K@Z"(ptr noundef %[[COOKIEADDR]], i64 noundef %[[SIZEPLUSCOOKIE]]) |
| 52 |
// X86-NEXT: call void @"??_V@YAXPAXI@Z"(ptr noundef %[[COOKIEADDR]], i32 noundef %[[SIZEPLUSCOOKIE]]) |
| 53 |
// CHECK-NEXT: br label %delete.end2 |
| 54 |
|
| 55 |
void case2(B *arg) { |
| 56 |
delete[] arg; |
| 57 |
} |
| 58 |
|
| 59 |
// X64-LABEL: define {{.*}} void @"?case2@@YAXPEAUB@@@Z" |
| 60 |
// X64-SAME: (ptr noundef %[[ARG:.*]]) |
| 61 |
// X86-LABEL: define {{.*}} void @"?case2@@YAXPAUB@@@Z" |
| 62 |
// X86-SAME: (ptr noundef %[[ARG:.*]]) |
| 63 |
// CHECK: entry: |
| 64 |
// CHECK-NEXT: %[[ARGADDR:.*]] = alloca ptr |
| 65 |
// CHECK-NEXT: store ptr %[[ARG]], ptr %[[ARGADDR]], |
| 66 |
// CHECK-NEXT: %[[ARR:.*]] = load ptr, ptr %[[ARGADDR]] |
| 67 |
// CHECK-NEXT: %[[ISNULL:.*]] = icmp eq ptr %[[ARR]], null |
| 68 |
// CHECK-NEXT: br i1 %[[ISNULL]], label %delete.end2, label %delete.notnull |
| 69 |
// CHECK: delete.notnull: |
| 70 |
// X64-NEXT: %[[COOKIEADDR:.*]] = getelementptr inbounds i8, ptr %[[ARR]], i64 -8 |
| 71 |
// X86-NEXT: %[[COOKIEADDR:.*]] = getelementptr inbounds i8, ptr %0, i32 -4 |
| 72 |
// X64-NEXT: %[[COOKIE:.*]] = load i64, ptr %[[COOKIEADDR]] |
| 73 |
// X86-NEXT: %[[COOKIE:.*]] = load i32, ptr %[[COOKIEADDR]] |
| 74 |
// X64-NEXT: %[[END:.*]] = getelementptr inbounds %struct.B, ptr %[[ARR]], i64 %[[COOKIE]] |
| 75 |
// X86-NEXT: %[[END:.*]] = getelementptr inbounds %struct.B, ptr %[[ARR]], i32 %[[COOKIE]] |
| 76 |
// CHECK-NEXT: %[[ISEMPTY:.*]] = icmp eq ptr %[[ARR]], %[[END]] |
| 77 |
// CHECK-NEXT: br i1 %arraydestroy.isempty, label %arraydestroy.done1, label %arraydestroy.body |
| 78 |
// CHECK: arraydestroy.body: |
| 79 |
// CHECK-NEXT: %arraydestroy.elementPast = phi ptr [ %delete.end, %delete.notnull ], [ %arraydestroy.element, %arraydestroy.body ] |
| 80 |
// X64-NEXT: %arraydestroy.element = getelementptr inbounds %struct.B, ptr %arraydestroy.elementPast, i64 -1 |
| 81 |
// X86-NEXT: %arraydestroy.element = getelementptr inbounds %struct.B, ptr %arraydestroy.elementPast, i32 -1 |
| 82 |
// X64-NEXT: call void @"??1B@@UEAA@XZ"(ptr noundef nonnull align 8 dereferenceable(8) %arraydestroy.element) |
| 83 |
// X86-NEXT: call x86_thiscallcc void @"??1B@@UAE@XZ"(ptr noundef nonnull align 4 dereferenceable(4) %arraydestroy.element) |
| 84 |
// CHECK-NEXT: %arraydestroy.done = icmp eq ptr %arraydestroy.element, %0 |
| 85 |
// CHECK-NEXT: br i1 %arraydestroy.done, label %arraydestroy.done1, label %arraydestroy.body |
| 86 |
// CHECK: arraydestroy.done1: |
| 87 |
// X64-NEXT: %[[HOWMANYELEMS:.*]] = mul i64 8, %[[COOKIE]] |
| 88 |
// X86-NEXT: %[[HOWMANYELEMS:.*]] = mul i32 4, %[[COOKIE]] |
| 89 |
// X64-NEXT: %[[SIZEPLUSCOOKIE:.*]] = add i64 %[[HOWMANYELEMS]], 8 |
| 90 |
// X86-NEXT: %[[SIZEPLUSCOOKIE:.*]] = add i32 %[[HOWMANYELEMS]], 4 |
| 91 |
// X64-NEXT: call void @"??_V@YAXPEAX_K@Z"(ptr noundef %[[COOKIEADDR]], i64 noundef %[[SIZEPLUSCOOKIE]]) |
| 92 |
// X86-NEXT: call void @"??_V@YAXPAXI@Z"(ptr noundef %[[COOKIEADDR]], i32 noundef %[[SIZEPLUSCOOKIE]]) |
| 93 |
// CHECK-NEXT: br label %delete.end2 |
| 94 |
|
| 95 |
|
| 96 |
void case3(D *arg) { |
| 97 |
delete[] arg; |
| 98 |
} |
| 99 |
|
| 100 |
// CHECK-LABEL: case3 |
| 101 |
// X64: call noundef ptr %{{.}}( |
| 102 |
// X86: call x86_thiscallcc noundef ptr %{{.}}( |
| 103 |
|
| 104 |
void case4(D **arg) { |
| 105 |
delete[] arg[0]; |
| 106 |
delete[] arg[1]; |
| 107 |
} |
| 108 |
|
| 109 |
// CHECK-LABEL: case4 |
| 110 |
// X64: call noundef ptr %{{.}}( |
| 111 |
// X86: call x86_thiscallcc noundef ptr %{{.}}( |