Skip to content

Commit

Permalink
[CodeView] Add line numbers for inlined call sites
Browse files Browse the repository at this point in the history
We did this for inline call site line tables, but we hadn't done it for
regular function line tables yet. This patch copies that logic from
encodeInlineLineTable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322905 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rnk committed Jan 18, 2018
1 parent 1ef4dbf commit cbd60f7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
30 changes: 27 additions & 3 deletions lib/MC/MCCodeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,35 @@ std::vector<MCCVLineEntry>
CodeViewContext::getFunctionLineEntries(unsigned FuncId) {
std::vector<MCCVLineEntry> FilteredLines;
auto I = MCCVLineStartStop.find(FuncId);
if (I != MCCVLineStartStop.end())
if (I != MCCVLineStartStop.end()) {
MCCVFunctionInfo *SiteInfo = getCVFunctionInfo(FuncId);
for (size_t Idx = I->second.first, End = I->second.second; Idx != End;
++Idx)
if (MCCVLines[Idx].getFunctionId() == FuncId)
++Idx) {
unsigned LocationFuncId = MCCVLines[Idx].getFunctionId();
if (LocationFuncId == FuncId) {
// This was a .cv_loc directly for FuncId, so record it.
FilteredLines.push_back(MCCVLines[Idx]);
} else {
// Check if the current location is inlined in this function. If it is,
// synthesize a statement .cv_loc at the original inlined call site.
auto I = SiteInfo->InlinedAtMap.find(LocationFuncId);
if (I != SiteInfo->InlinedAtMap.end()) {
MCCVFunctionInfo::LineInfo &IA = I->second;
// Only add the location if it differs from the previous location.
// Large inlined calls will have many .cv_loc entries and we only need
// one line table entry in the parent function.
if (FilteredLines.empty() ||
FilteredLines.back().getFileNum() != IA.File ||
FilteredLines.back().getLine() != IA.Line ||
FilteredLines.back().getColumn() != IA.Col) {
FilteredLines.push_back(MCCVLineEntry(
MCCVLines[Idx].getLabel(),
MCCVLoc(FuncId, IA.File, IA.Line, IA.Col, false, false)));
}
}
}
}
}
return FilteredLines;
}

Expand Down
26 changes: 26 additions & 0 deletions test/MC/COFF/cv-inline-linetable.s
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,29 @@ Ltmp1:
.cv_filechecksums # File index to string table offset subsection
.cv_stringtable # String table

# CHECK-LABEL: FunctionLineTable [
# CHECK: LinkageName: ?baz@@YAXXZ
# CHECK: Flags: 0x1
# CHECK: CodeSize: 0x3D
# CHECK: FilenameSegment [
# CHECK: Filename: D:\src\llvm\build\t.cpp (0x0)
# CHECK: +0x0 [
# CHECK: LineNumberStart: 13
# CHECK: ]
# CHECK: +0x1 [
# CHECK: LineNumberStart: 14
# CHECK: ]
# CHECK: +0x8 [
# CHECK: LineNumberStart: 15
# CHECK: ]
# There shouldn't be any other line number entries because all the other
# .cv_locs are on line 15 where the top-level inline call site is.
# CHECK-NOT: LineNumberStart
# CHECK: +0x34 [
# CHECK: LineNumberStart: 16
# CHECK: ]
# CHECK: +0x3B [
# CHECK: LineNumberStart: 17
# CHECK: ]
# CHECK: ]
# CHECK: ]

0 comments on commit cbd60f7

Please sign in to comment.