Skip to content

Commit 5f5c88b

Browse files
committed
[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
1 parent aac843c commit 5f5c88b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5981,6 +5981,15 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
59815981

59825982
assert(E->getOpcode() == BO_Assign && "unexpected binary l-value");
59835983

5984+
// This covers both LHS and RHS expressions, though nested RHS
5985+
// expressions may get subsequently separately grouped.
5986+
// FIXME(OCH): Not clear yet if we've got fine enough control
5987+
// to pick and choose when we need to. Currently looks ok:
5988+
// a = b = c -> Two atoms.
5989+
// x = new(1) -> One atom (for both addr store and value store).
5990+
// Complex and agg assignment -> One atom.
5991+
ApplyAtomGroup Grp(getDebugInfo());
5992+
59845993
// Note that in all of these cases, __block variables need the RHS
59855994
// evaluated first just in case the variable gets moved by the RHS.
59865995

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang -gkey-instructions %s -gmlt -gcolumn-info -S -emit-llvm -o - -Wno-unused-variable \
2+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
3+
4+
unsigned long long g;
5+
void fun() { g = 0; }
6+
7+
// CHECK: store i64 0, ptr @g{{.*}}, !dbg [[G1R1:!.*]]
8+
9+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)

0 commit comments

Comments
 (0)