mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-26 12:46:00 +00:00
[CodeView] Emit an appropriate symbol kind for globals
We emitted debug info for globals/functions as if they all had external linkage. Instead, emit local symbol records when appropriate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274676 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cc3da7f637
commit
7bae2669d5
@ -642,8 +642,13 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
|
||||
OS.emitAbsoluteSymbolDiff(ProcRecordEnd, ProcRecordBegin, 2);
|
||||
OS.EmitLabel(ProcRecordBegin);
|
||||
|
||||
if (GV->hasLocalLinkage()) {
|
||||
OS.AddComment("Record kind: S_LPROC32_ID");
|
||||
OS.EmitIntValue(unsigned(SymbolKind::S_LPROC32_ID), 2);
|
||||
} else {
|
||||
OS.AddComment("Record kind: S_GPROC32_ID");
|
||||
OS.EmitIntValue(unsigned(SymbolKind::S_GPROC32_ID), 2);
|
||||
}
|
||||
|
||||
// These fields are filled in by tools like CVPACK which run after the fact.
|
||||
OS.AddComment("PtrParent");
|
||||
@ -1993,8 +1998,13 @@ void CodeViewDebug::emitDebugInfoForGlobal(const DIGlobalVariable *DIGV,
|
||||
OS.AddComment("Record length");
|
||||
OS.emitAbsoluteSymbolDiff(DataEnd, DataBegin, 2);
|
||||
OS.EmitLabel(DataBegin);
|
||||
OS.AddComment("Record kind: S_GDATA32");
|
||||
OS.EmitIntValue(unsigned(SymbolKind::S_GDATA32), 2);
|
||||
if (DIGV->isLocalToUnit()) {
|
||||
OS.AddComment("Record kind: S_LDATA32");
|
||||
OS.EmitIntValue(unsigned(SymbolKind::S_LDATA32), 2);
|
||||
} else {
|
||||
OS.AddComment("Record kind: S_GDATA32");
|
||||
OS.EmitIntValue(unsigned(SymbolKind::S_GDATA32), 2);
|
||||
}
|
||||
OS.AddComment("Type");
|
||||
OS.EmitIntValue(getCompleteTypeIndex(DIGV->getType()).getIndex(), 4);
|
||||
OS.AddComment("DataOffset");
|
||||
|
@ -279,6 +279,7 @@ void CVSymbolDumperImpl::visitConstantSym(SymbolKind Kind,
|
||||
void CVSymbolDumperImpl::visitDataSym(SymbolKind Kind, DataSym &Data) {
|
||||
DictScope S(W, "DataSym");
|
||||
|
||||
W.printEnum("Kind", uint16_t(Kind), getSymbolTypeNames());
|
||||
StringRef LinkageName;
|
||||
if (ObjDelegate) {
|
||||
ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
|
||||
@ -552,6 +553,7 @@ void CVSymbolDumperImpl::visitProcSym(SymbolKind Kind, ProcSym &Proc) {
|
||||
InFunctionScope = true;
|
||||
|
||||
StringRef LinkageName;
|
||||
W.printEnum("Kind", uint16_t(Kind), getSymbolTypeNames());
|
||||
W.printHex("PtrParent", Proc.Header.PtrParent);
|
||||
W.printHex("PtrEnd", Proc.Header.PtrEnd);
|
||||
W.printHex("PtrNext", Proc.Header.PtrNext);
|
||||
|
@ -3,7 +3,7 @@
|
||||
; This tests that we don't emit information about globals that were discarded
|
||||
; during optimization. We should only see one global symbol record.
|
||||
|
||||
; CHECK: .short 4365 # Record kind: S_GDATA32
|
||||
; CHECK: .short 4364 # Record kind: S_LDATA32
|
||||
; CHECK: .long 117 # Type
|
||||
; CHECK: .secrel32 x # DataOffset
|
||||
; CHECK: .secidx x # Segment
|
||||
|
@ -14,7 +14,7 @@
|
||||
; ASM: .long 4 # Debug section magic
|
||||
|
||||
; ASM: .short {{.*-.*}} # Record length
|
||||
; ASM: .short 4365 # Record kind: S_GDATA32
|
||||
; ASM: .short 4364 # Record kind: S_LDATA32
|
||||
; ASM: .long 116 # Type
|
||||
; ASM: .secrel32 "?first@@3HA" # DataOffset
|
||||
; ASM: .secidx "?first@@3HA" # Segment
|
||||
@ -74,18 +74,21 @@
|
||||
; OBJ: Subsection [
|
||||
; OBJ: SubSectionType: Symbols (0xF1)
|
||||
; OBJ: DataSym {
|
||||
; OBJ: Kind: S_LDATA32 (0x110C)
|
||||
; OBJ: DataOffset: ?first@@3HA+0x0
|
||||
; OBJ: Type: int (0x74)
|
||||
; OBJ: DisplayName: first
|
||||
; OBJ: LinkageName: ?first@@3HA
|
||||
; OBJ: }
|
||||
; OBJ: DataSym {
|
||||
; OBJ: Kind: S_GDATA32 (0x110D)
|
||||
; OBJ: DataOffset: ?middle@@3PEBHEB+0x0
|
||||
; OBJ: Type: const int* (0x1001)
|
||||
; OBJ: DisplayName: middle
|
||||
; OBJ: LinkageName: ?middle@@3PEBHEB
|
||||
; OBJ: }
|
||||
; OBJ: DataSym {
|
||||
; OBJ: Kind: S_GDATA32 (0x110D)
|
||||
; OBJ: DataOffset: ?last@@3HA+0x0
|
||||
; OBJ: Type: int (0x74)
|
||||
; OBJ: DisplayName: last
|
||||
@ -115,7 +118,7 @@ target triple = "x86_64-pc-windows-msvc19.0.23918"
|
||||
|
||||
$"\01?comdat@?$A@X@@2HB" = comdat any
|
||||
|
||||
@"\01?first@@3HA" = global i32 0, align 4
|
||||
@"\01?first@@3HA" = internal global i32 0, align 4
|
||||
@"\01?comdat@?$A@X@@2HB" = linkonce_odr constant i32 3, comdat, align 4
|
||||
@"\01?middle@@3PEBHEB" = global i32* @"\01?comdat@?$A@X@@2HB", align 8
|
||||
@"\01?last@@3HA" = global i32 0, align 4
|
||||
@ -128,7 +131,7 @@ $"\01?comdat@?$A@X@@2HB" = comdat any
|
||||
!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
|
||||
!2 = !{}
|
||||
!3 = !{!4, !6, !13, !15}
|
||||
!4 = distinct !DIGlobalVariable(name: "first", linkageName: "\01?first@@3HA", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, variable: i32* @"\01?first@@3HA")
|
||||
!4 = distinct !DIGlobalVariable(name: "first", linkageName: "\01?first@@3HA", scope: !0, file: !1, line: 1, type: !5, isLocal: true, isDefinition: true, variable: i32* @"\01?first@@3HA")
|
||||
!5 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
||||
!6 = distinct !DIGlobalVariable(name: "comdat", linkageName: "\01?comdat@?$A@X@@2HB", scope: !0, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, variable: i32* @"\01?comdat@?$A@X@@2HB", declaration: !8)
|
||||
!7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !5)
|
||||
|
@ -60,7 +60,7 @@
|
||||
; X86-NEXT: [[F1_START]]:
|
||||
; X86-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] #
|
||||
; X86-NEXT: [[PROC_SEGMENT_START]]:
|
||||
; X86-NEXT: .short 4423
|
||||
; X86-NEXT: .short 4422
|
||||
; X86-NEXT: .long 0
|
||||
; X86-NEXT: .long 0
|
||||
; X86-NEXT: .long 0
|
||||
@ -154,6 +154,7 @@
|
||||
; OBJ32-NEXT: SubSectionType: Symbols (0xF1)
|
||||
; OBJ32-NOT: ]
|
||||
; OBJ32: ProcStart {
|
||||
; OBJ32: Kind: S_LPROC32_ID (0x1146)
|
||||
; OBJ32: CodeSize: 0x6
|
||||
; OBJ32: DisplayName: x
|
||||
; OBJ32: LinkageName: _x
|
||||
@ -168,6 +169,7 @@
|
||||
; OBJ32-NEXT: SubSectionType: Symbols (0xF1)
|
||||
; OBJ32-NOT: ]
|
||||
; OBJ32: ProcStart {
|
||||
; OBJ32: Kind: S_GPROC32_ID (0x1147)
|
||||
; OBJ32: CodeSize: 0x6
|
||||
; OBJ32: DisplayName: y
|
||||
; OBJ32: LinkageName: _y
|
||||
@ -182,6 +184,7 @@
|
||||
; OBJ32-NEXT: SubSectionType: Symbols (0xF1)
|
||||
; OBJ32-NOT: ]
|
||||
; OBJ32: ProcStart {
|
||||
; OBJ32: Kind: S_GPROC32_ID (0x1147)
|
||||
; OBJ32: CodeSize: 0x10
|
||||
; OBJ32: DisplayName: f
|
||||
; OBJ32: LinkageName: _f
|
||||
@ -324,7 +327,7 @@
|
||||
; X64-NEXT: [[F1_START]]:
|
||||
; X64-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] #
|
||||
; X64-NEXT: [[PROC_SEGMENT_START]]:
|
||||
; X64-NEXT: .short 4423
|
||||
; X64-NEXT: .short 4422
|
||||
; X64-NEXT: .long 0
|
||||
; X64-NEXT: .long 0
|
||||
; X64-NEXT: .long 0
|
||||
@ -420,6 +423,7 @@
|
||||
; OBJ64-NEXT: SubSectionType: Symbols (0xF1)
|
||||
; OBJ64-NOT: ]
|
||||
; OBJ64: ProcStart {
|
||||
; OBJ64: Kind: S_LPROC32_ID (0x1146)
|
||||
; OBJ64: CodeSize: 0xE
|
||||
; OBJ64: DisplayName: x
|
||||
; OBJ64: LinkageName: x
|
||||
@ -434,6 +438,7 @@
|
||||
; OBJ64-NEXT: SubSectionType: Symbols (0xF1)
|
||||
; OBJ64-NOT: ]
|
||||
; OBJ64: ProcStart {
|
||||
; OBJ64: Kind: S_GPROC32_ID (0x1147)
|
||||
; OBJ64: CodeSize: 0xE
|
||||
; OBJ64: DisplayName: y
|
||||
; OBJ64: LinkageName: y
|
||||
@ -448,6 +453,7 @@
|
||||
; OBJ64-NEXT: SubSectionType: Symbols (0xF1)
|
||||
; OBJ64-NOT: ]
|
||||
; OBJ64: ProcStart {
|
||||
; OBJ64: Kind: S_GPROC32_ID (0x1147)
|
||||
; OBJ64: CodeSize: 0x18
|
||||
; OBJ64: DisplayName: f
|
||||
; OBJ64: LinkageName: f
|
||||
@ -561,7 +567,7 @@
|
||||
; OBJ64-NEXT: ]
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define void @x() #0 !dbg !4 {
|
||||
define internal void @x() #0 !dbg !4 {
|
||||
entry:
|
||||
call void @z(), !dbg !14
|
||||
ret void, !dbg !15
|
||||
|
@ -292,6 +292,7 @@
|
||||
; EMPTY-NEXT: }
|
||||
; EMPTY-NEXT: {
|
||||
; EMPTY-NEXT: ProcStart {
|
||||
; EMPTY-NEXT: Kind: S_GPROC32 (0x1110)
|
||||
; EMPTY-NEXT: PtrParent: 0x0
|
||||
; EMPTY-NEXT: PtrEnd: 0xC4
|
||||
; EMPTY-NEXT: PtrNext: 0x0
|
||||
@ -842,6 +843,7 @@
|
||||
; EMPTY-NEXT: }
|
||||
; EMPTY-NEXT: {
|
||||
; EMPTY-NEXT: DataSym {
|
||||
; EMPTY-NEXT: Kind: S_GDATA32 (0x110D)
|
||||
; EMPTY-NEXT: Type: void* (0x403)
|
||||
; EMPTY-NEXT: DisplayName: __purecall
|
||||
; EMPTY-NEXT: }
|
||||
|
Loading…
x
Reference in New Issue
Block a user