Skip to content

Commit 3b4ca1b

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 4e082dd commit 3b4ca1b

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
@@ -5985,6 +5985,15 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
59855985

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

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

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)