Skip to content
This repository was archived by the owner on Jan 1, 2023. It is now read-only.

Commit a110941

Browse files
committed
[codeview] Use character types for all byte-sized integer types
The VS debugger doesn't appear to understand the 0x68 or 0x69 type indices, which were probably intended for use on a platform where a C 'int' is 8 bits. So, use the character types instead. Clang was already using the character types because '[u]int8_t' is usually defined in terms of 'char'. See the Rust issue for screenshots of what VS does: rust-lang/rust#36646 Fixes PR30552 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282739 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 61724e6 commit a110941

File tree

2 files changed

+65
-10
lines changed

2 files changed

+65
-10
lines changed

lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,20 +1222,20 @@ TypeIndex CodeViewDebug::lowerTypeBasic(const DIBasicType *Ty) {
12221222
break;
12231223
case dwarf::DW_ATE_signed:
12241224
switch (ByteSize) {
1225-
case 1: STK = SimpleTypeKind::SByte; break;
1226-
case 2: STK = SimpleTypeKind::Int16Short; break;
1227-
case 4: STK = SimpleTypeKind::Int32; break;
1228-
case 8: STK = SimpleTypeKind::Int64Quad; break;
1229-
case 16: STK = SimpleTypeKind::Int128Oct; break;
1225+
case 1: STK = SimpleTypeKind::SignedCharacter; break;
1226+
case 2: STK = SimpleTypeKind::Int16Short; break;
1227+
case 4: STK = SimpleTypeKind::Int32; break;
1228+
case 8: STK = SimpleTypeKind::Int64Quad; break;
1229+
case 16: STK = SimpleTypeKind::Int128Oct; break;
12301230
}
12311231
break;
12321232
case dwarf::DW_ATE_unsigned:
12331233
switch (ByteSize) {
1234-
case 1: STK = SimpleTypeKind::Byte; break;
1235-
case 2: STK = SimpleTypeKind::UInt16Short; break;
1236-
case 4: STK = SimpleTypeKind::UInt32; break;
1237-
case 8: STK = SimpleTypeKind::UInt64Quad; break;
1238-
case 16: STK = SimpleTypeKind::UInt128Oct; break;
1234+
case 1: STK = SimpleTypeKind::UnsignedCharacter; break;
1235+
case 2: STK = SimpleTypeKind::UInt16Short; break;
1236+
case 4: STK = SimpleTypeKind::UInt32; break;
1237+
case 8: STK = SimpleTypeKind::UInt64Quad; break;
1238+
case 16: STK = SimpleTypeKind::UInt128Oct; break;
12391239
}
12401240
break;
12411241
case dwarf::DW_ATE_UTF:

test/DebugInfo/COFF/int8-char-type.ll

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
2+
3+
; Use character types for all 8-bit integers. The VS debugger doesn't cope well
4+
; with the T_[U]INT1 types. Non-C language frontends are likely use the normal
5+
; DW_ATE_[un]signed encoding for all integer types if they don't have distinct
6+
; integer types for characters types. This was PR30552.
7+
8+
; CHECK-LABEL: DataSym {
9+
; CHECK-NEXT: Kind: S_GDATA32 (0x110D)
10+
; CHECK-NEXT: DataOffset:
11+
; CHECK-NEXT: Type: signed char (0x10)
12+
; CHECK-NEXT: DisplayName: x
13+
; CHECK-NEXT: LinkageName: x
14+
; CHECK-NEXT: }
15+
16+
; CHECK-LABEL: DataSym {
17+
; CHECK-NEXT: Kind: S_GDATA32 (0x110D)
18+
; CHECK-NEXT: DataOffset:
19+
; CHECK-NEXT: Type: unsigned char (0x20)
20+
; CHECK-NEXT: DisplayName: y
21+
; CHECK-NEXT: LinkageName: y
22+
; CHECK-NEXT: }
23+
24+
source_filename = "-"
25+
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
26+
target triple = "x86_64-pc-windows-msvc19.0.24210"
27+
28+
@x = global i8 0, align 1, !dbg !0
29+
@y = global i8 0, align 1, !dbg !5
30+
31+
!llvm.dbg.cu = !{!1}
32+
!llvm.module.flags = !{!11, !12, !13}
33+
!llvm.ident = !{!14}
34+
35+
!0 = distinct !DIGlobalVariable(name: "x", scope: !1, file: !6, line: 4, type: !9, isLocal: false, isDefinition: true)
36+
!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 4.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !4)
37+
!2 = !DIFile(filename: "-", directory: "C:\5Csrc\5Cllvm\5Cbuild")
38+
!3 = !{}
39+
!4 = !{!0, !5}
40+
!5 = distinct !DIGlobalVariable(name: "y", scope: !1, file: !6, line: 5, type: !7, isLocal: false, isDefinition: true)
41+
!6 = !DIFile(filename: "<stdin>", directory: "C:\5Csrc\5Cllvm\5Cbuild")
42+
!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint8_t", file: !6, line: 3, baseType: !8)
43+
44+
; Manually modified to use DW_ATE_unsigned
45+
!8 = !DIBasicType(size: 8, align: 8, encoding: DW_ATE_unsigned)
46+
47+
!9 = !DIDerivedType(tag: DW_TAG_typedef, name: "int8_t", file: !6, line: 2, baseType: !10)
48+
49+
; Manually modified to use DW_ATE_signed
50+
!10 = !DIBasicType(size: 8, align: 8, encoding: DW_ATE_signed)
51+
52+
!11 = !{i32 2, !"CodeView", i32 1}
53+
!12 = !{i32 2, !"Debug Info Version", i32 3}
54+
!13 = !{i32 1, !"PIC Level", i32 2}
55+
!14 = !{!"clang version 4.0.0 "}

0 commit comments

Comments
 (0)