summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-02-11 19:41:47 +0000
committerReid Kleckner <rnk@google.com>2016-02-11 19:41:47 +0000
commit829365aeef9cde27b00969e7801b0f4844025ca1 (patch)
tree09d3fd4ae60f61f4e8b007cdea21db95c7ec4e08 /llvm/lib/CodeGen
parent1b1c7e977feec17e3c62c035797335bc50623449 (diff)
downloadbcm5719-llvm-829365aeef9cde27b00969e7801b0f4844025ca1.tar.gz
bcm5719-llvm-829365aeef9cde27b00969e7801b0f4844025ca1.zip
[codeview] Fix bug around multi-level wrapper inlining
If there were wrapper functions with no instructions of their own in the inlining tree, we would fail to emit InlineSite records for them. llvm-svn: 260571
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 5473228d0b7..481772944b4 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -117,6 +117,13 @@ CodeViewDebug::InlineSite &CodeViewDebug::getInlineSite(const DILocation *Loc) {
return *Site;
}
+static void addLocIfNotPresent(SmallVectorImpl<const DILocation *> &Locs,
+ const DILocation *Loc) {
+ auto B = Locs.begin(), E = Locs.end();
+ if (std::find(B, E, Loc) == E)
+ Locs.push_back(Loc);
+}
+
void CodeViewDebug::maybeRecordLocation(DebugLoc DL,
const MachineFunction *MF) {
// Skip this instruction if it has the same location as the previous one.
@@ -147,24 +154,24 @@ void CodeViewDebug::maybeRecordLocation(DebugLoc DL,
CurFn->LastLoc = DL;
unsigned FuncId = CurFn->FuncId;
- if (const DILocation *Loc = DL->getInlinedAt()) {
+ if (DL->getInlinedAt()) {
+ const DILocation *Loc = DL.get();
+
// If this location was actually inlined from somewhere else, give it the ID
// of the inline call site.
- FuncId = getInlineSite(DL.get()).SiteFuncId;
- CurFn->ChildSites.push_back(Loc);
+ FuncId = getInlineSite(Loc).SiteFuncId;
+
// Ensure we have links in the tree of inline call sites.
- const DILocation *ChildLoc = nullptr;
- while (Loc->getInlinedAt()) {
+ const DILocation *SiteLoc;
+ bool FirstLoc = true;
+ while ((SiteLoc = Loc->getInlinedAt())) {
InlineSite &Site = getInlineSite(Loc);
- if (ChildLoc) {
- // Record the child inline site if not already present.
- auto B = Site.ChildSites.begin(), E = Site.ChildSites.end();
- if (std::find(B, E, Loc) != E)
- break;
- Site.ChildSites.push_back(Loc);
- }
- ChildLoc = Loc;
+ if (!FirstLoc)
+ addLocIfNotPresent(Site.ChildSites, Loc);
+ FirstLoc = false;
+ Loc = SiteLoc;
}
+ addLocIfNotPresent(CurFn->ChildSites, Loc);
}
OS.EmitCVLocDirective(FuncId, FileId, DL.getLine(), DL.getCol(),
OpenPOWER on IntegriCloud