diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-02-02 19:22:34 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-02-02 19:22:34 +0000 |
commit | c9911f28e5a8060a439aa475e0a95793b1b1e970 (patch) | |
tree | 1292f7b899d8f09ff4c194fea492b3b7ff8ecd6c /llvm/lib/MC/MCCodeView.cpp | |
parent | e5737f7cacd925aabc3b0d079928d43a4dfdc4a3 (diff) | |
download | llvm-c9911f28e5a8060a439aa475e0a95793b1b1e970.zip llvm-c9911f28e5a8060a439aa475e0a95793b1b1e970.tar.gz llvm-c9911f28e5a8060a439aa475e0a95793b1b1e970.tar.bz2 |
[codeview] Correctly handle inlining functions post-dominated by unreachable
CodeView requires us to accurately describe the extent of the inlined
code. We did this by grabbing the next debug location in source order
and using *that* to denote where we stopped inlining. However, this is
not sufficient or correct in instances where there is no next debug
location or the next debug location belongs to the start of another
function.
To get this correct, use the end symbol of the function to denote the
last possible place the inlining could have stopped at.
llvm-svn: 259548
Diffstat (limited to 'llvm/lib/MC/MCCodeView.cpp')
-rw-r--r-- | llvm/lib/MC/MCCodeView.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp index ea226f7..81597f6 100644 --- a/llvm/lib/MC/MCCodeView.cpp +++ b/llvm/lib/MC/MCCodeView.cpp @@ -228,11 +228,11 @@ static uint32_t encodeSignedNumber(uint32_t Data) { void CodeViewContext::emitInlineLineTableForFunction( MCObjectStreamer &OS, unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, - ArrayRef<unsigned> SecondaryFunctionIds) { + const MCSymbol *FnEndSym, ArrayRef<unsigned> SecondaryFunctionIds) { // Create and insert a fragment into the current section that will be encoded // later. new MCCVInlineLineTableFragment( - PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, + PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym, SecondaryFunctionIds, OS.getCurrentSectionOnly()); } @@ -265,7 +265,7 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout, } if (LocBegin >= LocEnd) return; - ArrayRef<MCCVLineEntry> Locs = getLinesForExtent(LocBegin, LocEnd + 1); + ArrayRef<MCCVLineEntry> Locs = getLinesForExtent(LocBegin, LocEnd); if (Locs.empty()) return; @@ -331,6 +331,19 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout, LastLoc = &Loc; } + + assert(WithinFunction); + + unsigned EndSymLength = + computeLabelDiff(Layout, LastLoc->getLabel(), Frag.getFnEndSym()); + unsigned LocAfterLength = ~0U; + ArrayRef<MCCVLineEntry> LocAfter = getLinesForExtent(LocEnd, LocEnd + 1); + if (!LocAfter.empty()) + LocAfterLength = + computeLabelDiff(Layout, LastLoc->getLabel(), LocAfter[0].getLabel()); + + compressAnnotation(ChangeCodeLength, Buffer); + compressAnnotation(std::min(EndSymLength, LocAfterLength), Buffer); } // |