diff options
| author | Reid Kleckner <rnk@google.com> | 2018-04-25 23:34:15 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2018-04-25 23:34:15 +0000 |
| commit | 2c6430fe3c2005a60680b72a52bfb4e81ca841ee (patch) | |
| tree | 28e62f54a215254efc9790922a5cfed6861e7890 /llvm/lib | |
| parent | 947647d0c1fd9557f2dd8ddda3a15622da2c7f77 (diff) | |
| download | bcm5719-llvm-2c6430fe3c2005a60680b72a52bfb4e81ca841ee.tar.gz bcm5719-llvm-2c6430fe3c2005a60680b72a52bfb4e81ca841ee.zip | |
[codeview] Ignore .cv_loc directives at the end of a function
If no data or instructions are emitted after a location directive, we
should clear the cv_loc when we change sections, or it will be emitted
at the beginning of the next section. This violates our invariant that
all .cv_loc directives belong to the same section. Add clearer
assertions for this.
llvm-svn: 330884
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/MC/MCCodeView.cpp | 13 | ||||
| -rw-r--r-- | llvm/lib/MC/MCContext.cpp | 5 | ||||
| -rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp index 8247db1c622..7d79fc74c18 100644 --- a/llvm/lib/MC/MCCodeView.cpp +++ b/llvm/lib/MC/MCCodeView.cpp @@ -472,6 +472,19 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout, if (Locs.empty()) return; + // Check that the locations are all in the same section. +#ifndef NDEBUG + const MCSection *FirstSec = &Locs.front().getLabel()->getSection(); + for (const MCCVLineEntry &Loc : Locs) { + if (&Loc.getLabel()->getSection() != FirstSec) { + errs() << ".cv_loc " << Loc.getFunctionId() << ' ' << Loc.getFileNum() + << ' ' << Loc.getLine() << ' ' << Loc.getColumn() + << " is in the wrong section\n"; + llvm_unreachable(".cv_loc crosses sections"); + } + } +#endif + // Make an artificial start location using the function start and the inlinee // lines start location information. All deltas start relative to this // location. diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 69c10f535e5..ac9259a4d24 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -570,6 +570,11 @@ CodeViewContext &MCContext::getCVContext() { return *CVContext.get(); } +void MCContext::clearCVLocSeen() { + if (CVContext) + CVContext->clearCVLocSeen(); +} + //===----------------------------------------------------------------------===// // Error Reporting //===----------------------------------------------------------------------===// diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 0a684588110..316a3be8d89 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -247,6 +247,7 @@ bool MCObjectStreamer::changeSectionImpl(MCSection *Section, const MCExpr *Subsection) { assert(Section && "Cannot switch to a null section!"); flushPendingLabels(nullptr); + getContext().clearCVLocSeen(); getContext().clearDwarfLocSeen(); bool Created = getAssembler().registerSection(*Section); |

