Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/CodeGen/CGVTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ static void resolveTopLevelMetadata(llvm::Function *Fn,
if (!DIS)
return;
auto *NewDIS = llvm::MDNode::replaceWithDistinct(DIS->clone());
// As DISubprogram remapping is avoided, clear retained nodes list of
// cloned DISubprogram from retained nodes local to original DISubprogram.
// FIXME: Thunk function signature is produced wrong in DWARF, as retained
// nodes are not remapped.
NewDIS->replaceRetainedNodes(llvm::MDTuple::get(Fn->getContext(), {}));
VMap.MD()[DIS].reset(NewDIS);

// Find all llvm.dbg.declare intrinsics and resolve the DILocalVariable nodes
Expand Down
16 changes: 16 additions & 0 deletions clang/test/CodeGenCXX/tmp-md-nodes1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
// RUN: %clang_cc1 -O0 -triple %itanium_abi_triple -debug-info-kind=limited -emit-llvm %s -o - | \
// RUN: FileCheck %s

// Trigger GenerateVarArgsThunk.
// RUN: %clang_cc1 -O0 -triple riscv64-linux-gnu -debug-info-kind=limited -emit-llvm %s -o - | \
// RUN: FileCheck %s

// Check that retainedNodes are properly maintained at function cloning.
// RUN: %clang_cc1 -O1 -triple riscv64-linux-gnu -debug-info-kind=limited -emit-llvm %s -o - | \
// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-DI

// This test simply checks that the varargs thunk is created. The failing test
// case asserts.

Expand All @@ -16,3 +24,11 @@ struct CharlieImpl : Charlie, Alpha {
} delta;

// CHECK: define {{.*}} void @_ZThn{{[48]}}_N11CharlieImpl5bravoEz(

// CHECK-DI: distinct !DISubprogram({{.*}}, linkageName: "_ZN11CharlieImpl5bravoEz", {{.*}}, retainedNodes: [[RN1:![0-9]+]]
// A non-empty retainedNodes list of original DISubprogram.
// CHECK-DI: [[RN1]] = !{!{{.*}}}

// CHECK-DI: distinct !DISubprogram({{.*}}, linkageName: "_ZN11CharlieImpl5bravoEz", {{.*}}, retainedNodes: [[EMPTY:![0-9]+]]
// An empty retainedNodes list of cloned DISubprogram.
// CHECK-DI: [[EMPTY]] = !{}
16 changes: 16 additions & 0 deletions clang/test/CodeGenCXX/tmp-md-nodes2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
// RUN: %clang_cc1 -O0 -triple %itanium_abi_triple -debug-info-kind=limited -emit-llvm %s -o - | \
// RUN: FileCheck %s

// Trigger GenerateVarArgsThunk.
// RUN: %clang_cc1 -O0 -triple riscv64-linux-gnu -debug-info-kind=limited -emit-llvm %s -o - | \
// RUN: FileCheck %s

// Check that retainedNodes are properly maintained at function cloning.
// RUN: %clang_cc1 -O1 -triple riscv64-linux-gnu -debug-info-kind=limited -emit-llvm %s -o - | \
// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-DI

// This test simply checks that the varargs thunk is created. The failing test
// case asserts.

Expand Down Expand Up @@ -31,3 +39,11 @@ BOOL CBdVfsImpl::ReqCacheHint( CMsgAgent* p_ma, CACHE_HINT hint, ... ) {
}

// CHECK: define {{.*}} @_ZThn{{[48]}}_N10CBdVfsImpl12ReqCacheHintEP9CMsgAgentN3CFs10CACHE_HINTEz(

// An empty retainedNodes list of cloned DISubprogram.
// CHECK-DI: [[EMPTY:![0-9]+]] = !{}
// CHECK-DI: distinct !DISubprogram({{.*}}, linkageName: "_ZN10CBdVfsImpl12ReqCacheHintEP9CMsgAgentN3CFs10CACHE_HINTEz", {{.*}}, retainedNodes: [[RN1:![0-9]+]]
// A non-empty retainedNodes list of original DISubprogram.
// CHECK-DI: [[RN1]] = !{!{{.*}}}

// CHECK-DI: distinct !DISubprogram({{.*}}, linkageName: "_ZN10CBdVfsImpl12ReqCacheHintEP9CMsgAgentN3CFs10CACHE_HINTEz", {{.*}}, retainedNodes: [[EMPTY]]
Loading