Fix PR22386. The inliner moves static allocas to the entry basic block
so we need to move the dbg.declare intrinsics that describe them, too.
llvm-svn: 227544
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 7386186..313728c0 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1111,6 +1111,14 @@
FirstNewBlock->getInstList(),
AI, I);
}
+ // Move any dbg.declares describing the allocas into the entry basic block.
+ for (auto &I : IFI.StaticAllocas)
+ if (auto AI = dyn_cast<AllocaInst>(I))
+ if (auto *DDI = FindAllocaDbgDeclare(AI))
+ if (DDI->getParent() != Caller->begin())
+ Caller->getEntryBlock().getInstList()
+ .splice(AI->getNextNode(), FirstNewBlock->getInstList(),
+ DDI, DDI->getNextNode());
}
bool InlinedMustTailCalls = false;