-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[KeyInstr][Clang] Assignment atom group #134637
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
Conversation
a92afbf
to
76da803
Compare
6788769
to
6f0135b
Compare
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.
Looks good, with a question inline and some test nits.
@@ -5985,6 +5985,15 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { | |||
|
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.
I wonder whether the comma operator (six or seven lines above here) needs instrumenting -- technically if either lhs/rhs of the comma is an assignment, I guess it'll come back through this function and be given a separate group?
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.
Yeah that's right - added to the test for better coverage.
clang/lib/CodeGen/CGExpr.cpp
Outdated
// This covers both LHS and RHS expressions, though nested RHS | ||
// expressions may get subsequently separately grouped. |
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.
Opening part of the comment should provide context to the reader that you're doing something debug-info / stepping related.
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.
Done
clang/lib/CodeGen/CGExpr.cpp
Outdated
// FIXME(OCH): Not clear yet if we've got fine enough control | ||
// to pick and choose when we need to. Currently looks ok: | ||
// a = b = c -> Two atoms. | ||
// x = new(1) -> One atom (for both addr store and value store). |
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.
Is this TODO still relevant -- it's not clear what's actually to do.
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.
I was thinking out loud, I guess. Agree it doesn't really add anything (except confusion) so I've removed it.
@@ -5849,6 +5852,7 @@ LValue CodeGenFunction::EmitObjCIsaExpr(const ObjCIsaExpr *E) { | |||
|
|||
LValue CodeGenFunction::EmitCompoundAssignmentLValue( | |||
const CompoundAssignOperator *E) { | |||
ApplyAtomGroup Grp(getDebugInfo()); |
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.
If I enter via a VisitBin##OP##Assign
function from above I'll get an atom group before calling EmitCompoundAssign
, then get a second atom group here in EmitcompoundAssignmentLValue
(which is called by EmitCompoundAssign
). I would have expected only one atom group to be generated in that, is that wrong?
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.
If I enter via a VisitBin##OP##Assign function from above I'll get an atom group before calling EmitCompoundAssign,
Looks correct
then get a second atom group here in EmitcompoundAssignmentLValue (which is called by EmitCompoundAssign). I would have expected only one atom group to be generated in that, is that wrong?
Looks wrong - EmitCompoundAssign
calls EmitCompoundAssignLValue
not EmitcompoundAssignmentLValue
. The function names are annoyingly similar, this took a bit of head-scratching to re-figure out!
// RUN: %clang_cc1 -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 |
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 test is great; I feel we can make it even greater by testing:
g += ++h;
Or something like that, where there are stores on both sides of a compound assignment expression.
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.
Done
// CHECK: store i64 0, ptr @g{{.*}}, !dbg [[G1R1:!.*]] | ||
g = 0; | ||
|
||
// Treat the two assignments as two atoms. |
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.
Duplicate coverage with the g = g = g
in the test file above?
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.
Oops, this file magically appeared as a result of a wobbly rebase after moving the tests to the new dir. Deleted it, it is all completely redundant (clang/test/DebugInfo/KeyInstructions/assign-scalar.c covers exactly this and more).
// CHECK: call void @llvm.memcpy{{.*}}, !dbg [[G1R1:!.*]] | ||
int A[] = { 1, 2, 3 }; |
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.
As with a prior review, tying the memcpy down to its destination SSA name would be nice, as it'd be more specific than "there is a memcpy with group 1 rank 1, anywhere".
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.
Agree, done.
// CHECK: store i32 %0, ptr %{{.*}}, !dbg [[G2R1]] | ||
int B[] = { 1, 2, g }; | ||
|
||
// CHECK: call void @llvm.memset{{.*}}, !dbg [[G3R1:!.*]] |
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.
Similarly, would be nice to have a more specific memset, and the one below.
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.
Done
Thanks @jmorse, that should be all nits/questions addressed now. |
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.
LGTM
4e082dd
to
ef9acc1
Compare
This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. The Key Instructions project is introduced, including a "quick summary" section at the top which adds context for this PR, here: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668 The feature is only functional in LLVM if LLVM is built with CMake flag LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed. The Clang-side work is demoed here: #130943
d2d43d9
to
24fb5af
Compare
This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668 The feature is only functional in LLVM if LLVM is built with CMake flag LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.
This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668 The feature is only functional in LLVM if LLVM is built with CMake flag LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.
[KeyInstr][Clang] Assignment atom group
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.
The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.
The Clang-side work is demoed here:
#130943