[PATCH] D19436: Update discriminator assignment algorithm in clang assembler.

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 14:31:04 PDT 2016


danielcdh created this revision.
danielcdh added reviewers: dnovillo, davidxl.
danielcdh added a subscriber: llvm-commits.

The clang assembler assumes that the discriminator remains the same when there is source line change. The correct behavior is that when there is line change, discriminator will automatically reset to 0.

http://reviews.llvm.org/D19436

Files:
  lib/MC/MCDwarf.cpp

Index: lib/MC/MCDwarf.cpp
===================================================================
--- lib/MC/MCDwarf.cpp
+++ lib/MC/MCDwarf.cpp
@@ -112,6 +112,12 @@
             ie = LineEntries.end();
        it != ie; ++it) {
 
+    int64_t LineDelta = static_cast<int64_t>(it->getLine()) - LastLine;
+
+    // Discriminator will be cleared if there is line change.
+    if (LineDelta != 0)
+      Discriminator = 0;
+
     if (FileNum != it->getFileNum()) {
       FileNum = it->getFileNum();
       MCOS->EmitIntValue(dwarf::DW_LNS_set_file, 1);
@@ -146,7 +152,6 @@
     if (it->getFlags() & DWARF2_FLAG_EPILOGUE_BEGIN)
       MCOS->EmitIntValue(dwarf::DW_LNS_set_epilogue_begin, 1);
 
-    int64_t LineDelta = static_cast<int64_t>(it->getLine()) - LastLine;
     MCSymbol *Label = it->getLabel();
 
     // At this point we want to emit/create the sequence to encode the delta in


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19436.54726.patch
Type: text/x-patch
Size: 881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160422/32b33804/attachment.bin>


More information about the llvm-commits mailing list