mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 02:06:30 +00:00
[KeyInstr][Clang] Static variable init 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
This commit is contained in:
parent
eef73d31b6
commit
a92afbf589
@ -428,8 +428,10 @@ void CodeGenFunction::EmitStaticVarDecl(const VarDecl &D,
|
||||
bool isCudaSharedVar = getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
|
||||
D.hasAttr<CUDASharedAttr>();
|
||||
// If this value has an initializer, emit it.
|
||||
if (D.getInit() && !isCudaSharedVar)
|
||||
if (D.getInit() && !isCudaSharedVar) {
|
||||
ApplyAtomGroup Grp(getDebugInfo());
|
||||
var = AddInitializerToStaticVarDecl(D, var);
|
||||
}
|
||||
|
||||
var->setAlignment(alignment.getAsAlign());
|
||||
|
||||
|
12
clang/test/KeyInstructions/init-static.cpp
Normal file
12
clang/test/KeyInstructions/init-static.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
// RUN: %clang -gkey-instructions %s -gmlt -gcolumn-info -S -emit-llvm -o -\
|
||||
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
|
||||
|
||||
void g(int *a) {
|
||||
// CHECK: %2 = load ptr, ptr %a.addr{{.*}}, !dbg [[G1R2:!.*]]
|
||||
// CHECK: store ptr %2, ptr @_ZZ1gPiE1b{{.*}}, !dbg [[G1R1:!.*]]
|
||||
static int &b = *a;
|
||||
}
|
||||
|
||||
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
|
||||
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user