llvm.org GIT mirror llvm / 3681929
IAS: correct debug line info for asm macros Correct the line information generation for preprocessed assembly. Although we tracked the source information for the macro instantiation, we failed to account for the fact that we were instantiating a macro, which is populated into a new buffer and that the line information would be relative to the definition rather than the actual instantiation location. This could cause the line number associated with the statement to be very high due to wrapping of the difference calculated for the preprocessor line information emitted into the stream. Properly calculate the line for the macro instantiation, referencing the line where the macro is actually used as GCC/gas do. The test case uses x86, though the same problem exists on any other target using the LLVM IAS. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224810 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 5 years ago
2 changed file(s) with 28 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
15941594 // directive for the instruction.
15951595 if (!HadError && getContext().getGenDwarfForAssembly() &&
15961596 getContext().getGenDwarfSectionSyms().count(
1597 getStreamer().getCurrentSection().first)) {
1598
1599 unsigned Line = SrcMgr.FindLineNumber(IDLoc, CurBuffer);
1597 getStreamer().getCurrentSection().first)) {
1598 unsigned Line;
1599 if (ActiveMacros.empty())
1600 Line = SrcMgr.FindLineNumber(IDLoc, CurBuffer);
1601 else
1602 Line = SrcMgr.FindLineNumber(ActiveMacros.back()->InstantiationLoc,
1603 ActiveMacros.back()->ExitBuffer);
16001604
16011605 // If we previously parsed a cpp hash file line comment then make sure the
16021606 // current Dwarf File is for the CppHashFilename if not then emit the
16031607 // Dwarf File table for it and adjust the line number for the .loc.
1604 if (CppHashFilename.size() != 0) {
1608 if (CppHashFilename.size()) {
16051609 unsigned FileNumber = getStreamer().EmitDwarfFileDirective(
16061610 0, StringRef(), CppHashFilename);
16071611 getContext().setGenDwarfFileNumber(FileNumber);
0 # RUN: llvm-mc -g -triple i686-linux-gnu -filetype asm -o - %s | FileCheck %s
1
2 # 1 "reduced.S"
3 # 1 "" 1
4 # 1 "reduced.S" 2
5
6 .macro return arg
7 movl %eax, \arg
8 retl
9 .endm
10
11 function:
12 return 0
13
14 # CHECK: .file 2 "reduced.S"
15 # CHECK: .loc 2 8 0
16 # CHECK: movl %eax, 0
17 # CHECK: .loc 2 8 0
18 # CHECK: retl
19