From dbcb7adb0342b07b0f7385ab2cdd523bccb99963 Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Wed, 7 Dec 2016 12:01:45 +0000 Subject: [PATCH] [InlineFunction] Refactor code in function `fixupLineNumbers' as suggested by David in D27462. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288901 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/InlineFunction.cpp | 34 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index c9f2f72a0de..ee083f91c7a 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -1372,24 +1372,26 @@ static void fixupLineNumbers(Function *Fn, Function::iterator FI, for (; FI != Fn->end(); ++FI) { for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI) { - DebugLoc DL = BI->getDebugLoc(); - if (!DL) { - if (CalleeHasDebugInfo) + if (DebugLoc DL = BI->getDebugLoc()) { + BI->setDebugLoc( + updateInlinedAtInfo(DL, InlinedAtNode, BI->getContext(), IANodes)); + continue; + } + + if (CalleeHasDebugInfo) + continue; + + // If the inlined instruction has no line number, make it look as if it + // originates from the call location. This is important for + // ((__always_inline__, __nodebug__)) functions which must use caller + // location for all instructions in their function body. + + // Don't update static allocas, as they may get moved later. + if (auto *AI = dyn_cast(BI)) + if (allocaWouldBeStaticInEntry(AI)) continue; - // If the inlined instruction has no line number, make it look as if it - // originates from the call location. This is important for - // ((__always_inline__, __nodebug__)) functions which must use caller - // location for all instructions in their function body. - - // Don't update static allocas, as they may get moved later. - if (auto *AI = dyn_cast(BI)) - if (allocaWouldBeStaticInEntry(AI)) - continue; - BI->setDebugLoc(TheCallDL); - } else { - BI->setDebugLoc(updateInlinedAtInfo(DL, InlinedAtNode, BI->getContext(), IANodes)); - } + BI->setDebugLoc(TheCallDL); } } } -- 2.11.0