aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorYuanfang Chen <yuanfang.chen@sony.com>2023-03-15 10:14:58 -0700
committerYuanfang Chen <yuanfang.chen@sony.com>2023-03-15 10:30:28 -0700
commite7a2da5298dc90527c05441485def6c7b04e226a (patch)
treef7433ed0a3fc08b842b64a0bf47cb1b6b461f98f /llvm/lib/Transforms/Utils/InlineFunction.cpp
parent471ab69f5bfaef22012996fe3a15b2e9edbded66 (diff)
downloadllvm-e7a2da5298dc90527c05441485def6c7b04e226a.zip
llvm-e7a2da5298dc90527c05441485def6c7b04e226a.tar.gz
llvm-e7a2da5298dc90527c05441485def6c7b04e226a.tar.bz2
[Inliner] Assign dummy debug location to the memcpy for byval argument
A similar fix to D133095. Fixes https://github.com/llvm/llvm-project/issues/58770. Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D145607
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 2061738..4746916 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1537,7 +1537,8 @@ static void UpdateCallGraphAfterInlining(CallBase &CB,
static void HandleByValArgumentInit(Type *ByValType, Value *Dst, Value *Src,
Module *M, BasicBlock *InsertBlock,
- InlineFunctionInfo &IFI) {
+ InlineFunctionInfo &IFI,
+ Function *CalledFunc) {
IRBuilder<> Builder(InsertBlock, InsertBlock->begin());
Value *Size =
@@ -1546,8 +1547,15 @@ static void HandleByValArgumentInit(Type *ByValType, Value *Dst, Value *Src,
// Always generate a memcpy of alignment 1 here because we don't know
// the alignment of the src pointer. Other optimizations can infer
// better alignment.
- Builder.CreateMemCpy(Dst, /*DstAlign*/ Align(1), Src,
- /*SrcAlign*/ Align(1), Size);
+ CallInst *CI = Builder.CreateMemCpy(Dst, /*DstAlign*/ Align(1), Src,
+ /*SrcAlign*/ Align(1), Size);
+
+ // The verifier requires that all calls of debug-info-bearing functions
+ // from debug-info-bearing functions have a debug location (for inlining
+ // purposes). Assign a dummy location to satisfy the constraint.
+ if (!CI->getDebugLoc() && InsertBlock->getParent()->getSubprogram())
+ if (DISubprogram *SP = CalledFunc->getSubprogram())
+ CI->setDebugLoc(DILocation::get(SP->getContext(), 0, 0, SP));
}
/// When inlining a call site that has a byval argument,
@@ -2242,7 +2250,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
// Inject byval arguments initialization.
for (ByValInit &Init : ByValInits)
HandleByValArgumentInit(Init.Ty, Init.Dst, Init.Src, Caller->getParent(),
- &*FirstNewBlock, IFI);
+ &*FirstNewBlock, IFI, CalledFunc);
std::optional<OperandBundleUse> ParentDeopt =
CB.getOperandBundle(LLVMContext::OB_deopt);