-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang][CodeGen] Add metadata for load from reference #98746
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b120d8d
[Clang][CodeGen] Add metadata for load from reference
dtcxzyw 68f6381
[Clang][CodeGen] Add tests. NFC.
dtcxzyw 5a1269a
[Clang][CodeGen] Reuse alignment computation
dtcxzyw ee7ef59
[Clang][CodeGen] Fix tests. NFC.
dtcxzyw 8fe484f
[Clang][CodeGen] Add more tests. NFC.
dtcxzyw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,98 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 | ||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -std=c++11 -O1 -disable-llvm-passes %s -o - | FileCheck %s | ||
|
||
struct alignas(32) F { int x; }; | ||
|
||
struct S { | ||
char &a; | ||
int &b; | ||
F &c; | ||
}; | ||
|
||
// CHECK-LABEL: define dso_local void @_Z4testR1S( | ||
// CHECK-SAME: ptr noundef nonnull align 8 dereferenceable(24) [[S:%.*]]) #[[ATTR0:[0-9]+]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[S_ADDR:%.*]] = alloca ptr, align 8 | ||
// CHECK-NEXT: store ptr [[S]], ptr [[S_ADDR]], align 8, !tbaa [[TBAA2:![0-9]+]] | ||
// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8, !tbaa [[TBAA2]], !nonnull [[META7:![0-9]+]], !align [[META8:![0-9]+]] | ||
// CHECK-NEXT: [[A:%.*]] = getelementptr inbounds nuw [[STRUCT_S:%.*]], ptr [[TMP0]], i32 0, i32 0 | ||
// CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[A]], align 8, !tbaa [[TBAA9:![0-9]+]], !nonnull [[META7]] | ||
// CHECK-NEXT: store i8 0, ptr [[TMP1]], align 1, !tbaa [[TBAA14:![0-9]+]] | ||
// CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[S_ADDR]], align 8, !tbaa [[TBAA2]], !nonnull [[META7]], !align [[META8]] | ||
// CHECK-NEXT: [[B:%.*]] = getelementptr inbounds nuw [[STRUCT_S]], ptr [[TMP2]], i32 0, i32 1 | ||
// CHECK-NEXT: [[TMP3:%.*]] = load ptr, ptr [[B]], align 8, !tbaa [[TBAA15:![0-9]+]], !nonnull [[META7]], !align [[META16:![0-9]+]] | ||
// CHECK-NEXT: store i32 0, ptr [[TMP3]], align 4, !tbaa [[TBAA17:![0-9]+]] | ||
// CHECK-NEXT: [[TMP4:%.*]] = load ptr, ptr [[S_ADDR]], align 8, !tbaa [[TBAA2]], !nonnull [[META7]], !align [[META8]] | ||
// CHECK-NEXT: [[C:%.*]] = getelementptr inbounds nuw [[STRUCT_S]], ptr [[TMP4]], i32 0, i32 2 | ||
// CHECK-NEXT: [[TMP5:%.*]] = load ptr, ptr [[C]], align 8, !tbaa [[TBAA19:![0-9]+]], !nonnull [[META7]], !align [[META20:![0-9]+]] | ||
// CHECK-NEXT: [[X:%.*]] = getelementptr inbounds nuw [[STRUCT_F:%.*]], ptr [[TMP5]], i32 0, i32 0 | ||
// CHECK-NEXT: store i32 0, ptr [[X]], align 32, !tbaa [[TBAA21:![0-9]+]] | ||
// CHECK-NEXT: ret void | ||
// | ||
void test(S &s) { | ||
s.a = 0; | ||
s.b = 0; | ||
s.c.x = 0; | ||
} | ||
|
||
struct A { alignas(32) char x[32]; }; | ||
struct B : virtual A { long long b; char c; }; | ||
extern B& b; | ||
extern B (&bb)[2]; | ||
// CHECK-LABEL: define dso_local void @_Z13test_externalv( | ||
// CHECK-SAME: ) #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr @b, align 8, !tbaa [[TBAA23:![0-9]+]], !nonnull [[META7]], !align [[META8]] | ||
// CHECK-NEXT: [[C:%.*]] = getelementptr inbounds nuw [[STRUCT_B:%.*]], ptr [[TMP0]], i32 0, i32 2 | ||
// CHECK-NEXT: store i8 0, ptr [[C]], align 8, !tbaa [[TBAA25:![0-9]+]] | ||
// CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr @bb, align 8, !tbaa [[TBAA23]], !nonnull [[META7]], !align [[META20]] | ||
// CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x %struct.B], ptr [[TMP1]], i64 0, i64 0 | ||
// CHECK-NEXT: [[C1:%.*]] = getelementptr inbounds nuw [[STRUCT_B]], ptr [[ARRAYIDX]], i32 0, i32 2 | ||
// CHECK-NEXT: store i8 0, ptr [[C1]], align 16, !tbaa [[TBAA25]] | ||
// CHECK-NEXT: ret void | ||
// | ||
void test_external() { | ||
b.c = 0; // align 8 | ||
bb[0].c = 0; // align 32 | ||
} | ||
|
||
// CHECK-LABEL: define dso_local noundef ptr @_Z15test_deref_onlyR1B( | ||
// CHECK-SAME: ptr noundef nonnull align 8 dereferenceable(17) [[S:%.*]]) #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[S_ADDR:%.*]] = alloca ptr, align 8 | ||
// CHECK-NEXT: store ptr [[S]], ptr [[S_ADDR]], align 8, !tbaa [[TBAA23]] | ||
// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8, !tbaa [[TBAA23]], !nonnull [[META7]], !align [[META8]] | ||
// CHECK-NEXT: [[C:%.*]] = getelementptr inbounds nuw [[STRUCT_B:%.*]], ptr [[TMP0]], i32 0, i32 2 | ||
// CHECK-NEXT: ret ptr [[C]] | ||
// | ||
char* test_deref_only(B &s) { | ||
return &s.c; | ||
} | ||
//. | ||
// CHECK: [[TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i64 0} | ||
// CHECK: [[META3]] = !{!"p1 _ZTS1S", [[META4:![0-9]+]], i64 0} | ||
// CHECK: [[META4]] = !{!"any pointer", [[META5:![0-9]+]], i64 0} | ||
// CHECK: [[META5]] = !{!"omnipotent char", [[META6:![0-9]+]], i64 0} | ||
// CHECK: [[META6]] = !{!"Simple C++ TBAA"} | ||
// CHECK: [[META7]] = !{} | ||
// CHECK: [[META8]] = !{i64 8} | ||
// CHECK: [[TBAA9]] = !{[[META10:![0-9]+]], [[META11:![0-9]+]], i64 0} | ||
// CHECK: [[META10]] = !{!"_ZTS1S", [[META11]], i64 0, [[META12:![0-9]+]], i64 8, [[META13:![0-9]+]], i64 16} | ||
// CHECK: [[META11]] = !{!"p1 omnipotent char", [[META4]], i64 0} | ||
// CHECK: [[META12]] = !{!"p1 int", [[META4]], i64 0} | ||
// CHECK: [[META13]] = !{!"p1 _ZTS1F", [[META4]], i64 0} | ||
// CHECK: [[TBAA14]] = !{[[META5]], [[META5]], i64 0} | ||
// CHECK: [[TBAA15]] = !{[[META10]], [[META12]], i64 8} | ||
// CHECK: [[META16]] = !{i64 4} | ||
// CHECK: [[TBAA17]] = !{[[META18:![0-9]+]], [[META18]], i64 0} | ||
// CHECK: [[META18]] = !{!"int", [[META5]], i64 0} | ||
// CHECK: [[TBAA19]] = !{[[META10]], [[META13]], i64 16} | ||
// CHECK: [[META20]] = !{i64 32} | ||
// CHECK: [[TBAA21]] = !{[[META22:![0-9]+]], [[META18]], i64 0} | ||
// CHECK: [[META22]] = !{!"_ZTS1F", [[META18]], i64 0} | ||
// CHECK: [[TBAA23]] = !{[[META24:![0-9]+]], [[META24]], i64 0} | ||
// CHECK: [[META24]] = !{!"p1 _ZTS1B", [[META4]], i64 0} | ||
// CHECK: [[TBAA25]] = !{[[META26:![0-9]+]], [[META5]], i64 16} | ||
// CHECK: [[META26]] = !{!"_ZTS1B", [[META27:![0-9]+]], i64 8, [[META5]], i64 16} | ||
// CHECK: [[META27]] = !{!"long long", [[META5]], i64 0} | ||
//. |
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.