-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[KeyInstr][Clang] For stmt atom #134646
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
[KeyInstr][Clang] For stmt atom #134646
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0c7a830
[KeyInstr][Clang] For stmt atom
OCHyams 396ab05
cc1
OCHyams 664478c
nit: shadowed var, test triple
OCHyams 446e622
improve test comments
OCHyams 81005f9
improve test
OCHyams fe4a7d8
fix for body with ctrl-flow
OCHyams 0af9ceb
improve test further: empty loop
OCHyams 6d5aa3d
add braceless test
OCHyams 903922c
comment
OCHyams 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ %s -debug-info-kind=line-tables-only -emit-llvm -o - \ | ||
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank | ||
|
||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - \ | ||
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank | ||
|
||
// Perennial question: should the inc be its own source atom or not | ||
// (currently it is). | ||
|
||
// TODO: See do.c and while.c regarding cmp and cond br groups. | ||
|
||
void a(int A) { | ||
// CHECK: entry: | ||
// CHECK: store i32 0, ptr %i{{.*}}, !dbg [[G1R1:!.*]] | ||
// CHECK: for.cond: | ||
// CHECK: %cmp = icmp slt i32 %0, %1, !dbg [[G2R1:!.*]] | ||
// CHECK: br i1 %cmp, label %for.body, label %for.end, !dbg [[G3R1:!.*]] | ||
|
||
// TODO: The unconditional br is given an atom group here which is useful for | ||
// O0. Since we're no longer targeting O0 we should reevaluate whether this | ||
// adds any value. | ||
// CHECK: for.body: | ||
// CHECK-NEXT: br label %for.inc, !dbg [[G5R1:!.*]] | ||
|
||
// CHECK: for.inc: | ||
// CHECK: %inc = add{{.*}}, !dbg [[G4R2:!.*]] | ||
// CHECK: store i32 %inc, ptr %i{{.*}}, !dbg [[G4R1:!.*]] | ||
for (int i = 0; i < A; ++i) { | ||
} | ||
} | ||
|
||
void b(int A) { | ||
// CHECK: entry: | ||
// CHECK: store i32 0, ptr %i{{.*}}, !dbg [[bG1R1:!.*]] | ||
// CHECK: for.cond: | ||
// CHECK: %cmp = icmp slt i32 %0, %1, !dbg [[bG2R1:!.*]] | ||
// CHECK: br i1 %cmp, label %for.body, label %for.end, !dbg [[bG3R1:!.*]] | ||
|
||
// CHECK: for.body: | ||
// CHECK-NEXT: %2 = load i32, ptr %A.addr | ||
// - If stmt atom: | ||
// CHECK-NEXT: %cmp1 = icmp sgt i32 %2, 1, !dbg [[bG4R2:!.*]] | ||
// CHECK-NEXT: br i1 %cmp1, label %if.then, label %if.end, !dbg [[bG4R1:!.*]] | ||
// CHECK: if.then: | ||
// CHECK-NEXT: br label %if.end | ||
|
||
// - For closing brace. | ||
// CHECK: if.end: | ||
// CHECK-NEXT: br label %for.inc, !dbg [[bG6R1:!.*]] | ||
|
||
// CHECK: for.inc: | ||
// CHECK: %inc = add{{.*}}, !dbg [[bG5R2:!.*]] | ||
// CHECK: store i32 %inc, ptr %i{{.*}}, !dbg [[bG5R1:!.*]] | ||
for (int i = 0; i < A; ++i) { | ||
if (A > 1) | ||
; | ||
} | ||
} | ||
|
||
void c(int A) { | ||
// CHECK: entry: | ||
// CHECK: for.cond: | ||
// CHECK-NEXT: %0 = load i32, ptr %A.addr | ||
// - If stmt atom: | ||
// CHECK-NEXT: %cmp = icmp sgt i32 %0, 1, !dbg [[cG1R2:!.*]] | ||
// CHECK-NEXT: br i1 %cmp, label %if.then, label %if.end, !dbg [[cG1R1:!.*]] | ||
// CHECK: if.then: | ||
// CHECK-NEXT: br label %if.end | ||
|
||
// - For closing brace. | ||
// CHECK: if.end: | ||
// CHECK-NEXT: br label %for.inc, !dbg [[cG3R1:!.*]] | ||
|
||
// CHECK: for.inc: | ||
// CHECK-NEXT: %1 = load i32, ptr %A.addr | ||
// CHECK-NEXT: %inc = add{{.*}}, !dbg [[cG2R2:!.*]] | ||
// CHECK-NEXT: store i32 %inc, ptr %A.addr{{.*}}, !dbg [[cG2R1:!.*]] | ||
for (; /*no cond*/ ; ++A) { | ||
if (A > 1) | ||
; | ||
} | ||
} | ||
|
||
void d() { | ||
// - Check the `for` keyword gets an atom group. | ||
// CHECK: entry: | ||
// CHECK-NEXT: br label %for.cond | ||
|
||
// CHECK: for.cond: | ||
// CHECK: br label %for.cond, !dbg [[dG1R1:!.*]], !llvm.loop | ||
for ( ; ; ) | ||
{ | ||
} | ||
} | ||
|
||
int x, i; | ||
void ee(); | ||
void e() { | ||
// - Check we assign an atom group to `for.body`s `br`, even without braces. | ||
// - TODO: Investigate whether this is needed. | ||
// CHECK: entry: | ||
|
||
// CHECK: for.cond: | ||
// CHECK-NEXT: %0 = load i32, ptr @i | ||
// CHECK-NEXT: %cmp = icmp slt i32 %0, 3, !dbg [[eG1R1:!.*]] | ||
// CHECK-NEXT: br i1 %cmp, label %for.body, label %for.end, !dbg [[eG2R1:!.*]] | ||
|
||
// CHECK: for.body: | ||
// CHECK-NEXT: %1 = load i32, ptr @i{{.*}}, !dbg [[eG3R2:!.*]] | ||
// CHECK-NEXT: store i32 %1, ptr @x{{.*}}, !dbg [[eG3R1:!.*]] | ||
// CHECK-NEXT: br label %for.inc, !dbg [[eG4R1:!.*]] | ||
for (; i < 3; ee()) | ||
x = i; | ||
} | ||
|
||
|
||
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1) | ||
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1) | ||
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1) | ||
// CHECK: [[G5R1]] = !DILocation(line: 29,{{.*}} atomGroup: 5, atomRank: 1) | ||
// CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2) | ||
// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1) | ||
|
||
// CHECK: [[bG1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1) | ||
// CHECK: [[bG2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1) | ||
// CHECK: [[bG3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1) | ||
// CHECK: [[bG4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2) | ||
// CHECK: [[bG4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1) | ||
// CHECK: [[bG6R1]] = !DILocation(line: 57,{{.*}} atomGroup: 6, atomRank: 1) | ||
// CHECK: [[bG5R2]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 2) | ||
// CHECK: [[bG5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1) | ||
|
||
// CHECK: [[cG1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2) | ||
// CHECK: [[cG1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1) | ||
// CHECK: [[cG3R1]] = !DILocation(line: 81,{{.*}} atomGroup: 3, atomRank: 1) | ||
// CHECK: [[cG2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2) | ||
// CHECK: [[cG2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1) | ||
|
||
// CHECK: [[dG1R1]] = !DILocation(line: 91, column: 3, scope: ![[#]], atomGroup: 1, atomRank: 1) | ||
|
||
// CHECK: [[eG1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1) | ||
// CHECK: [[eG2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1) | ||
// CHECK: [[eG3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2) | ||
// CHECK: [[eG3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1) | ||
// CHECK: [[eG4R1]] = !DILocation(line: 113, column: 5, scope: ![[#]], atomGroup: 4, atomRank: 1) |
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.
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.
IMO the comment should indicate the intention of what
FinalBodyBB
-- presumably the last block of the body where the scope ends. Does this mean that for brace-less for loops, we could theoretically step on the same last-line twice if there's a simple assignment and then a branch?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.
There could be two is_stmts there for the same line, yep (I think we discussed before that interpreting that is up to the debugger).
Added to test for additional coverage.
Updated comment.