diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 4a8f7f6a42ecb..d02f2ad09d2f1 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1925,6 +1925,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { const VarDecl &D = *emission.Variable; auto DL = ApplyDebugLocation::CreateDefaultArtificial(*this, D.getLocation()); + ApplyAtomGroup Grp(getDebugInfo()); QualType type = D.getType(); // If this local has an initializer, emit it now. diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 708002a7f9ab3..1e426586620a2 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -2222,6 +2222,8 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr, } llvm::StoreInst *Store = Builder.CreateStore(Value, Addr, Volatile); + addInstToCurrentSourceAtom(Store, Value); + if (isNontemporal) { llvm::MDNode *Node = llvm::MDNode::get(Store->getContext(), diff --git a/clang/test/DebugInfo/KeyInstructions/init-scalar.c b/clang/test/DebugInfo/KeyInstructions/init-scalar.c new file mode 100644 index 0000000000000..a86c029e47e8c --- /dev/null +++ b/clang/test/DebugInfo/KeyInstructions/init-scalar.c @@ -0,0 +1,17 @@ +// 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 + +void a() { +// CHECK: store i32 0, ptr %A{{.*}}, !dbg [[G1R1:!.*]] + int A = 0; +// CHECK: %add = add {{.*}}, !dbg [[G2R2:!.*]] +// CHECK: store i32 %add, ptr %B, align 4, !dbg [[G2R1:!.*]] + int B = 2 * A + 1; +} + +// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1) +// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2) +// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)