[clang] [KeyInstr][Clang] For stmt atom (PR #134646)
Orlando Cazalet-Hyams via cfe-commits
cfe-commits at lists.llvm.org
Tue May 27 07:51:41 PDT 2025
https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/134646
>From 510cb679b679f7265107127cc3d57a76b576e42d Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Tue, 27 May 2025 14:57:12 +0100
Subject: [PATCH 1/8] [KeyInstr][Clang] Reset atomGroup number for each
function
CGDebugInfo::completeFunction was added previously but mistakenly
not called (dropped through the cracks while putting together
the patch stack). Moved out of #134652 and #134654.
---
clang/lib/CodeGen/CodeGenFunction.cpp | 6 ++++++
.../DebugInfo/KeyInstructions/multi-func.c | 19 +++++++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 clang/test/DebugInfo/KeyInstructions/multi-func.c
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 0356952f4f291..a9ef2784c2fb6 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -36,6 +36,7 @@
#include "clang/CodeGen/CGFunctionInfo.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/ScopeExit.h"
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Dominators.h"
@@ -1506,6 +1507,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
// Disable debug info indefinitely for this function
DebugInfo = nullptr;
}
+ // Finalize function debug info on exit.
+ auto Cleanup = llvm::make_scope_exit([this] {
+ if (CGDebugInfo *DI = getDebugInfo())
+ DI->completeFunction();
+ });
// The function might not have a body if we're generating thunks for a
// function declaration.
diff --git a/clang/test/DebugInfo/KeyInstructions/multi-func.c b/clang/test/DebugInfo/KeyInstructions/multi-func.c
new file mode 100644
index 0000000000000..6e225eed81de8
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/multi-func.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -gno-column-info -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 -gno-column-info -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
+
+// Check atomGroup is reset to start at 1 in each function.
+
+int g;
+// CHECK: store{{.*}}, !dbg [[AG:!.*]]
+void a() { g = 0; }
+
+// CHECK: store{{.*}}, !dbg [[BG:!.*]]
+void b() { g = 0; }
+
+// CHECK: [[A:!.*]] = distinct !DISubprogram(name: "a",
+// CHECK: [[AG]] = !DILocation(line: 11, scope: [[A]], atomGroup: 1, atomRank: 1)
+// CHECK: [[B:!.*]] = distinct !DISubprogram(name: "b",
+// CHECK: [[BG]] = !DILocation(line: 14, scope: [[B]], atomGroup: 1, atomRank: 1)
>From 16fbead2fa46c92753b6703877a90e907adaa385 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Thu, 3 Apr 2025 19:12:47 +0100
Subject: [PATCH 2/8] [KeyInstr][Clang] For stmt atom
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:
https://github.com/llvm/llvm-project/pull/130943
---
clang/lib/CodeGen/CGStmt.cpp | 18 +++++++++--
clang/test/DebugInfo/KeyInstructions/for.c | 37 ++++++++++++++++++++++
2 files changed, 53 insertions(+), 2 deletions(-)
create mode 100644 clang/test/DebugInfo/KeyInstructions/for.c
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 31d64a5a788ee..0655e38cd4e4b 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1326,6 +1326,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
Continue = getJumpDestInCurrentScope("for.inc");
BreakContinueStack.push_back(BreakContinue(LoopExit, Continue));
+ llvm::BasicBlock *ForBody = nullptr;
if (S.getCond()) {
// If the for statement has a condition scope, emit the local variable
// declaration.
@@ -1350,7 +1351,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
ExitBlock = createBasicBlock("for.cond.cleanup");
// As long as the condition is true, iterate the loop.
- llvm::BasicBlock *ForBody = createBasicBlock("for.body");
+ ForBody = createBasicBlock("for.body");
// C99 6.8.5p2/p4: The first substatement is executed if the expression
// compares unequal to 0. The condition must be a scalar type.
@@ -1364,7 +1365,14 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
BoolCondVal = emitCondLikelihoodViaExpectIntrinsic(
BoolCondVal, Stmt::getLikelihood(S.getBody()));
- Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
+ auto *I = Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
+ // Key Instructions: Emit the condition and branch as separate atoms to
+ // match existing loop stepping behaviour. FIXME: We could have the branch
+ // as the backup location for the condition, which would probably be a
+ // better experience (no jumping to the brace).
+ if (auto *I = dyn_cast<llvm::Instruction>(BoolCondVal))
+ addInstToNewSourceAtom(I, nullptr);
+ addInstToNewSourceAtom(I, nullptr);
if (ExitBlock != LoopExit.getBlock()) {
EmitBlock(ExitBlock);
@@ -1418,6 +1426,12 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
if (CGM.shouldEmitConvergenceTokens())
ConvergenceTokenStack.pop_back();
+
+ if (ForBody) {
+ // Key Instructions: We want the for closing brace to be step-able on to
+ // match existing behaviour.
+ addInstToNewSourceAtom(ForBody->getTerminator(), nullptr);
+ }
}
void
diff --git a/clang/test/DebugInfo/KeyInstructions/for.c b/clang/test/DebugInfo/KeyInstructions/for.c
new file mode 100644
index 0000000000000..3221ece69a717
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/for.c
@@ -0,0 +1,37 @@
+// RUN: %clang -gkey-instructions -x c++ %s -gmlt -S -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
+
+// RUN: %clang -gkey-instructions -x c %s -gmlt -S -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
+
+// Perennial quesiton: should the inc be its own source atom or not
+// (currently it is).
+
+// FIXME: 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:!.*]]
+
+// FIXME: Added uncond br group here which is useful for O0, which we're
+// no longer targeting. With optimisations loop rotate puts the condition
+// into for.inc and simplifycfg smooshes that and for.body together, so
+// it's not clear whether it adds any value.
+// CHECK: for.body:
+// CHECK: 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) { }
+}
+
+// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
+// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
+// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
+// CHECK: [[G5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
+// CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2)
+// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
>From bccad5d04e6c04a01af8c77c6ea0e3985aaabae8 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Wed, 21 May 2025 15:50:28 +0100
Subject: [PATCH 3/8] cc1
---
clang/test/DebugInfo/KeyInstructions/for.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/test/DebugInfo/KeyInstructions/for.c b/clang/test/DebugInfo/KeyInstructions/for.c
index 3221ece69a717..dbca87d73c293 100644
--- a/clang/test/DebugInfo/KeyInstructions/for.c
+++ b/clang/test/DebugInfo/KeyInstructions/for.c
@@ -1,7 +1,7 @@
-// RUN: %clang -gkey-instructions -x c++ %s -gmlt -S -emit-llvm -o - \
+// 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
-// RUN: %clang -gkey-instructions -x c %s -gmlt -S -emit-llvm -o - \
+// 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
// Perennial quesiton: should the inc be its own source atom or not
>From 525a96109a619f4f8bc8994b49cb4662add2189e Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Tue, 27 May 2025 11:30:33 +0100
Subject: [PATCH 4/8] nit: shadowed var, test triple
---
clang/lib/CodeGen/CGStmt.cpp | 4 ++--
clang/test/DebugInfo/KeyInstructions/for.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 0655e38cd4e4b..bb58d69d41fc9 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1370,8 +1370,8 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
// match existing loop stepping behaviour. FIXME: We could have the branch
// as the backup location for the condition, which would probably be a
// better experience (no jumping to the brace).
- if (auto *I = dyn_cast<llvm::Instruction>(BoolCondVal))
- addInstToNewSourceAtom(I, nullptr);
+ if (auto *CondI = dyn_cast<llvm::Instruction>(BoolCondVal))
+ addInstToNewSourceAtom(CondI, nullptr);
addInstToNewSourceAtom(I, nullptr);
if (ExitBlock != LoopExit.getBlock()) {
diff --git a/clang/test/DebugInfo/KeyInstructions/for.c b/clang/test/DebugInfo/KeyInstructions/for.c
index dbca87d73c293..c5f57f863f478 100644
--- a/clang/test/DebugInfo/KeyInstructions/for.c
+++ b/clang/test/DebugInfo/KeyInstructions/for.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -gkey-instructions -x c++ %s -debug-info-kind=line-tables-only -emit-llvm -o - \
+// 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 -gkey-instructions -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - \
+// 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 quesiton: should the inc be its own source atom or not
>From 133e848b919dec04f02b750943b22fbbdfb1413b Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Tue, 27 May 2025 11:33:53 +0100
Subject: [PATCH 5/8] improve test comments
---
clang/test/DebugInfo/KeyInstructions/for.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/clang/test/DebugInfo/KeyInstructions/for.c b/clang/test/DebugInfo/KeyInstructions/for.c
index c5f57f863f478..ac5411917d0c1 100644
--- a/clang/test/DebugInfo/KeyInstructions/for.c
+++ b/clang/test/DebugInfo/KeyInstructions/for.c
@@ -4,10 +4,10 @@
// 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 quesiton: should the inc be its own source atom or not
+// Perennial question: should the inc be its own source atom or not
// (currently it is).
-// FIXME: See do.c and while.c regarding cmp and cond br groups.
+// TODO: See do.c and while.c regarding cmp and cond br groups.
void a(int A) {
// CHECK: entry:
@@ -16,10 +16,9 @@ void a(int A) {
// CHECK: %cmp = icmp slt i32 %0, %1, !dbg [[G2R1:!.*]]
// CHECK: br i1 %cmp, label %for.body, label %for.end, !dbg [[G3R1:!.*]]
-// FIXME: Added uncond br group here which is useful for O0, which we're
-// no longer targeting. With optimisations loop rotate puts the condition
-// into for.inc and simplifycfg smooshes that and for.body together, so
-// it's not clear whether it adds any value.
+// 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: br label %for.inc, !dbg [[G5R1:!.*]]
>From aff3990f43031205fc9b312796df94ce529e221c Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Tue, 27 May 2025 14:34:48 +0100
Subject: [PATCH 6/8] improve test
---
clang/test/DebugInfo/KeyInstructions/for.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/clang/test/DebugInfo/KeyInstructions/for.c b/clang/test/DebugInfo/KeyInstructions/for.c
index ac5411917d0c1..bf0c7031d5071 100644
--- a/clang/test/DebugInfo/KeyInstructions/for.c
+++ b/clang/test/DebugInfo/KeyInstructions/for.c
@@ -20,17 +20,18 @@ void a(int A) {
// O0. Since we're no longer targeting O0 we should reevaluate whether this
// adds any value.
// CHECK: for.body:
-// CHECK: br label %for.inc, !dbg [[G5R1:!.*]]
+// 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) { }
+ for (int i = 0; i < A; ++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({{.*}}, atomGroup: 5, 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)
>From b41dc1cdc5b96659275e10bc05a28ddb176cae94 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Tue, 27 May 2025 15:22:11 +0100
Subject: [PATCH 7/8] fix for body with ctrl-flow
---
clang/lib/CodeGen/CGStmt.cpp | 9 +--
clang/test/DebugInfo/KeyInstructions/for.c | 67 ++++++++++++++++++++++
2 files changed, 72 insertions(+), 4 deletions(-)
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index bb58d69d41fc9..cd2f05d419216 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1326,7 +1326,6 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
Continue = getJumpDestInCurrentScope("for.inc");
BreakContinueStack.push_back(BreakContinue(LoopExit, Continue));
- llvm::BasicBlock *ForBody = nullptr;
if (S.getCond()) {
// If the for statement has a condition scope, emit the local variable
// declaration.
@@ -1351,7 +1350,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
ExitBlock = createBasicBlock("for.cond.cleanup");
// As long as the condition is true, iterate the loop.
- ForBody = createBasicBlock("for.body");
+ llvm::BasicBlock *ForBody = createBasicBlock("for.body");
// C99 6.8.5p2/p4: The first substatement is executed if the expression
// compares unequal to 0. The condition must be a scalar type.
@@ -1397,6 +1396,8 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
EmitStmt(S.getBody());
}
+ auto *FinalBodyBB = Builder.GetInsertBlock();
+
// If there is an increment, emit it next.
if (S.getInc()) {
EmitBlock(Continue.getBlock());
@@ -1427,10 +1428,10 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
if (CGM.shouldEmitConvergenceTokens())
ConvergenceTokenStack.pop_back();
- if (ForBody) {
+ if (FinalBodyBB) {
// Key Instructions: We want the for closing brace to be step-able on to
// match existing behaviour.
- addInstToNewSourceAtom(ForBody->getTerminator(), nullptr);
+ addInstToNewSourceAtom(FinalBodyBB->getTerminator(), nullptr);
}
}
diff --git a/clang/test/DebugInfo/KeyInstructions/for.c b/clang/test/DebugInfo/KeyInstructions/for.c
index bf0c7031d5071..eafc08c655d57 100644
--- a/clang/test/DebugInfo/KeyInstructions/for.c
+++ b/clang/test/DebugInfo/KeyInstructions/for.c
@@ -29,9 +29,76 @@ void a(int A) {
}
}
+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)
+ ;
+ }
+}
+
// 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)
\ No newline at end of file
>From 784005e40100687f0162affa720fc3dbfe598974 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Tue, 27 May 2025 15:44:25 +0100
Subject: [PATCH 8/8] improve test further: empty loop
---
clang/test/DebugInfo/KeyInstructions/for.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/clang/test/DebugInfo/KeyInstructions/for.c b/clang/test/DebugInfo/KeyInstructions/for.c
index eafc08c655d57..d1fc79292266b 100644
--- a/clang/test/DebugInfo/KeyInstructions/for.c
+++ b/clang/test/DebugInfo/KeyInstructions/for.c
@@ -81,6 +81,18 @@ void c(int A) {
}
}
+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 ( ; ; )
+ {
+ }
+}
+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
@@ -101,4 +113,6 @@ void c(int A) {
// 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)
\ No newline at end of file
+// CHECK: [[cG2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
+
+// CHECK: [[dG1R1]] = !DILocation(line: 91, column: 3, scope: ![[#]], atomGroup: 1, atomRank: 1)
More information about the cfe-commits
mailing list