[llvm-commits] [llvm] r157786 - in /llvm/trunk: include/llvm/Analysis/DIBuilder.h lib/Analysis/DIBuilder.cpp lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp test/DebugInfo/X86/enum-fwd-decl.ll
Eric Christopher
echristo at apple.com
Thu May 31 17:22:33 PDT 2012
Author: echristo
Date: Thu May 31 19:22:32 2012
New Revision: 157786
URL: http://llvm.org/viewvc/llvm-project?rev=157786&view=rev
Log:
Add support for enum forward declarations.
Part of rdar://11570854
Added:
llvm/trunk/test/DebugInfo/X86/enum-fwd-decl.ll
Modified:
llvm/trunk/include/llvm/Analysis/DIBuilder.h
llvm/trunk/lib/Analysis/DIBuilder.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DIBuilder.h?rev=157786&r1=157785&r2=157786&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/DIBuilder.h (original)
+++ llvm/trunk/include/llvm/Analysis/DIBuilder.h Thu May 31 19:22:32 2012
@@ -329,10 +329,12 @@
/// @param SizeInBits Member size.
/// @param AlignInBits Member alignment.
/// @param Elements Enumeration elements.
+ /// @param Flags Flags (e.g. forward decl)
DIType createEnumerationType(DIDescriptor Scope, StringRef Name,
DIFile File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits,
- DIArray Elements, DIType ClassType);
+ DIArray Elements, DIType ClassType,
+ unsigned Flags);
/// createSubroutineType - Create subroutine type.
/// @param File File in which this subroutine is defined.
Modified: llvm/trunk/lib/Analysis/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DIBuilder.cpp?rev=157786&r1=157785&r2=157786&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DIBuilder.cpp (original)
+++ llvm/trunk/lib/Analysis/DIBuilder.cpp Thu May 31 19:22:32 2012
@@ -549,7 +549,7 @@
uint64_t SizeInBits,
uint64_t AlignInBits,
DIArray Elements,
- DIType ClassType) {
+ DIType ClassType, unsigned Flags) {
// TAG_enumeration_type is encoded in DICompositeType format.
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_enumeration_type),
@@ -560,7 +560,7 @@
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
- ConstantInt::get(Type::getInt32Ty(VMContext), 0),
+ ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
ClassType,
Elements,
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=157786&r1=157785&r2=157786&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Thu May 31 19:22:32 2012
@@ -935,15 +935,16 @@
Tag == dwarf::DW_TAG_structure_type ||
Tag == dwarf::DW_TAG_union_type) {
// Add size if non-zero (derived types might be zero-sized.)
+ // TODO: Do we care about size for enum forward declarations?
if (Size)
addUInt(&Buffer, dwarf::DW_AT_byte_size, 0, Size);
- else {
+ else if (!CTy.isForwardDecl())
// Add zero size if it is not a forward declaration.
- if (CTy.isForwardDecl())
- addUInt(&Buffer, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
- else
- addUInt(&Buffer, dwarf::DW_AT_byte_size, 0, 0);
- }
+ addUInt(&Buffer, dwarf::DW_AT_byte_size, 0, 0);
+
+ // If we're a forward decl, say so.
+ if (CTy.isForwardDecl())
+ addUInt(&Buffer, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
// Add source line info if available.
if (!CTy.isForwardDecl())
Added: llvm/trunk/test/DebugInfo/X86/enum-fwd-decl.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/enum-fwd-decl.ll?rev=157786&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/enum-fwd-decl.ll (added)
+++ llvm/trunk/test/DebugInfo/X86/enum-fwd-decl.ll Thu May 31 19:22:32 2012
@@ -0,0 +1,22 @@
+; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
+; RUN: llvm-dwarfdump %t | FileCheck %s
+
+ at e = global i16 0, align 2
+
+!llvm.dbg.cu = !{!0}
+
+!0 = metadata !{i32 786449, i32 0, i32 4, metadata !"foo.cpp", metadata !"/Users/echristo/tmp", metadata !"clang version 3.2 (trunk 157772) (llvm/trunk 157761)", i1 true, i1 false, metadata !"", i32 0, metadata !1, metadata !6, metadata !6, metadata !7} ; [ DW_TAG_compile_unit ]
+!1 = metadata !{metadata !2}
+!2 = metadata !{metadata !3}
+!3 = metadata !{i32 786436, null, metadata !"E", metadata !4, i32 1, i64 16, i64 16, i32 0, i32 4, null, metadata !5, i32 0, i32 0} ; [ DW_TAG_enumeration_type ]
+!4 = metadata !{i32 786473, metadata !"foo.cpp", metadata !"/Users/echristo/tmp", null} ; [ DW_TAG_file_type ]
+!5 = metadata !{i32 0}
+!6 = metadata !{metadata !5}
+!7 = metadata !{metadata !8}
+!8 = metadata !{metadata !9}
+!9 = metadata !{i32 786484, i32 0, null, metadata !"e", metadata !"e", metadata !"", metadata !4, i32 2, metadata !3, i32 0, i32 1, i16* @e} ; [ DW_TAG_variable ]
+
+; CHECK: DW_TAG_enumeration_type
+; CHECK-NEXT: DW_AT_name
+; CHECK-NEXT: DW_AT_byte_size
+; CHECK-NEXT: DW_AT_declaration
More information about the llvm-commits
mailing list