https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/134638
>From fa1c06148d4f79e9464d92ab5c26d9a22c5bf41d Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Thu, 3 Apr 2025 13:36:59 +0100 Subject: [PATCH 1/8] [KeyInstr] Complex assignment atoms 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/CGExprComplex.cpp | 10 ++++- .../test/DebugInfo/KeyInstructions/complex.c | 40 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 clang/test/DebugInfo/KeyInstructions/complex.c diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index f556594f4a9ec..600f61f1b325f 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -461,8 +461,12 @@ void ComplexExprEmitter::EmitStoreOfComplex(ComplexPairTy Val, LValue lvalue, Address RealPtr = CGF.emitAddrOfRealComponent(Ptr, lvalue.getType()); Address ImagPtr = CGF.emitAddrOfImagComponent(Ptr, lvalue.getType()); - Builder.CreateStore(Val.first, RealPtr, lvalue.isVolatileQualified()); - Builder.CreateStore(Val.second, ImagPtr, lvalue.isVolatileQualified()); + auto *R = + Builder.CreateStore(Val.first, RealPtr, lvalue.isVolatileQualified()); + CGF.addInstToCurrentSourceAtom(R, Val.first); + auto *I = + Builder.CreateStore(Val.second, ImagPtr, lvalue.isVolatileQualified()); + CGF.addInstToCurrentSourceAtom(I, Val.second); } @@ -1209,6 +1213,7 @@ LValue ComplexExprEmitter:: EmitCompoundAssignLValue(const CompoundAssignOperator *E, ComplexPairTy (ComplexExprEmitter::*Func)(const BinOpInfo&), RValue &Val) { + ApplyAtomGroup Grp(CGF.getDebugInfo()); TestAndClearIgnoreReal(); TestAndClearIgnoreImag(); QualType LHSTy = E->getLHS()->getType(); @@ -1356,6 +1361,7 @@ LValue ComplexExprEmitter::EmitBinAssignLValue(const BinaryOperator *E, } ComplexPairTy ComplexExprEmitter::VisitBinAssign(const BinaryOperator *E) { + ApplyAtomGroup Grp(CGF.getDebugInfo()); ComplexPairTy Val; LValue LV = EmitBinAssignLValue(E, Val); diff --git a/clang/test/DebugInfo/KeyInstructions/complex.c b/clang/test/DebugInfo/KeyInstructions/complex.c new file mode 100644 index 0000000000000..b97314e815bdc --- /dev/null +++ b/clang/test/DebugInfo/KeyInstructions/complex.c @@ -0,0 +1,40 @@ + +// RUN: %clang -gkey-instructions -x c++ %s -gmlt -gcolumn-info -S -emit-llvm -o - -Wno-unused-variable \ +// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank + +// RUN: %clang -gkey-instructions -x c %s -gmlt -gcolumn-info -S -emit-llvm -o - -Wno-unused-variable \ +// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank + +_Complex float ci; +void test() { +// CHECK: %ci.real = load float, ptr @ci{{.*}}, !dbg [[G1R2:!.*]] +// CHECK: %ci.imag = load float, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G1R2]] +// CHECK: store float %ci.real, ptr %lc.realp{{.*}}, !dbg [[G1R1:!.*]] +// CHECK: store float %ci.imag, ptr %lc.imagp{{.*}}, !dbg [[G1R1]] + _Complex float lc = ci; + +// CHECK: %ci.real1 = load float, ptr @ci{{.*}}, !dbg [[G2R2:!.*]] +// CHECK: %ci.imag2 = load float, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G2R2]] +// CHECK: store float %ci.real1, ptr @ci{{.*}}, !dbg [[G2R1:!.*]] +// CHECK: store float %ci.imag2, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G2R1]] + ci = ci; + +// CHECK: %add.r = fadd float %ci.real5, %ci.real3, !dbg [[G3R2:!.*]] +// CHECK: %add.i = fadd float %ci.imag6, %ci.imag4, !dbg [[G3R2]] +// CHECK: store float %add.r, ptr @ci{{.*}}, !dbg [[G3R1:!.*]] +// CHECK: store float %add.i, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G3R1]] + ci += ci; + +// CHECK: %add = fadd float %0, %1, !dbg [[G4R2:!.*]] +// CHECK: store float %add, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G4R1:!.*]] + __imag ci = __imag ci + __imag ci; +} + +// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2) +// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1) +// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2) +// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1) +// CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2) +// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1) +// CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2) +// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1) >From c04e9479ed87fb1a75aafba74d6655f37eab880a Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Wed, 21 May 2025 14:58:42 +0100 Subject: [PATCH 2/8] cc1 --- clang/test/DebugInfo/KeyInstructions/complex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/DebugInfo/KeyInstructions/complex.c b/clang/test/DebugInfo/KeyInstructions/complex.c index b97314e815bdc..f922e5ff71a58 100644 --- a/clang/test/DebugInfo/KeyInstructions/complex.c +++ b/clang/test/DebugInfo/KeyInstructions/complex.c @@ -1,8 +1,8 @@ -// RUN: %clang -gkey-instructions -x c++ %s -gmlt -gcolumn-info -S -emit-llvm -o - -Wno-unused-variable \ +// 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 -gcolumn-info -S -emit-llvm -o - -Wno-unused-variable \ +// 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 _Complex float ci; >From 449f30ee1f787e3f68a56a3a046d62981b081bfd Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Wed, 21 May 2025 15:09:04 +0100 Subject: [PATCH 3/8] whitespace --- clang/test/DebugInfo/KeyInstructions/complex.c | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/test/DebugInfo/KeyInstructions/complex.c b/clang/test/DebugInfo/KeyInstructions/complex.c index f922e5ff71a58..ff8557afb91e7 100644 --- a/clang/test/DebugInfo/KeyInstructions/complex.c +++ b/clang/test/DebugInfo/KeyInstructions/complex.c @@ -1,4 +1,3 @@ - // 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 >From f55989189bcda3dee37ca38d54a66ada306e8a2d Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Fri, 23 May 2025 15:45:21 +0100 Subject: [PATCH 4/8] expand test --- .../test/DebugInfo/KeyInstructions/complex.c | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/clang/test/DebugInfo/KeyInstructions/complex.c b/clang/test/DebugInfo/KeyInstructions/complex.c index ff8557afb91e7..850f39eaab95c 100644 --- a/clang/test/DebugInfo/KeyInstructions/complex.c +++ b/clang/test/DebugInfo/KeyInstructions/complex.c @@ -5,6 +5,7 @@ // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank _Complex float ci; +float f; void test() { // CHECK: %ci.real = load float, ptr @ci{{.*}}, !dbg [[G1R2:!.*]] // CHECK: %ci.imag = load float, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G1R2]] @@ -24,8 +25,31 @@ void test() { // CHECK: store float %add.i, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G3R1]] ci += ci; -// CHECK: %add = fadd float %0, %1, !dbg [[G4R2:!.*]] -// CHECK: store float %add, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G4R1:!.*]] +// CHECK: %sub.r = fsub float %ci.real9, %ci.real7, !dbg [[G4R2:!.*]] +// CHECK: %sub.i = fsub float %ci.imag10, %ci.imag8, !dbg [[G4R2]] +// CHECK: store float %sub.r, ptr @ci, align 4, !dbg [[G4R1:!.*]] +// CHECK: store float %sub.i, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G4R1]] + ci -= ci; + +// There's control flow introduced here to skip around nan and lib calls +// (which is ignored in the test as none of those insts need be key). This does +// make PHIs "backup" instructions, which is... odd. FIXME: Do we want to make +// the instructions producing the values in the PHI backups instead/too? +// CHECK: %real_mul_phi = phi float [ %mul_r, %entry ], [ %mul_r, %complex_mul_imag_nan ], [ %coerce.real, %complex_mul_libcall ], !dbg [[G5R2:!.*]] +// CHECK: %imag_mul_phi = phi float [ %mul_i, %entry ], [ %mul_i, %complex_mul_imag_nan ], [ %coerce.imag, %complex_mul_libcall ], !dbg [[G5R2]] +// CHECK: store float %real_mul_phi, ptr @ci, align 4, !dbg [[G5R1:!.*]] +// CHECK: store float %imag_mul_phi, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1), align 4, !dbg [[G5R1]] + ci *= ci; + +// div goes straight to lib call, which gets saved into a temp. +// CHECK: %coerce21.real = load float, ptr %coerce21.realp, align 4, !dbg [[G6R2:!.*]] +// CHECK: %coerce21.imag = load float, ptr %coerce21.imagp, align 4, !dbg [[G6R2]] +// CHECK: store float %coerce21.real, ptr @ci, align 4, !dbg [[G6R1:!.*]] +// CHECK: store float %coerce21.imag, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1), align 4, !dbg [[G6R1]] + ci /= ci; + +// CHECK: %add = fadd float %0, %1, !dbg [[G7R2:!.*]] +// CHECK: store float %add, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G7R1:!.*]] __imag ci = __imag ci + __imag ci; } @@ -37,3 +61,9 @@ void test() { // CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1) // CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2) // CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1) +// CHECK: [[G5R2]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 2) +// CHECK: [[G5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1) +// CHECK: [[G6R2]] = !DILocation({{.*}}, atomGroup: 6, atomRank: 2) +// CHECK: [[G6R1]] = !DILocation({{.*}}, atomGroup: 6, atomRank: 1) +// CHECK: [[G7R2]] = !DILocation({{.*}}, atomGroup: 7, atomRank: 2) +// CHECK: [[G7R1]] = !DILocation({{.*}}, atomGroup: 7, atomRank: 1) >From 124588d802bd5b2cc748c95b9cd56d2e592dd8cd Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Fri, 23 May 2025 15:56:22 +0100 Subject: [PATCH 5/8] further expand test --- .../test/DebugInfo/KeyInstructions/complex.c | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/clang/test/DebugInfo/KeyInstructions/complex.c b/clang/test/DebugInfo/KeyInstructions/complex.c index 850f39eaab95c..e89df837045b1 100644 --- a/clang/test/DebugInfo/KeyInstructions/complex.c +++ b/clang/test/DebugInfo/KeyInstructions/complex.c @@ -2,7 +2,7 @@ // 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: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank +// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-C _Complex float ci; float f; @@ -51,6 +51,26 @@ void test() { // CHECK: %add = fadd float %0, %1, !dbg [[G7R2:!.*]] // CHECK: store float %add, ptr getelementptr inbounds nuw ({ float, float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G7R1:!.*]] __imag ci = __imag ci + __imag ci; + +#ifndef __cplusplus +// CHECK-C: %2 = load float, ptr @f, align 4 +// CHECK-C: %add.r24 = fadd float %2, %ci.real22, !dbg [[G9R2:!.*]] +// CHECK-C: store float %add.r24, ptr @f, align 4, !dbg [[G9R1:!.*]] + f += ci; + +// CHECK-C: %3 = load float, ptr @f, align 4 +// CHECK-C: %sub.r27 = fsub float %3, %ci.real25, !dbg [[G11R2:!.*]] +// CHECK-C: store float %sub.r27, ptr @f, align 4, !dbg [[G11R1:!.*]] + f -= ci; + +// CHECK-C: %coerce32.real = load float, ptr %coerce32.realp, align 4, !dbg [[G13R2:!.*]] +// CHECK-C: store float %coerce32.real, ptr @f, align 4, !dbg [[G13R1:!.*]] + f /= ci; + +// CHECK-C: %mul.rl = fmul float %5, %ci.real33, !dbg [[G15R2:!.*]] +// CHECK-C: store float %mul.rl, ptr @f, align 4, !dbg [[G15R1:!.*]] + f *= ci; +#endif } // CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2) @@ -67,3 +87,12 @@ void test() { // CHECK: [[G6R1]] = !DILocation({{.*}}, atomGroup: 6, atomRank: 1) // CHECK: [[G7R2]] = !DILocation({{.*}}, atomGroup: 7, atomRank: 2) // CHECK: [[G7R1]] = !DILocation({{.*}}, atomGroup: 7, atomRank: 1) +// FIXME: These inc by 2 atom groups each time? +// CHECK-C: [[G9R2]] = !DILocation({{.*}}, atomGroup: 9, atomRank: 2) +// CHECK-C: [[G9R1]] = !DILocation({{.*}}, atomGroup: 9, atomRank: 1) +// CHECK-C: [[G11R2]] = !DILocation({{.*}}, atomGroup: 11, atomRank: 2) +// CHECK-C: [[G11R1]] = !DILocation({{.*}}, atomGroup: 11, atomRank: 1) +// CHECK-C: [[G13R2]] = !DILocation({{.*}}, atomGroup: 13, atomRank: 2) +// CHECK-C: [[G13R1]] = !DILocation({{.*}}, atomGroup: 13, atomRank: 1) +// CHECK-C: [[G15R2]] = !DILocation({{.*}}, atomGroup: 15, atomRank: 2) +// CHECK-C: [[G15R1]] = !DILocation({{.*}}, atomGroup: 15, atomRank: 1) >From 84a14fff2cd264f9b4e90ce0ba1d39e014cc186d Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Fri, 23 May 2025 16:36:55 +0100 Subject: [PATCH 6/8] shuffle code, works for cpp --- clang/lib/CodeGen/CGExprComplex.cpp | 8 ++++++-- clang/test/DebugInfo/KeyInstructions/complex.c | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index 600f61f1b325f..74146a3ee9032 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -364,15 +364,19 @@ class ComplexExprEmitter // Compound assignments. ComplexPairTy VisitBinAddAssign(const CompoundAssignOperator *E) { + ApplyAtomGroup Grp(CGF.getDebugInfo()); return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinAdd); } ComplexPairTy VisitBinSubAssign(const CompoundAssignOperator *E) { + ApplyAtomGroup Grp(CGF.getDebugInfo()); return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinSub); } ComplexPairTy VisitBinMulAssign(const CompoundAssignOperator *E) { + ApplyAtomGroup Grp(CGF.getDebugInfo()); return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinMul); } ComplexPairTy VisitBinDivAssign(const CompoundAssignOperator *E) { + ApplyAtomGroup Grp(CGF.getDebugInfo()); return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinDiv); } @@ -1213,7 +1217,6 @@ LValue ComplexExprEmitter:: EmitCompoundAssignLValue(const CompoundAssignOperator *E, ComplexPairTy (ComplexExprEmitter::*Func)(const BinOpInfo&), RValue &Val) { - ApplyAtomGroup Grp(CGF.getDebugInfo()); TestAndClearIgnoreReal(); TestAndClearIgnoreImag(); QualType LHSTy = E->getLHS()->getType(); @@ -1361,8 +1364,8 @@ LValue ComplexExprEmitter::EmitBinAssignLValue(const BinaryOperator *E, } ComplexPairTy ComplexExprEmitter::VisitBinAssign(const BinaryOperator *E) { - ApplyAtomGroup Grp(CGF.getDebugInfo()); ComplexPairTy Val; + ApplyAtomGroup Grp(CGF.getDebugInfo()); LValue LV = EmitBinAssignLValue(E, Val); // The result of an assignment in C is the assigned r-value. @@ -1538,6 +1541,7 @@ static CompoundFunc getComplexOp(BinaryOperatorKind Op) { LValue CodeGenFunction:: EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E) { + ApplyAtomGroup Grp(getDebugInfo()); CompoundFunc Op = getComplexOp(E->getOpcode()); RValue Val; return ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val); diff --git a/clang/test/DebugInfo/KeyInstructions/complex.c b/clang/test/DebugInfo/KeyInstructions/complex.c index e89df837045b1..5b0a2206a0a15 100644 --- a/clang/test/DebugInfo/KeyInstructions/complex.c +++ b/clang/test/DebugInfo/KeyInstructions/complex.c @@ -1,8 +1,8 @@ // 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_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 --check-prefixes=CHECK,CHECK-C +// UN: %clang_cc1 -gkey-instructions -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - \ +// UN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-C _Complex float ci; float f; >From 8203f285d8ec6f93d4c7e5c2ce12572b7b949c69 Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Fri, 23 May 2025 16:37:59 +0100 Subject: [PATCH 7/8] fix c scalar bin-op-assign complex --- clang/lib/CodeGen/CGExprComplex.cpp | 1 + clang/test/DebugInfo/KeyInstructions/complex.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index 74146a3ee9032..ddc7add8db35c 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -1550,6 +1550,7 @@ EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E) { LValue CodeGenFunction:: EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, llvm::Value *&Result) { + ApplyAtomGroup Grp(getDebugInfo()); CompoundFunc Op = getComplexOp(E->getOpcode()); RValue Val; LValue Ret = ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val); diff --git a/clang/test/DebugInfo/KeyInstructions/complex.c b/clang/test/DebugInfo/KeyInstructions/complex.c index 5b0a2206a0a15..e89df837045b1 100644 --- a/clang/test/DebugInfo/KeyInstructions/complex.c +++ b/clang/test/DebugInfo/KeyInstructions/complex.c @@ -1,8 +1,8 @@ // 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 -// UN: %clang_cc1 -gkey-instructions -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - \ -// UN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-C +// 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 --check-prefixes=CHECK,CHECK-C _Complex float ci; float f; >From 70856b8ee7a5b62e265bf62ce68b573653daf029 Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams <orlando.hy...@sony.com> Date: Fri, 23 May 2025 16:57:25 +0100 Subject: [PATCH 8/8] fix c scalar binop assign complex unecessary atom nesting --- clang/lib/CodeGen/CGExprComplex.cpp | 3 ++- .../test/DebugInfo/KeyInstructions/complex.c | 24 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index ddc7add8db35c..f8a946a76554a 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -1550,7 +1550,8 @@ EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E) { LValue CodeGenFunction:: EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, llvm::Value *&Result) { - ApplyAtomGroup Grp(getDebugInfo()); + // Key Instructions: Don't need to create an atom group here; one will already + // be active through scalar handling code. CompoundFunc Op = getComplexOp(E->getOpcode()); RValue Val; LValue Ret = ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val); diff --git a/clang/test/DebugInfo/KeyInstructions/complex.c b/clang/test/DebugInfo/KeyInstructions/complex.c index e89df837045b1..6ce2975454111 100644 --- a/clang/test/DebugInfo/KeyInstructions/complex.c +++ b/clang/test/DebugInfo/KeyInstructions/complex.c @@ -54,21 +54,21 @@ void test() { #ifndef __cplusplus // CHECK-C: %2 = load float, ptr @f, align 4 -// CHECK-C: %add.r24 = fadd float %2, %ci.real22, !dbg [[G9R2:!.*]] -// CHECK-C: store float %add.r24, ptr @f, align 4, !dbg [[G9R1:!.*]] +// CHECK-C: %add.r24 = fadd float %2, %ci.real22, !dbg [[G8R2:!.*]] +// CHECK-C: store float %add.r24, ptr @f, align 4, !dbg [[G8R1:!.*]] f += ci; // CHECK-C: %3 = load float, ptr @f, align 4 -// CHECK-C: %sub.r27 = fsub float %3, %ci.real25, !dbg [[G11R2:!.*]] -// CHECK-C: store float %sub.r27, ptr @f, align 4, !dbg [[G11R1:!.*]] +// CHECK-C: %sub.r27 = fsub float %3, %ci.real25, !dbg [[G9R2:!.*]] +// CHECK-C: store float %sub.r27, ptr @f, align 4, !dbg [[G9R1:!.*]] f -= ci; -// CHECK-C: %coerce32.real = load float, ptr %coerce32.realp, align 4, !dbg [[G13R2:!.*]] -// CHECK-C: store float %coerce32.real, ptr @f, align 4, !dbg [[G13R1:!.*]] +// CHECK-C: %coerce32.real = load float, ptr %coerce32.realp, align 4, !dbg [[G10R2:!.*]] +// CHECK-C: store float %coerce32.real, ptr @f, align 4, !dbg [[G10R1:!.*]] f /= ci; -// CHECK-C: %mul.rl = fmul float %5, %ci.real33, !dbg [[G15R2:!.*]] -// CHECK-C: store float %mul.rl, ptr @f, align 4, !dbg [[G15R1:!.*]] +// CHECK-C: %mul.rl = fmul float %5, %ci.real33, !dbg [[G11R2:!.*]] +// CHECK-C: store float %mul.rl, ptr @f, align 4, !dbg [[G11R1:!.*]] f *= ci; #endif } @@ -88,11 +88,11 @@ void test() { // CHECK: [[G7R2]] = !DILocation({{.*}}, atomGroup: 7, atomRank: 2) // CHECK: [[G7R1]] = !DILocation({{.*}}, atomGroup: 7, atomRank: 1) // FIXME: These inc by 2 atom groups each time? +// CHECK-C: [[G8R2]] = !DILocation({{.*}}, atomGroup: 8, atomRank: 2) +// CHECK-C: [[G8R1]] = !DILocation({{.*}}, atomGroup: 8, atomRank: 1) // CHECK-C: [[G9R2]] = !DILocation({{.*}}, atomGroup: 9, atomRank: 2) // CHECK-C: [[G9R1]] = !DILocation({{.*}}, atomGroup: 9, atomRank: 1) +// CHECK-C: [[G10R2]] = !DILocation({{.*}}, atomGroup: 10, atomRank: 2) +// CHECK-C: [[G10R1]] = !DILocation({{.*}}, atomGroup: 10, atomRank: 1) // CHECK-C: [[G11R2]] = !DILocation({{.*}}, atomGroup: 11, atomRank: 2) // CHECK-C: [[G11R1]] = !DILocation({{.*}}, atomGroup: 11, atomRank: 1) -// CHECK-C: [[G13R2]] = !DILocation({{.*}}, atomGroup: 13, atomRank: 2) -// CHECK-C: [[G13R1]] = !DILocation({{.*}}, atomGroup: 13, atomRank: 1) -// CHECK-C: [[G15R2]] = !DILocation({{.*}}, atomGroup: 15, atomRank: 2) -// CHECK-C: [[G15R1]] = !DILocation({{.*}}, atomGroup: 15, atomRank: 1) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits