From e45b2c7d8e76c3e51c47ca272b00e4257d8fd672 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 29 Sep 2016 17:55:01 +0000 Subject: [PATCH] [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: https://github.com/rust-lang/rust/issues/36646 Fixes PR30552 llvm-svn: 282739 --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 20 +++++----- llvm/test/DebugInfo/COFF/int8-char-type.ll | 55 +++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 llvm/test/DebugInfo/COFF/int8-char-type.ll diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 13e98c3..821b3b9 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -1222,20 +1222,20 @@ TypeIndex CodeViewDebug::lowerTypeBasic(const DIBasicType *Ty) { break; case dwarf::DW_ATE_signed: switch (ByteSize) { - case 1: STK = SimpleTypeKind::SByte; break; - case 2: STK = SimpleTypeKind::Int16Short; break; - case 4: STK = SimpleTypeKind::Int32; break; - case 8: STK = SimpleTypeKind::Int64Quad; break; - case 16: STK = SimpleTypeKind::Int128Oct; break; + case 1: STK = SimpleTypeKind::SignedCharacter; break; + case 2: STK = SimpleTypeKind::Int16Short; break; + case 4: STK = SimpleTypeKind::Int32; break; + case 8: STK = SimpleTypeKind::Int64Quad; break; + case 16: STK = SimpleTypeKind::Int128Oct; break; } break; case dwarf::DW_ATE_unsigned: switch (ByteSize) { - case 1: STK = SimpleTypeKind::Byte; break; - case 2: STK = SimpleTypeKind::UInt16Short; break; - case 4: STK = SimpleTypeKind::UInt32; break; - case 8: STK = SimpleTypeKind::UInt64Quad; break; - case 16: STK = SimpleTypeKind::UInt128Oct; break; + case 1: STK = SimpleTypeKind::UnsignedCharacter; break; + case 2: STK = SimpleTypeKind::UInt16Short; break; + case 4: STK = SimpleTypeKind::UInt32; break; + case 8: STK = SimpleTypeKind::UInt64Quad; break; + case 16: STK = SimpleTypeKind::UInt128Oct; break; } break; case dwarf::DW_ATE_UTF: diff --git a/llvm/test/DebugInfo/COFF/int8-char-type.ll b/llvm/test/DebugInfo/COFF/int8-char-type.ll new file mode 100644 index 0000000..bbfd006 --- /dev/null +++ b/llvm/test/DebugInfo/COFF/int8-char-type.ll @@ -0,0 +1,55 @@ +; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s + +; Use character types for all 8-bit integers. The VS debugger doesn't cope well +; with the T_[U]INT1 types. Non-C language frontends are likely use the normal +; DW_ATE_[un]signed encoding for all integer types if they don't have distinct +; integer types for characters types. This was PR30552. + +; CHECK-LABEL: DataSym { +; CHECK-NEXT: Kind: S_GDATA32 (0x110D) +; CHECK-NEXT: DataOffset: +; CHECK-NEXT: Type: signed char (0x10) +; CHECK-NEXT: DisplayName: x +; CHECK-NEXT: LinkageName: x +; CHECK-NEXT: } + +; CHECK-LABEL: DataSym { +; CHECK-NEXT: Kind: S_GDATA32 (0x110D) +; CHECK-NEXT: DataOffset: +; CHECK-NEXT: Type: unsigned char (0x20) +; CHECK-NEXT: DisplayName: y +; CHECK-NEXT: LinkageName: y +; CHECK-NEXT: } + +source_filename = "-" +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.0.24210" + +@x = global i8 0, align 1, !dbg !0 +@y = global i8 0, align 1, !dbg !5 + +!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!11, !12, !13} +!llvm.ident = !{!14} + +!0 = distinct !DIGlobalVariable(name: "x", scope: !1, file: !6, line: 4, type: !9, isLocal: false, isDefinition: true) +!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) +!2 = !DIFile(filename: "-", directory: "C:\5Csrc\5Cllvm\5Cbuild") +!3 = !{} +!4 = !{!0, !5} +!5 = distinct !DIGlobalVariable(name: "y", scope: !1, file: !6, line: 5, type: !7, isLocal: false, isDefinition: true) +!6 = !DIFile(filename: "", directory: "C:\5Csrc\5Cllvm\5Cbuild") +!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint8_t", file: !6, line: 3, baseType: !8) + +; Manually modified to use DW_ATE_unsigned +!8 = !DIBasicType(size: 8, align: 8, encoding: DW_ATE_unsigned) + +!9 = !DIDerivedType(tag: DW_TAG_typedef, name: "int8_t", file: !6, line: 2, baseType: !10) + +; Manually modified to use DW_ATE_signed +!10 = !DIBasicType(size: 8, align: 8, encoding: DW_ATE_signed) + +!11 = !{i32 2, !"CodeView", i32 1} +!12 = !{i32 2, !"Debug Info Version", i32 3} +!13 = !{i32 1, !"PIC Level", i32 2} +!14 = !{!"clang version 4.0.0 "} -- 2.7.4