[llvm] r271494 - [codeview] Return type indices for typedefs
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 1 23:21:37 PDT 2016
Author: majnemer
Date: Thu Jun 2 01:21:37 2016
New Revision: 271494
URL: http://llvm.org/viewvc/llvm-project?rev=271494&view=rev
Log:
[codeview] Return type indices for typedefs
Use the type index of the underlying type unless we have a typedef from
long to HRESULT; HRESULT typedefs are translated to T_HRESULT.
Added:
llvm/trunk/test/DebugInfo/COFF/typedef.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=271494&r1=271493&r2=271494&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Thu Jun 2 01:21:37 2016
@@ -731,6 +731,8 @@ void CodeViewDebug::beginFunction(const
TypeIndex CodeViewDebug::lowerType(const DIType *Ty) {
// Generic dispatch for lowering an unknown type.
switch (Ty->getTag()) {
+ case dwarf::DW_TAG_typedef:
+ return lowerTypeAlias(cast<DIDerivedType>(Ty));
case dwarf::DW_TAG_base_type:
return lowerTypeBasic(cast<DIBasicType>(Ty));
case dwarf::DW_TAG_pointer_type:
@@ -748,6 +750,16 @@ TypeIndex CodeViewDebug::lowerType(const
}
}
+TypeIndex CodeViewDebug::lowerTypeAlias(const DIDerivedType *Ty) {
+ // TODO: MSVC emits a S_UDT record.
+ DITypeRef UnderlyingTypeRef = Ty->getBaseType();
+ TypeIndex UnderlyingTypeIndex = getTypeIndex(UnderlyingTypeRef);
+ if (UnderlyingTypeIndex == TypeIndex(SimpleTypeKind::Int32Long) &&
+ Ty->getName() == "HRESULT")
+ return TypeIndex(SimpleTypeKind::HResult);
+ return UnderlyingTypeIndex;
+}
+
TypeIndex CodeViewDebug::lowerTypeBasic(const DIBasicType *Ty) {
TypeIndex Index;
dwarf::TypeKind Kind;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=271494&r1=271493&r2=271494&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h Thu Jun 2 01:21:37 2016
@@ -190,6 +190,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe
codeview::TypeIndex getTypeIndex(DITypeRef Ty);
codeview::TypeIndex lowerType(const DIType *Ty);
+ codeview::TypeIndex lowerTypeAlias(const DIDerivedType *Ty);
codeview::TypeIndex lowerTypeBasic(const DIBasicType *Ty);
codeview::TypeIndex lowerTypePointer(const DIDerivedType *Ty);
codeview::TypeIndex lowerTypeMemberPointer(const DIDerivedType *Ty);
Added: llvm/trunk/test/DebugInfo/COFF/typedef.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/typedef.ll?rev=271494&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/typedef.ll (added)
+++ llvm/trunk/test/DebugInfo/COFF/typedef.ll Thu Jun 2 01:21:37 2016
@@ -0,0 +1,38 @@
+; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
+
+; CHECK: CodeViewDebugInfo [
+; CHECK: Subsection [
+; CHECK: Local {
+; CHECK: Type: wchar_t (0x71)
+; CHECK: Flags [ (0x0)
+; CHECK: ]
+; CHECK: VarName: foo
+; CHECK: }
+
+target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
+target triple = "i686-pc-windows-msvc18.0.0"
+
+define void @test1() !dbg !5 {
+entry:
+ %foo = alloca i16, align 2
+ call void @llvm.dbg.declare(metadata i16* %foo, metadata !8, metadata !11), !dbg !12
+ ret void, !dbg !12
+}
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
+!1 = !DIFile(filename: "-", directory: "/usr/local/google/home/majnemer/llvm/src")
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: !6, file: !6, type: !7, unit: !0, variables: !{})
+!6 = !DIFile(filename: "<stdin>", directory: ".")
+!7 = !DISubroutineType(types: !{})
+!8 = !DILocalVariable(name: "foo", scope: !5, file: !6, line: 3, type: !9)
+!9 = !DIDerivedType(tag: DW_TAG_typedef, name: "XYZ", file: !6, line: 2, baseType: !10)
+!10 = !DIBasicType(name: "wchar_t", size: 16, align: 16, encoding: DW_ATE_unsigned)
+!11 = !DIExpression()
+!12 = !DILocation(line: 3, column: 16, scope: !5)
More information about the llvm-commits
mailing list