diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-03-07 17:28:57 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-03-07 17:28:57 +0000 |
commit | d4056501fbda79f6d9100a483762daa173403caa (patch) | |
tree | 55eb3cbe2fbc3cf01de56abbd1ecd7a8068af30a /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | 51ee7bb06f03a279a9898c89638701c4c97334ba (diff) | |
download | llvm-d4056501fbda79f6d9100a483762daa173403caa.zip llvm-d4056501fbda79f6d9100a483762daa173403caa.tar.gz llvm-d4056501fbda79f6d9100a483762daa173403caa.tar.bz2 |
Revert "Strip debug info when inlining into a nodebug function."
This reverts commit r296488.
As noted by David Blaikie on llvm-commits, I overlooked the case of a
debug function being inlined into a nodebug function being inlined
into a debug function.
llvm-svn: 297163
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 9873e8e..bd3aa8d 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1343,26 +1343,22 @@ static bool allocaWouldBeStaticInEntry(const AllocaInst *AI ) { return isa<Constant>(AI->getArraySize()) && !AI->isUsedWithInAlloca(); } -/// Update inlined instructions' line numbers to to encode location where these -/// instructions are inlined. Also strip all debug intrinsics that were inlined -/// into a nodebug function; there is no debug info the backend could produce -/// for a function without a DISubprogram attachment. -static void fixupDebugInfo(Function *Fn, Function::iterator FI, - Instruction *TheCall, bool CalleeHasDebugInfo) { - bool CallerHasDebugInfo = Fn->getSubprogram(); - bool StripDebugInfo = !CallerHasDebugInfo && CalleeHasDebugInfo; - SmallVector<DbgInfoIntrinsic *, 8> IntrinsicsToErase; +/// Update inlined instructions' line numbers to +/// to encode location where these instructions are inlined. +static void fixupLineNumbers(Function *Fn, Function::iterator FI, + Instruction *TheCall, bool CalleeHasDebugInfo) { const DebugLoc &TheCallDL = TheCall->getDebugLoc(); + if (!TheCallDL) + return; auto &Ctx = Fn->getContext(); - DILocation *InlinedAtNode = nullptr; + DILocation *InlinedAtNode = TheCallDL; // Create a unique call site, not to be confused with any other call from the // same location. - if (TheCallDL) - InlinedAtNode = DILocation::getDistinct( - Ctx, TheCallDL->getLine(), TheCallDL->getColumn(), - TheCallDL->getScope(), TheCallDL->getInlinedAt()); + InlinedAtNode = DILocation::getDistinct( + Ctx, InlinedAtNode->getLine(), InlinedAtNode->getColumn(), + InlinedAtNode->getScope(), InlinedAtNode->getInlinedAt()); // Cache the inlined-at nodes as they're built so they are reused, without // this every instruction's inlined-at chain would become distinct from each @@ -1372,17 +1368,6 @@ static void fixupDebugInfo(Function *Fn, Function::iterator FI, for (; FI != Fn->end(); ++FI) { for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI) { - if (StripDebugInfo) { - // Inlining into a nodebug function. - if (auto *DI = dyn_cast<DbgInfoIntrinsic>(BI)) - // Mark dead debug intrinsics for deletion. - IntrinsicsToErase.push_back(DI); - else - // Remove the dangling debug location. - BI->setDebugLoc(DebugLoc()); - continue; - } - if (DebugLoc DL = BI->getDebugLoc()) { BI->setDebugLoc( updateInlinedAtInfo(DL, InlinedAtNode, BI->getContext(), IANodes)); @@ -1405,9 +1390,6 @@ static void fixupDebugInfo(Function *Fn, Function::iterator FI, BI->setDebugLoc(TheCallDL); } } - - for (auto *DI : IntrinsicsToErase) - DI->eraseFromParent(); } /// Update the block frequencies of the caller after a callee has been inlined. /// @@ -1728,8 +1710,8 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI, // For 'nodebug' functions, the associated DISubprogram is always null. // Conservatively avoid propagating the callsite debug location to // instructions inlined from a function whose DISubprogram is not null. - fixupDebugInfo(Caller, FirstNewBlock, TheCall, - CalledFunc->getSubprogram() != nullptr); + fixupLineNumbers(Caller, FirstNewBlock, TheCall, + CalledFunc->getSubprogram() != nullptr); // Clone existing noalias metadata if necessary. CloneAliasScopeMetadata(CS, VMap); |