Skip to content

Commit 0065d06

Browse files
authored
[NFC][DebugInfo] Maintain RemoveDIs flag when attributor creates functions (#79143)
We're using this flag (IsNewDbgInfoFormat) to detect the boundaries in LLVM of what's treating debug-info as intrinsics (i.e. dbg.value), and what's using DPValue objects (the non-intrinsic replacement). The attributor tends to create new wrapper functions and doesn't insert them into Modules in the usual way, thus we have to manually update that flag to signal what debug-info mode it's using. I've added some --try-experimental-debuginfo-iterators RUN lines to tests that would otherwise crash because of this, so that they're exercised by our new-debuginfo-iterators buildbot. NB: there's an attributor test with a dbg.value in it, however attributes re-order themselves in RemoveDIs mode for various reasons, so we're going to address that in a different patch.
1 parent 9fc890b commit 0065d06

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,6 +2738,8 @@ void Attributor::createShallowWrapper(Function &F) {
27382738
Function::Create(FnTy, F.getLinkage(), F.getAddressSpace(), F.getName());
27392739
F.setName(""); // set the inside function anonymous
27402740
M.getFunctionList().insert(F.getIterator(), Wrapper);
2741+
// Flag whether the function is using new-debug-info or not.
2742+
Wrapper->IsNewDbgInfoFormat = M.IsNewDbgInfoFormat;
27412743

27422744
F.setLinkage(GlobalValue::InternalLinkage);
27432745

@@ -2818,6 +2820,8 @@ bool Attributor::internalizeFunctions(SmallPtrSetImpl<Function *> &FnSet,
28182820
VMap[&Arg] = &(*NewFArgIt++);
28192821
}
28202822
SmallVector<ReturnInst *, 8> Returns;
2823+
// Flag whether the function is using new-debug-info or not.
2824+
Copied->IsNewDbgInfoFormat = F->IsNewDbgInfoFormat;
28212825

28222826
// Copy the body of the original function to the new one
28232827
CloneFunctionInto(Copied, F, VMap,
@@ -3035,6 +3039,8 @@ ChangeStatus Attributor::rewriteFunctionSignatures(
30353039
OldFn->getParent()->getFunctionList().insert(OldFn->getIterator(), NewFn);
30363040
NewFn->takeName(OldFn);
30373041
NewFn->copyAttributesFrom(OldFn);
3042+
// Flag whether the function is using new-debug-info or not.
3043+
NewFn->IsNewDbgInfoFormat = OldFn->IsNewDbgInfoFormat;
30383044

30393045
// Patch the pointer to LLVM function in debug info descriptor.
30403046
NewFn->setSubprogram(OldFn->getSubprogram());

llvm/test/Transforms/Attributor/ArgumentPromotion/alignment.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
33
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
44

5+
;; Test with RemoveDIs debug-info mode to exercise a potential crash path.
6+
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s --try-experimental-debuginfo-iterators | FileCheck %s --check-prefixes=CHECK,TUNIT
7+
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s --try-experimental-debuginfo-iterators | FileCheck %s --check-prefixes=CHECK,CGSCC
8+
59
define void @f() {
610
; TUNIT-LABEL: define {{[^@]+}}@f() {
711
; TUNIT-NEXT: entry:

0 commit comments

Comments
 (0)