-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[CodeGen] Add TBAA struct path info for array members #137719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
d63c8fe
bba5ee5
0258b0d
52cb263
1a40063
e8d2703
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| // RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \ | ||
| // RUN: %clang_cc1 -triple x86_64-linux -O1 %s \ | ||
| // RUN: -emit-llvm -o - | FileCheck %s | ||
| // RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \ | ||
| // RUN: %clang_cc1 -triple x86_64-linux -O1 %s \ | ||
| // RUN: -new-struct-path-tbaa -emit-llvm -o - | \ | ||
| // RUN: FileCheck -check-prefix=CHECK-NEW %s | ||
| // | ||
|
|
@@ -10,6 +10,8 @@ | |
| struct A { int i; }; | ||
| struct B { A a[1]; }; | ||
| struct C { int i; int x[3]; }; | ||
| struct D { int n; int arr[]; }; // flexible array member | ||
| extern int AA[]; // incomplete array type | ||
|
|
||
| int foo(B *b) { | ||
| // CHECK-LABEL: _Z3fooP1B | ||
|
|
@@ -28,25 +30,39 @@ int bar(C *c) { | |
|
|
||
| int bar2(C *c) { | ||
| // CHECK-NEW-LABEL: _Z4bar2P1C | ||
| // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]] | ||
| // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_C_x:!.*]] | ||
| return c->x[2]; | ||
| } | ||
|
|
||
| int bar3(C *c, int j) { | ||
| // CHECK-NEW-LABEL: _Z4bar3P1Ci | ||
| // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]] | ||
| // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_C_x]] | ||
| return c->x[j]; | ||
|
Comment on lines
-37
to
44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Am I reading this right that the tag now says we access a 4-byte int in C at offset 4? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the access to any element of the x member array will get this tag. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, thanks. |
||
| } | ||
|
|
||
| int bar4(D *d) { | ||
| // CHECK-NEW-LABEL: _Z4bar4P1D | ||
| // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]] | ||
| // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]] | ||
| return d->arr[d->n]; | ||
| } | ||
|
|
||
| int bar5(int j) { | ||
| // CHECK-NEW-LABEL: _Z4bar5i | ||
| // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]] | ||
| // CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]] | ||
| return AA[2] + AA[j]; | ||
| } | ||
|
|
||
| // CHECK-DAG: [[TAG_A_i]] = !{[[TYPE_A:!.*]], [[TYPE_int:!.*]], i64 0} | ||
| // CHECK-DAG: [[TYPE_A]] = !{!"_ZTS1A", !{{.*}}, i64 0} | ||
| // CHECK-DAG: [[TYPE_int]] = !{!"int", !{{.*}}, i64 0} | ||
|
|
||
| // CHECK-NEW-DAG: [[TYPE_char:!.*]] = !{{{.*}}, i64 1, !"omnipotent char"} | ||
| // CHECK-NEW-DAG: [[TYPE_int:!.*]] = !{[[TYPE_char]], i64 4, !"int"} | ||
| // CHECK-NEW-DAG: [[TAG_int]] = !{[[TYPE_int]], [[TYPE_int]], i64 0, i64 4} | ||
| // CHECK-NEW-DAG: [[TYPE_pointer:!.*]] = !{[[TYPE_char]], i64 8, !"any pointer"} | ||
| // CHECK-NEW-DAG: [[TYPE_A:!.*]] = !{[[TYPE_char]], i64 4, !"_ZTS1A", [[TYPE_int]], i64 0, i64 4} | ||
| // CHECK-NEW-DAG: [[TAG_A_i]] = !{[[TYPE_A]], [[TYPE_int]], i64 0, i64 4} | ||
| // CHECK-NEW-DAG: [[TYPE_C:!.*]] = !{[[TYPE_char]], i64 16, !"_ZTS1C", [[TYPE_int]], i64 0, i64 4, [[TYPE_int]], i64 4, i64 12} | ||
| // CHECK-NEW-DAG: [[TAG_C_i]] = !{[[TYPE_C:!.*]], [[TYPE_int:!.*]], i64 0, i64 4} | ||
| // CHECK-NEW-DAG: [[TAG_C_x]] = !{[[TYPE_C:!.*]], [[TYPE_int:!.*]], i64 4, i64 4} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment doesn't seem to match the code anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've rewritten the code comments for this block.