Skip to content

Commit a042a0f

Browse files
author
git apple-llvm automerger
committed
Merge commit 'c4d0d95a4fb9' from llvm.org/main into next
2 parents dcf1fab + c4d0d95 commit a042a0f

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "clang/CodeGen/CGFunctionInfo.h"
3737
#include "clang/Frontend/FrontendDiagnostic.h"
3838
#include "llvm/ADT/ArrayRef.h"
39+
#include "llvm/ADT/ScopeExit.h"
3940
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
4041
#include "llvm/IR/DataLayout.h"
4142
#include "llvm/IR/Dominators.h"
@@ -1554,6 +1555,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
15541555
// Disable debug info indefinitely for this function
15551556
DebugInfo = nullptr;
15561557
}
1558+
// Finalize function debug info on exit.
1559+
auto Cleanup = llvm::make_scope_exit([this] {
1560+
if (CGDebugInfo *DI = getDebugInfo())
1561+
DI->completeFunction();
1562+
});
15571563

15581564
// The function might not have a body if we're generating thunks for a
15591565
// function declaration.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// 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 - \
2+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
3+
4+
// 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 - \
5+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
6+
7+
// Check atomGroup is reset to start at 1 in each function.
8+
9+
int g;
10+
// CHECK: store{{.*}}, !dbg [[AG:!.*]]
11+
void a() { g = 0; }
12+
13+
// CHECK: store{{.*}}, !dbg [[BG:!.*]]
14+
void b() { g = 0; }
15+
16+
// CHECK: [[A:!.*]] = distinct !DISubprogram(name: "a",
17+
// CHECK: [[AG]] = !DILocation(line: 11, scope: [[A]], atomGroup: 1, atomRank: 1)
18+
// CHECK: [[B:!.*]] = distinct !DISubprogram(name: "b",
19+
// CHECK: [[BG]] = !DILocation(line: 14, scope: [[B]], atomGroup: 1, atomRank: 1)

0 commit comments

Comments
 (0)