aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCCodeView.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2018-04-25 23:34:15 +0000
committerReid Kleckner <rnk@google.com>2018-04-25 23:34:15 +0000
commit2c6430fe3c2005a60680b72a52bfb4e81ca841ee (patch)
tree28e62f54a215254efc9790922a5cfed6861e7890 /llvm/lib/MC/MCCodeView.cpp
parent947647d0c1fd9557f2dd8ddda3a15622da2c7f77 (diff)
downloadllvm-2c6430fe3c2005a60680b72a52bfb4e81ca841ee.zip
llvm-2c6430fe3c2005a60680b72a52bfb4e81ca841ee.tar.gz
llvm-2c6430fe3c2005a60680b72a52bfb4e81ca841ee.tar.bz2
[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/MC/MCCodeView.cpp')
-rw-r--r--llvm/lib/MC/MCCodeView.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp
index 8247db1..7d79fc7 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.