-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for array cookies of dynamically sized arrays
- Loading branch information
1 parent
08254d8
commit 22d8b4f
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// clang-format off | ||
// RUN: %cpp-to-llvm %s | %apply-typeart -S 2>&1 | FileCheck %s | ||
// clang-format on | ||
|
||
struct S1 { | ||
int x; | ||
~S1(){}; | ||
}; | ||
|
||
// CHECK: call i8* @_Znam(i64 [[ALLOC:%[0-9]+]]) | ||
// CHECK: call void @__typeart_alloc(i8* [[MEM:%[0-9]+]], i32 {{2[0-9]+}}, i64 [[COUNT:%[0-9]+]]) | ||
// CHECK: [[COOKIE:%[0-9]+]] = bitcast i8* [[MEM]] to i64* | ||
// CHECK: store i64 [[COUNT]], i64* [[COOKIE]], align 8 | ||
// CHECK: [[ARR:%[0-9]+]] = getelementptr inbounds i8, i8* [[MEM]], i64 8 | ||
// CHECK: bitcast i8* [[ARR]] to %struct.S1* | ||
int main() { | ||
volatile int elment_count = 2; | ||
S1* ss = new S1[elment_count]; | ||
return 0; | ||
} | ||
|
||
// CHECK: TypeArtPass [Heap] | ||
// CHECK-NEXT: Malloc{{[ ]*}}:{{[ ]*}}1 | ||
// CHECK-NEXT: Free | ||
// CHECK-NEXT: Alloca{{[ ]*}}:{{[ ]*}}0 |