[PATCH] IAS: Use the root macro instanciation for location

Frederic Riss friss at apple.com
Mon Jun 15 16:58:08 PDT 2015


Hi compnerd,

In r224810 you fixed the handling of debug locations in AsmParser. I think this
patch brings it closer to what you ireally wanted (or I misunderstood the logic
there): it uses the first macro of the macro stack instead of the last one. The
updated testcase shows that the current scheme doesn't work when macro
instanciations are nested and multiple files are used.

The case where '# <line> "<file>"' directives are present in the macro themselves
isn't handled by this patch, and I'm not sure we want it handled (what should the
behavior be?)

http://reviews.llvm.org/D10463

Files:
  lib/MC/MCParser/AsmParser.cpp
  test/DebugInfo/X86/asm-macro-line-number.s

Index: lib/MC/MCParser/AsmParser.cpp
===================================================================
--- lib/MC/MCParser/AsmParser.cpp
+++ lib/MC/MCParser/AsmParser.cpp
@@ -1620,8 +1620,8 @@
     if (ActiveMacros.empty())
       Line = SrcMgr.FindLineNumber(IDLoc, CurBuffer);
     else
-      Line = SrcMgr.FindLineNumber(ActiveMacros.back()->InstantiationLoc,
-                                   ActiveMacros.back()->ExitBuffer);
+      Line = SrcMgr.FindLineNumber(ActiveMacros.front()->InstantiationLoc,
+                                   ActiveMacros.front()->ExitBuffer);
 
     // If we previously parsed a cpp hash file line comment then make sure the
     // current Dwarf File is for the CppHashFilename if not then emit the
Index: test/DebugInfo/X86/asm-macro-line-number.s
===================================================================
--- test/DebugInfo/X86/asm-macro-line-number.s
+++ test/DebugInfo/X86/asm-macro-line-number.s
@@ -3,14 +3,20 @@
 # 1 "reduced.S"
 # 1 "<built-in>" 1
 # 1 "reduced.S" 2
+# 200 "macros.h"
 
  .macro return arg
   movl %eax, \arg
   retl
  .endm
 
+ .macro return2 arg
+  return \arg
+ .endm
+
+# 7 "reduced.S"
 function:
- return 0
+ return2 0
 
 # CHECK: .file 2 "reduced.S"
 # CHECK: .loc 2 8 0

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10463.27728.patch
Type: text/x-patch
Size: 1253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150615/34d0942f/attachment.bin>


More information about the llvm-commits mailing list