diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index d8e290cbc8a4d..5d1a783b2996d 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -2738,6 +2738,8 @@ void Attributor::createShallowWrapper(Function &F) { Function::Create(FnTy, F.getLinkage(), F.getAddressSpace(), F.getName()); F.setName(""); // set the inside function anonymous M.getFunctionList().insert(F.getIterator(), Wrapper); + // Flag whether the function is using new-debug-info or not. + Wrapper->IsNewDbgInfoFormat = M.IsNewDbgInfoFormat; F.setLinkage(GlobalValue::InternalLinkage); @@ -2818,6 +2820,8 @@ bool Attributor::internalizeFunctions(SmallPtrSetImpl &FnSet, VMap[&Arg] = &(*NewFArgIt++); } SmallVector Returns; + // Flag whether the function is using new-debug-info or not. + Copied->IsNewDbgInfoFormat = F->IsNewDbgInfoFormat; // Copy the body of the original function to the new one CloneFunctionInto(Copied, F, VMap, @@ -3035,6 +3039,8 @@ ChangeStatus Attributor::rewriteFunctionSignatures( OldFn->getParent()->getFunctionList().insert(OldFn->getIterator(), NewFn); NewFn->takeName(OldFn); NewFn->copyAttributesFrom(OldFn); + // Flag whether the function is using new-debug-info or not. + NewFn->IsNewDbgInfoFormat = OldFn->IsNewDbgInfoFormat; // Patch the pointer to LLVM function in debug info descriptor. NewFn->setSubprogram(OldFn->getSubprogram()); diff --git a/llvm/test/Transforms/Attributor/ArgumentPromotion/alignment.ll b/llvm/test/Transforms/Attributor/ArgumentPromotion/alignment.ll index 9ae21ca44ee8c..54a5b8c564077 100644 --- a/llvm/test/Transforms/Attributor/ArgumentPromotion/alignment.ll +++ b/llvm/test/Transforms/Attributor/ArgumentPromotion/alignment.ll @@ -2,6 +2,10 @@ ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC +;; Test with RemoveDIs debug-info mode to exercise a potential crash path. +; 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 +; 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 + define void @f() { ; TUNIT-LABEL: define {{[^@]+}}@f() { ; TUNIT-NEXT: entry: