diff options
author | Reid Kleckner <rnk@google.com> | 2018-01-18 22:55:43 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2018-01-18 22:55:43 +0000 |
commit | 7897a789e7f138f928e3a9fecbb709ee043b44fe (patch) | |
tree | 0493bebc5611620b04088bf23db9f429484eec92 /llvm/lib/MC/MCCodeView.cpp | |
parent | b5258722889112188d255140654163fdd4e1fbe7 (diff) | |
download | llvm-7897a789e7f138f928e3a9fecbb709ee043b44fe.zip llvm-7897a789e7f138f928e3a9fecbb709ee043b44fe.tar.gz llvm-7897a789e7f138f928e3a9fecbb709ee043b44fe.tar.bz2 |
[CodeView] Add line numbers for inlined call sites
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.
llvm-svn: 322905
Diffstat (limited to 'llvm/lib/MC/MCCodeView.cpp')
-rw-r--r-- | llvm/lib/MC/MCCodeView.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp index 3a3d7f2..8247db1 100644 --- a/llvm/lib/MC/MCCodeView.cpp +++ b/llvm/lib/MC/MCCodeView.cpp @@ -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; } |