[llvm-branch-commits] [llvm-branch] r81137 - in /llvm/branches/Apple/L2: docs/ include/llvm/ include/llvm/Analysis/ include/llvm/CodeGen/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/CodeGen/AsmPrinter/ lib/CodeGen/SelectionDAG/ lib/Linker/ lib/Target/PIC16/ lib/Transforms/IPO/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/DebugInfo/ test/FrontendC++/ test/FrontendObjC/ test/Linker/ test/Transforms/GlobalDCE/ test/Transforms/SimplifyCFG/

Devang Patel dpatel at apple.com
Sun Sep 6 14:39:37 PDT 2009


Author: dpatel
Date: Sun Sep  6 16:39:36 2009
New Revision: 81137

URL: http://llvm.org/viewvc/llvm-project?rev=81137&view=rev
Log:
Revert following patches on L2.
81045
80941
80928
80868
80867
80841
80839
80778
80741
80738
80660
80648
80647
80637
80635
80633
80627
80625
80620
80618
80602
80406
80307
80247
80073
80061
79977


Added:
    llvm/branches/Apple/L2/test/DebugInfo/2008-11-06-Mem2Reg.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/2008-11-06-Mem2Reg.ll
    llvm/branches/Apple/L2/test/DebugInfo/2008-11-19-InstCombine.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/2008-11-19-InstCombine.ll
    llvm/branches/Apple/L2/test/DebugInfo/2009-01-28-ArrayType.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/2009-01-28-ArrayType.ll
    llvm/branches/Apple/L2/test/DebugInfo/2009-01-29-HeaderLocation.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/2009-01-29-HeaderLocation.ll
    llvm/branches/Apple/L2/test/DebugInfo/2009-01-29-MethodDeclaration.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/2009-01-29-MethodDeclaration.ll
    llvm/branches/Apple/L2/test/DebugInfo/2009-01-30-Method.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/2009-01-30-Method.ll
    llvm/branches/Apple/L2/test/DebugInfo/2009-02-23-InstCombine.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/2009-02-23-InstCombine.ll
    llvm/branches/Apple/L2/test/DebugInfo/2009-03-02-sink.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/2009-03-02-sink.ll
    llvm/branches/Apple/L2/test/DebugInfo/dataOnly.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/dataOnly.ll
    llvm/branches/Apple/L2/test/DebugInfo/forwardDecl.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/forwardDecl.ll
    llvm/branches/Apple/L2/test/DebugInfo/printdbginfo.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/printdbginfo.ll
    llvm/branches/Apple/L2/test/DebugInfo/printdbginfo2.ll
      - copied unchanged from r80405, llvm/trunk/test/DebugInfo/printdbginfo2.ll
    llvm/branches/Apple/L2/test/FrontendC++/2009-02-16-AnonTypedef-Dbg.cpp
      - copied unchanged from r80405, llvm/trunk/test/FrontendC++/2009-02-16-AnonTypedef-Dbg.cpp
    llvm/branches/Apple/L2/test/FrontendObjC/2009-02-17-RunTimeVer-dbg.m
      - copied unchanged from r80405, llvm/trunk/test/FrontendObjC/2009-02-17-RunTimeVer-dbg.m
Removed:
    llvm/branches/Apple/L2/test/Linker/2009-09-03-mdnode.ll
    llvm/branches/Apple/L2/test/Linker/2009-09-03-mdnode2.ll
    llvm/branches/Apple/L2/test/Transforms/GlobalDCE/2009-09-03-MDNode.ll
Modified:
    llvm/branches/Apple/L2/docs/SourceLevelDebugging.html
    llvm/branches/Apple/L2/include/llvm/Analysis/DebugInfo.h
    llvm/branches/Apple/L2/include/llvm/AutoUpgrade.h
    llvm/branches/Apple/L2/include/llvm/CodeGen/DwarfWriter.h
    llvm/branches/Apple/L2/include/llvm/CodeGen/MachineFunction.h
    llvm/branches/Apple/L2/include/llvm/CodeGen/SelectionDAG.h
    llvm/branches/Apple/L2/include/llvm/CodeGen/SelectionDAGNodes.h
    llvm/branches/Apple/L2/include/llvm/Constants.h
    llvm/branches/Apple/L2/include/llvm/IntrinsicInst.h
    llvm/branches/Apple/L2/include/llvm/Intrinsics.td
    llvm/branches/Apple/L2/include/llvm/Metadata.h
    llvm/branches/Apple/L2/include/llvm/Support/DebugLoc.h
    llvm/branches/Apple/L2/lib/Analysis/DbgInfoPrinter.cpp
    llvm/branches/Apple/L2/lib/Analysis/DebugInfo.cpp
    llvm/branches/Apple/L2/lib/Analysis/ValueTracking.cpp
    llvm/branches/Apple/L2/lib/AsmParser/LLParser.cpp
    llvm/branches/Apple/L2/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfDebug.h
    llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
    llvm/branches/Apple/L2/lib/CodeGen/MachineFunction.cpp
    llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/FastISel.cpp
    llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
    llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
    llvm/branches/Apple/L2/lib/Linker/LinkModules.cpp
    llvm/branches/Apple/L2/lib/Target/PIC16/PIC16DebugInfo.cpp
    llvm/branches/Apple/L2/lib/Target/PIC16/PIC16DebugInfo.h
    llvm/branches/Apple/L2/lib/Transforms/IPO/StripSymbols.cpp
    llvm/branches/Apple/L2/lib/Transforms/Scalar/DeadStoreElimination.cpp
    llvm/branches/Apple/L2/lib/Transforms/Utils/CloneFunction.cpp
    llvm/branches/Apple/L2/lib/Transforms/Utils/InlineFunction.cpp
    llvm/branches/Apple/L2/lib/VMCore/AutoUpgrade.cpp
    llvm/branches/Apple/L2/lib/VMCore/Constants.cpp
    llvm/branches/Apple/L2/lib/VMCore/ConstantsContext.h
    llvm/branches/Apple/L2/lib/VMCore/IntrinsicInst.cpp
    llvm/branches/Apple/L2/lib/VMCore/LLVMContext.cpp
    llvm/branches/Apple/L2/lib/VMCore/LLVMContextImpl.h
    llvm/branches/Apple/L2/lib/VMCore/Metadata.cpp
    llvm/branches/Apple/L2/lib/VMCore/ValueTypes.cpp
    llvm/branches/Apple/L2/test/Transforms/SimplifyCFG/dbginfo.ll

Modified: llvm/branches/Apple/L2/docs/SourceLevelDebugging.html
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/docs/SourceLevelDebugging.html?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/docs/SourceLevelDebugging.html (original)
+++ llvm/branches/Apple/L2/docs/SourceLevelDebugging.html Sun Sep  6 16:39:36 2009
@@ -122,8 +122,8 @@
 <p>The approach used by the LLVM implementation is to use a small set
    of <a href="#format_common_intrinsics">intrinsic functions</a> to define a
    mapping between LLVM program objects and the source-level objects.  The
-   description of the source-level program is maintained in LLVM metadata
-   in an <a href="#ccxx_frontend">implementation-defined format</a>
+   description of the source-level program is maintained in LLVM global
+   variables in an <a href="#ccxx_frontend">implementation-defined format</a>
    (the C/C++ front-end currently uses working draft 7 of
    the <a href="http://www.eagercon.com/dwarf/dwarf3std.htm">DWARF 3
    standard</a>).</p>
@@ -240,21 +240,31 @@
 <p>LLVM debugging information has been carefully designed to make it possible
    for the optimizer to optimize the program and debugging information without
    necessarily having to know anything about debugging information.  In
-   particular, te use of metadadta avoids duplicated dubgging information from
-   the beginning, and the global dead code elimination pass automatically 
-   deletes debugging information for a function if it decides to delete the 
-   function. </p>
+   particular, the global constant merging pass automatically eliminates
+   duplicated debugging information (often caused by header files), the global
+   dead code elimination pass automatically deletes debugging information for a
+   function if it decides to delete the function, and the linker eliminates
+   debug information when it merges <tt>linkonce</tt> functions.</p>
 
 <p>To do this, most of the debugging information (descriptors for types,
    variables, functions, source files, etc) is inserted by the language
-   front-end in the form of LLVM metadata. </p>
+   front-end in the form of LLVM global variables.  These LLVM global variables
+   are no different from any other global variables, except that they have a web
+   of LLVM intrinsic functions that point to them.  If the last references to a
+   particular piece of debugging information are deleted (for example, by the
+   <tt>-globaldce</tt> pass), the extraneous debug information will
+   automatically become dead and be removed by the optimizer.</p>
 
 <p>Debug information is designed to be agnostic about the target debugger and
    debugging information representation (e.g. DWARF/Stabs/etc).  It uses a
-   generic pass to decode the information that represents variables, types, 
-   functions, namespaces, etc: this allows for arbitrary source-language 
-   semantics and type-systems to be used, as long as there is a module 
-   written for the target debugger to interpret the information. </p>
+   generic machine debug information pass to decode the information that
+   represents variables, types, functions, namespaces, etc: this allows for
+   arbitrary source-language semantics and type-systems to be used, as long as
+   there is a module written for the target debugger to interpret the
+   information. In addition, debug global variables are declared in
+   the <tt>"llvm.metadata"</tt> section.  All values declared in this section
+   are stripped away after target debug information is constructed and before
+   the program object is emitted.</p>
 
 <p>To provide basic functionality, the LLVM debugger does have to make some
    assumptions about the source-level language being debugged, though it keeps
@@ -278,7 +288,9 @@
 <div class="doc_text">
 
 <p>In consideration of the complexity and volume of debug information, LLVM
-   provides a specification for well formed debug descriptors. </p>
+   provides a specification for well formed debug global variables.  The
+   constant value of each of these globals is one of a limited set of
+   structures, known as debug descriptors.</p>
 
 <p>Consumers of LLVM debug information expect the descriptors for program
    objects to start in a canonical format, but the descriptors can include
@@ -291,14 +303,17 @@
    the range 0x1000 thru 0x2000 (there is a defined enum DW_TAG_user_base =
    0x1000.)</p>
 
-<p>The fields of debug descriptors used internally by LLVM 
+<p>The fields of debug descriptors used internally by LLVM (MachineModuleInfo)
    are restricted to only the simple data types <tt>int</tt>, <tt>uint</tt>,
-   <tt>bool</tt>, <tt>float</tt>, <tt>double</tt>, <tt>mdstring</tt> and
-   <tt>mdnode</tt>. </p>
+   <tt>bool</tt>, <tt>float</tt>, <tt>double</tt>, <tt>i8*</tt> and
+   <tt>{ }*</tt>.  References to arbitrary values are handled using a
+   <tt>{ }*</tt> and a cast to <tt>{ }*</tt> expression; typically
+   references to other field descriptors, arrays of descriptors or global
+   variables.</p>
 
 <div class="doc_code">
 <pre>
-!1 = metadata !{
+%llvm.dbg.object.type = type {
   uint,   ;; A tag
   ...
 }
@@ -311,8 +326,8 @@
    of tags are loosely bound to the tag values of DWARF information entries.
    However, that does not restrict the use of the information supplied to DWARF
    targets.  To facilitate versioning of debug information, the tag is augmented
-   with the current debug version (LLVMDebugVersion = 7 << 16 or 0x70000 or
-   458752.)</a></p>
+   with the current debug version (LLVMDebugVersion = 4 << 16 or 0x40000 or
+   262144.)</a></p>
 
 <p>The details of the various descriptors follow.</p>  
 
@@ -327,18 +342,17 @@
 
 <div class="doc_code">
 <pre>
-!0 = metadata !{
-  i32,       ;; Tag = 17 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> 
-             ;; (DW_TAG_compile_unit)
-  i32,       ;; Unused field. 
-  i32,       ;; DWARF language identifier (ex. DW_LANG_C89) 
-  metadata,  ;; Source file name
-  metadata,  ;; Source file directory (includes trailing slash)
-  metadata   ;; Producer (ex. "4.0.1 LLVM (LLVM research group)")
-  i1,        ;; True if this is a main compile unit. 
-  i1,        ;; True if this is optimized.
-  metadata,  ;; Flags
-  i32        ;; Runtime version
+%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = type {
+  i32,    ;; Tag = 17 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_compile_unit)
+  {  }*,  ;; Compile unit anchor = cast = (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_units</a> to {  }*)
+  i32,    ;; DWARF language identifier (ex. DW_LANG_C89) 
+  i8*,    ;; Source file name
+  i8*,    ;; Source file directory (includes trailing slash)
+  i8*     ;; Producer (ex. "4.0.1 LLVM (LLVM research group)")
+  i1,     ;; True if this is a main compile unit. 
+  i1,     ;; True if this is optimized.
+  i8*,    ;; Flags
+  i32     ;; Runtime version
 }
 </pre>
 </div>
@@ -374,20 +388,19 @@
 
 <div class="doc_code">
 <pre>
-!1 = metadata !{
-  i32,      ;; Tag = 52 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> 
-            ;; (DW_TAG_variable)
-  i32,      ;; Unused field.
-  metadata, ;; Reference to context descriptor
-  metadata, ;; Name
-  metadata, ;; Display name (fully qualified C++ name)
-  metadata, ;; MIPS linkage name (for C++)
-  metadata, ;; Reference to compile unit where defined
-  i32,      ;; Line number where defined
-  metadata, ;; Reference to type descriptor
-  i1,       ;; True if the global is local to compile unit (static)
-  i1,       ;; True if the global is defined in the compile unit (not extern)
-  {  }*     ;; Reference to the global variable
+%<a href="#format_global_variables">llvm.dbg.global_variable.type</a> = type {
+  i32,    ;; Tag = 52 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_variable)
+  {  }*,  ;; Global variable anchor = cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_global_variables">llvm.dbg.global_variables</a> to {  }*),  
+  {  }*,  ;; Reference to context descriptor
+  i8*,    ;; Name
+  i8*,    ;; Display name (fully qualified C++ name)
+  i8*,    ;; MIPS linkage name (for C++)
+  {  }*,  ;; Reference to compile unit where defined
+  i32,    ;; Line number where defined
+  {  }*,  ;; Reference to type descriptor
+  i1,     ;; True if the global is local to compile unit (static)
+  i1,     ;; True if the global is defined in the compile unit (not extern)
+  {  }*   ;; Reference to the global variable
 }
 </pre>
 </div>
@@ -406,19 +419,18 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32,      ;; Tag = 46 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a>
-            ;; (DW_TAG_subprogram)
-  i32,      ;; Unused field.
-  metadata, ;; Reference to context descriptor
-  metadata, ;; Name
-  metadata, ;; Display name (fully qualified C++ name)
-  metadata, ;; MIPS linkage name (for C++)
-  metadata, ;; Reference to compile unit where defined
-  i32,      ;; Line number where defined
-  metadata, ;; Reference to type descriptor
-  i1,       ;; True if the global is local to compile unit (static)
-  i1        ;; True if the global is defined in the compile unit (not extern)
+%<a href="#format_subprograms">llvm.dbg.subprogram.type</a> = type {
+  i32,    ;; Tag = 46 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_subprogram)
+  {  }*,  ;; Subprogram anchor = cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_subprograms">llvm.dbg.subprograms</a> to {  }*),  
+  {  }*,  ;; Reference to context descriptor
+  i8*,    ;; Name
+  i8*,    ;; Display name (fully qualified C++ name)
+  i8*,    ;; MIPS linkage name (for C++)
+  {  }*,  ;; Reference to compile unit where defined
+  i32,    ;; Line number where defined
+  {  }*,  ;; Reference to type descriptor
+  i1,     ;; True if the global is local to compile unit (static)
+  i1      ;; True if the global is defined in the compile unit (not extern)
 }
 </pre>
 </div>
@@ -438,9 +450,9 @@
 
 <div class="doc_code">
 <pre>
-!3 = metadata !{
-  i32,     ;; Tag = 13 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_lexical_block)
-  metadata ;; Reference to context descriptor
+%<a href="#format_blocks">llvm.dbg.block</a> = type {
+  i32,    ;; Tag = 13 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_lexical_block)
+  {  }*   ;; Reference to context descriptor
 }
 </pre>
 </div>
@@ -460,18 +472,17 @@
 
 <div class="doc_code">
 <pre>
-!4 = metadata !{
-  i32,      ;; Tag = 36 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> 
-            ;; (DW_TAG_base_type)
-  metadata, ;; Reference to context (typically a compile unit)
-  metadata, ;; Name (may be "" for anonymous types)
-  metadata, ;; Reference to compile unit where defined (may be NULL)
-  i32,      ;; Line number where defined (may be 0)
-  i64,      ;; Size in bits
-  i64,      ;; Alignment in bits
-  i64,      ;; Offset in bits
-  i32,      ;; Flags
-  i32       ;; DWARF type encoding
+%<a href="#format_basic_type">llvm.dbg.basictype.type</a> = type {
+  i32,    ;; Tag = 36 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_base_type)
+  {  }*,  ;; Reference to context (typically a compile unit)
+  i8*,    ;; Name (may be "" for anonymous types)
+  {  }*,  ;; Reference to compile unit where defined (may be NULL)
+  i32,    ;; Line number where defined (may be 0)
+  i64,    ;; Size in bits
+  i64,    ;; Alignment in bits
+  i64,    ;; Offset in bits
+  i32,    ;; Flags
+  i32     ;; DWARF type encoding
 }
 </pre>
 </div>
@@ -512,16 +523,16 @@
 
 <div class="doc_code">
 <pre>
-!5 = metadata !{
-  i32,      ;; Tag (see below)
-  metadata, ;; Reference to context
-  metadata, ;; Name (may be "" for anonymous types)
-  metadata, ;; Reference to compile unit where defined (may be NULL)
-  i32,      ;; Line number where defined (may be 0)
-  i32,      ;; Size in bits
-  i32,      ;; Alignment in bits
-  i32,      ;; Offset in bits
-  metadata  ;; Reference to type derived from
+%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> = type {
+  i32,    ;; Tag (see below)
+  {  }*,  ;; Reference to context
+  i8*,    ;; Name (may be "" for anonymous types)
+  {  }*,  ;; Reference to compile unit where defined (may be NULL)
+  i32,    ;; Line number where defined (may be 0)
+  i32,    ;; Size in bits
+  i32,    ;; Alignment in bits
+  i32,    ;; Offset in bits
+  {  }*   ;; Reference to type derived from
 }
 </pre>
 </div>
@@ -580,19 +591,19 @@
 
 <div class="doc_code">
 <pre>
-!6 = metadata !{
-  i32,      ;; Tag (see below)
-  metadata, ;; Reference to context
-  metadata, ;; Name (may be "" for anonymous types)
-  metadata, ;; Reference to compile unit where defined (may be NULL)
-  i32,      ;; Line number where defined (may be 0)
-  i64,      ;; Size in bits
-  i64,      ;; Alignment in bits
-  i64,      ;; Offset in bits
-  i32,      ;; Flags
-  metadata, ;; Reference to type derived from
-  metadata, ;; Reference to array of member descriptors
-  i32       ;; Runtime languages
+%<a href="#format_composite_type">llvm.dbg.compositetype.type</a> = type {
+  i32,    ;; Tag (see below)
+  {  }*,  ;; Reference to context
+  i8*,    ;; Name (may be "" for anonymous types)
+  {  }*,  ;; Reference to compile unit where defined (may be NULL)
+  i32,    ;; Line number where defined (may be 0)
+  i64,    ;; Size in bits
+  i64,    ;; Alignment in bits
+  i64,    ;; Offset in bits
+  i32,    ;; Flags
+  {  }*,  ;; Reference to type derived from
+  {  }*,  ;; Reference to array of member descriptors
+  i32     ;; Runtime languages
 }
 </pre>
 </div>
@@ -691,11 +702,10 @@
 
 <div class="doc_code">
 <pre>
-!6 = metadata !{
-  i32,      ;; Tag = 40 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> 
-            ;; (DW_TAG_enumerator)
-  metadata, ;; Name
-  i64       ;; Value
+%<a href="#format_enumeration">llvm.dbg.enumerator.type</a> = type {
+  i32,    ;; Tag = 40 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_enumerator)
+  i8*,    ;; Name
+  i64     ;; Value
 }
 </pre>
 </div>
@@ -715,13 +725,13 @@
 
 <div class="doc_code">
 <pre>
-!7 = metadata !{
-  i32,      ;; Tag (see below)
-  metadata, ;; Context
-  metadata, ;; Name
-  metadata, ;; Reference to compile unit where defined
-  i32,      ;; Line number where defined
-  metadata  ;; Type descriptor
+%<a href="#format_variables">llvm.dbg.variable.type</a> = type {
+  i32,     ;; Tag (see below)
+  {  }*,   ;; Context
+  i8*,     ;; Name
+  {  }*,   ;; Reference to compile unit where defined
+  i32,     ;; Line number where defined
+  {  }*    ;; Type descriptor
 }
 </pre>
 </div>
@@ -768,14 +778,14 @@
 
 <div class="doc_text">
 <pre>
-  void %<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint, uint, metadata)
+  void %<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint, uint, { }* )
 </pre>
 
 <p>This intrinsic is used to provide correspondence between the source file and
    the generated code.  The first argument is the line number (base 1), second
    argument is the column number (0 if unknown) and the third argument the
-   source <tt>%<a href="#format_compile_units">llvm.dbg.compile_unit</a>.
-   Code following a call to this intrinsic will
+   source <tt>%<a href="#format_compile_units">llvm.dbg.compile_unit</a>*</tt>
+   cast to a <tt>{ }*</tt>.  Code following a call to this intrinsic will
    have been defined in close proximity of the line, column and file. This
    information holds until the next call
    to <tt>%<a href="#format_common_stoppoint">lvm.dbg.stoppoint</a></tt>.</p>
@@ -789,7 +799,7 @@
 
 <div class="doc_text">
 <pre>
-  void %<a href="#format_common_func_start">llvm.dbg.func.start</a>( metadata )
+  void %<a href="#format_common_func_start">llvm.dbg.func.start</a>( { }* )
 </pre>
 
 <p>This intrinsic is used to link the debug information
@@ -813,7 +823,7 @@
 
 <div class="doc_text">
 <pre>
-  void %<a href="#format_common_region_start">llvm.dbg.region.start</a>( metadata )
+  void %<a href="#format_common_region_start">llvm.dbg.region.start</a>( { }* )
 </pre>
 
 <p>This intrinsic is used to define the beginning of a declarative scope (ex.
@@ -833,7 +843,7 @@
 
 <div class="doc_text">
 <pre>
-  void %<a href="#format_common_region_end">llvm.dbg.region.end</a>( metadata )
+  void %<a href="#format_common_region_end">llvm.dbg.region.end</a>( { }* )
 </pre>
 
 <p>This intrinsic is used to define the end of a declarative scope (ex. block)
@@ -854,14 +864,14 @@
 
 <div class="doc_text">
 <pre>
-  void %<a href="#format_common_declare">llvm.dbg.declare</a>( { } *, metadata )
+  void %<a href="#format_common_declare">llvm.dbg.declare</a>( { } *, { }* )
 </pre>
 
 <p>This intrinsic provides information about a local element (ex. variable.) The
    first argument is the alloca for the variable, cast to a <tt>{ }*</tt>. The
    second argument is
    the <tt>%<a href="#format_variables">llvm.dbg.variable</a></tt> containing
-   the description of the variable. </p>
+   the description of the variable, also cast to a <tt>{ }*</tt>.</p>
 
 </div>
 
@@ -945,29 +955,29 @@
     
     ...
     
-    call void @<a href="#format_common_func_start">llvm.dbg.func.start</a>( metadata !0)
+    call void @<a href="#format_common_func_start">llvm.dbg.func.start</a>( %<a href="#format_subprograms">llvm.dbg.subprogram.type</a>* @llvm.dbg.subprogram )
     
-    call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 2, uint 2, metadata !1)
+    call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 2, uint 2, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* @llvm.dbg.compile_unit )
     
     call void @<a href="#format_common_declare">llvm.dbg.declare</a>({}* %X, ...)
     call void @<a href="#format_common_declare">llvm.dbg.declare</a>({}* %Y, ...)
     
     <i>;; Evaluate expression on line 2, assigning to X.</i>
     
-    call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 3, uint 2, metadata !1)
+    call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 3, uint 2, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* @llvm.dbg.compile_unit )
     
     <i>;; Evaluate expression on line 3, assigning to Y.</i>
     
     call void @<a href="#format_common_stoppoint">llvm.region.start</a>()
-    call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 5, uint 4, metadata !1)
+    call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 5, uint 4, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* @llvm.dbg.compile_unit )
     call void @<a href="#format_common_declare">llvm.dbg.declare</a>({}* %X, ...)
     
     <i>;; Evaluate expression on line 5, assigning to Z.</i>
     
-    call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 7, uint 2, metadata !1)
+    call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 7, uint 2, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* @llvm.dbg.compile_unit )
     call void @<a href="#format_common_region_end">llvm.region.end</a>()
     
-    call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 9, uint 2, metadata !1)
+    call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 9, uint 2, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* @llvm.dbg.compile_unit )
     
     call void @<a href="#format_common_region_end">llvm.region.end</a>()
     
@@ -1087,35 +1097,50 @@
 <pre>
 ...
 ;;
-;; Define the compile unit for the source file "/Users/mine/sources/MySource.cpp".
+;; Define types used.  In this case we need one for compile unit anchors and one
+;; for compile units.
+;;
+%<a href="#format_anchors">llvm.dbg.anchor.type</a> = type { uint, uint }
+%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = type { uint, {  }*, uint, uint, i8*, i8*, i8* }
+...
+;;
+;; Define the anchor for compile units.  Note that the second field of the
+;; anchor is 17, which is the same as the tag for compile units
+;; (17 = DW_TAG_compile_unit.)
 ;;
-!3 = metadata !{
-  i32 458769,    ;; Tag
-  i32 0,         ;; Unused
-  i32 4,         ;; Language Id
-  metadata !"MySource.cpp", 
-  metadata !"/Users/mine/sources", 
-  metadata !"4.2.1 (Based on Apple Inc. build 5649) (LLVM build 00)", 
-  i1 true,       ;; Main Compile Unit
-  i1 false,      ;; Optimized compile unit
-  metadata !"",  ;; Compiler flags
-  i32 0}         ;; Runtime version
+%<a href="#format_compile_units">llvm.dbg.compile_units</a> = linkonce constant %<a href="#format_anchors">llvm.dbg.anchor.type</a> { uint 0, uint 17 }, section "llvm.metadata"
 
 ;;
+;; Define the compile unit for the source file "/Users/mine/sources/MySource.cpp".
+;;
+%<a href="#format_compile_units">llvm.dbg.compile_unit1</a> = internal constant %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> {
+    uint add(uint 17, uint 262144), 
+    {  }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_units</a> to {  }*), 
+    uint 1, 
+    uint 1, 
+    i8* getelementptr ([13 x i8]* %str1, i32 0, i32 0), 
+    i8* getelementptr ([21 x i8]* %str2, i32 0, i32 0), 
+    i8* getelementptr ([33 x i8]* %str3, i32 0, i32 0) }, section "llvm.metadata"
+    
+;;
 ;; Define the compile unit for the header file "/Users/mine/sources/MyHeader.h".
 ;;
-!1 = metadata !{
-  i32 458769,    ;; Tag
-  i32 0,         ;; Unused
-  i32 4,         ;; Language Id
-  metadata !"MyHeader.h", 
-  metadata !"/Users/mine/sources", 
-  metadata !"4.2.1 (Based on Apple Inc. build 5649) (LLVM build 00)", 
-  i1 false,      ;; Main Compile Unit
-  i1 false,      ;; Optimized compile unit
-  metadata !"",  ;; Compiler flags
-  i32 0}         ;; Runtime version
-
+%<a href="#format_compile_units">llvm.dbg.compile_unit2</a> = internal constant %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> {
+    uint add(uint 17, uint 262144), 
+    {  }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_units</a> to {  }*), 
+    uint 1, 
+    uint 1, 
+    i8* getelementptr ([11 x i8]* %str4, int 0, int 0), 
+    i8* getelementptr ([21 x i8]* %str2, int 0, int 0), 
+    i8* getelementptr ([33 x i8]* %str3, int 0, int 0) }, section "llvm.metadata"
+
+;;
+;; Define each of the strings used in the compile units.
+;;
+%str1 = internal constant [13 x i8] c"MySource.cpp\00", section "llvm.metadata";
+%str2 = internal constant [21 x i8] c"/Users/mine/sources/\00", section "llvm.metadata";
+%str3 = internal constant [33 x i8] c"4.0.1 LLVM (LLVM research group)\00", section "llvm.metadata";
+%str4 = internal constant [11 x i8] c"MyHeader.h\00", section "llvm.metadata";
 ...
 </pre>
 </div>
@@ -1142,51 +1167,65 @@
 <div class="doc_code">
 <pre>
 ;;
+;; Define types used. One for global variable anchors, one for the global
+;; variable descriptor, one for the global's basic type and one for the global's
+;; compile unit.
+;;
+%<a href="#format_anchors">llvm.dbg.anchor.type</a> = type { uint, uint }
+%<a href="#format_global_variables">llvm.dbg.global_variable.type</a> = type { uint, {  }*, {  }*, i8*, {  }*, uint, {  }*, bool, bool, {  }*, uint }
+%<a href="#format_basic_type">llvm.dbg.basictype.type</a> = type { uint, {  }*, i8*, {  }*, int, uint, uint, uint, uint }
+%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = ...
+...
+;;
 ;; Define the global itself.
 ;;
 %MyGlobal = global int 100
 ...
 ;;
-;; List of debug info of globals
+;; Define the anchor for global variables.  Note that the second field of the
+;; anchor is 52, which is the same as the tag for global variables
+;; (52 = DW_TAG_variable.)
 ;;
-!llvm.dbg.gv = !{!0}
+%<a href="#format_global_variables">llvm.dbg.global_variables</a> = linkonce constant %<a href="#format_anchors">llvm.dbg.anchor.type</a> { uint 0, uint 52 }, section "llvm.metadata"
 
 ;;
 ;; Define the global variable descriptor.  Note the reference to the global
 ;; variable anchor and the global variable itself.
 ;;
-!0 = metadata !{
-  i32 458804,              ;; Tag
-  i32 0,                   ;; Unused
-  metadata !1,             ;; Context
-  metadata !"MyGlobal",    ;; Name
-  metadata !"MyGlobal",    ;; Display Name
-  metadata !"MyGlobal",    ;; Linkage Name
-  metadata !1,             ;; Compile Unit
-  i32 1,                   ;; Line Number
-  metadata !2,             ;; Type
-  i1 false,                ;; Is a local variable
-  i1 true,                 ;; Is this a definition
-  i32* @MyGlobal           ;; The global variable
-}
-
+%<a href="#format_global_variables">llvm.dbg.global_variable</a> = internal constant %<a href="#format_global_variables">llvm.dbg.global_variable.type</a> {
+    uint add(uint 52, uint 262144), 
+    {  }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_global_variables">llvm.dbg.global_variables</a> to {  }*), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([9 x i8]* %str1, int 0, int 0), 
+    i8* getelementptr ([1 x i8]* %str2, int 0, int 0), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    uint 1,
+    {  }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to {  }*), 
+    bool false, 
+    bool true, 
+    {  }* cast (int* %MyGlobal to {  }*) }, section "llvm.metadata"
+    
 ;;
 ;; Define the basic type of 32 bit signed integer.  Note that since int is an
 ;; intrinsic type the source file is NULL and line 0.
 ;;    
-!2 = metadata !{
-  i32 458788,              ;; Tag
-  metadata !1,             ;; Context
-  metadata !"int",         ;; Name
-  metadata !1,             ;; Compile Unit
-  i32 0,                   ;; Line number
-  i64 32,                  ;; Size in Bits
-  i64 32,                  ;; Align in Bits
-  i64 0,                   ;; Offset in Bits
-  i32 0,                   ;; Flags
-  i32 5                    ;; Encoding
-}
-
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([4 x i8]* %str3, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 32, 
+    uint 32, 
+    uint 0, 
+    uint 5 }, section "llvm.metadata"
+
+;;
+;; Define the names of the global variable and basic type.
+;;
+%str1 = internal constant [9 x i8] c"MyGlobal\00", section "llvm.metadata"
+%str2 = internal constant [1 x i8] c"\00", section "llvm.metadata"
+%str3 = internal constant [4 x i8] c"int\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1214,27 +1253,46 @@
 <div class="doc_code">
 <pre>
 ;;
+;; Define types used. One for subprogram anchors, one for the subprogram
+;; descriptor, one for the global's basic type and one for the subprogram's
+;; compile unit.
+;;
+%<a href="#format_subprograms">llvm.dbg.subprogram.type</a> = type { uint, {  }*, {  }*, i8*, {  }*, bool, bool }
+%<a href="#format_anchors">llvm.dbg.anchor.type</a> = type { uint, uint }
+%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = ...
+	
+;;
 ;; Define the anchor for subprograms.  Note that the second field of the
 ;; anchor is 46, which is the same as the tag for subprograms
 ;; (46 = DW_TAG_subprogram.)
 ;;
-!0 = metadata !{
-  i32 458798,        ;; Tag
-  i32 0,             ;; Unused
-  metadata !1,       ;; Context
-  metadata !"main",  ;; Name
-  metadata !"main",  ;; Display name
-  metadata !"main",  ;; Linkage name
-  metadata !1,       ;; Compile unit
-  i32 1,             ;; Line number
-  metadata !2,       ;; Type
-  i1 false,          ;; Is local 
-  i1 true            ;; Is definition
-}
+%<a href="#format_subprograms">llvm.dbg.subprograms</a> = linkonce constant %<a href="#format_anchors">llvm.dbg.anchor.type</a> { uint 0, uint 46 }, section "llvm.metadata"
+
+;;
+;; Define the descriptor for the subprogram.  TODO - more details.
+;;
+%<a href="#format_subprograms">llvm.dbg.subprogram</a> = internal constant %<a href="#format_subprograms">llvm.dbg.subprogram.type</a> {
+    uint add(uint 46, uint 262144), 
+    {  }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_subprograms">llvm.dbg.subprograms</a> to {  }*), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([5 x i8]* %str1, int 0, int 0), 
+    i8* getelementptr ([1 x i8]* %str2, int 0, int 0), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*),
+    uint 1,
+    {  }* null, 
+    bool false, 
+    bool true }, section "llvm.metadata"
+
+;;
+;; Define the name of the subprogram.
+;;
+%str1 = internal constant [5 x i8] c"main\00", section "llvm.metadata"
+%str2 = internal constant [1 x i8] c"\00", section "llvm.metadata"
+
 ;;
 ;; Define the subprogram itself.
 ;;
-define i32 @main(i32 %argc, i8** %argv) {
+int %main(int %argc, i8** %argv) {
 ...
 }
 </pre>
@@ -1262,18 +1320,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"bool",  ;; Name
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 8,             ;; Size in Bits
-  i64 8,             ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 2              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([5 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 32, 
+    uint 32, 
+    uint 0, 
+    uint 2 }, section "llvm.metadata"
+%str1 = internal constant [5 x i8] c"bool\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1288,18 +1345,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"char",  ;; Name
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 8,             ;; Size in Bits
-  i64 8,             ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 6              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([5 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 8, 
+    uint 8, 
+    uint 0, 
+    uint 6 }, section "llvm.metadata"
+%str1 = internal constant [5 x i8] c"char\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1314,18 +1370,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"unsigned char", 
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 8,             ;; Size in Bits
-  i64 8,             ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 8              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([14 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 8, 
+    uint 8, 
+    uint 0, 
+    uint 8 }, section "llvm.metadata"
+%str1 = internal constant [14 x i8] c"unsigned char\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1340,18 +1395,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"short int",
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 16,            ;; Size in Bits
-  i64 16,            ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 5              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([10 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 16, 
+    uint 16, 
+    uint 0, 
+    uint 5 }, section "llvm.metadata"
+%str1 = internal constant [10 x i8] c"short int\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1366,18 +1420,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"short unsigned int",
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 16,            ;; Size in Bits
-  i64 16,            ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 7              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([19 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 16, 
+    uint 16, 
+    uint 0, 
+    uint 7 }, section "llvm.metadata"
+%str1 = internal constant [19 x i8] c"short unsigned int\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1392,18 +1445,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"int",   ;; Name
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 32,            ;; Size in Bits
-  i64 32,            ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 5              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([4 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 32, 
+    uint 32, 
+    uint 0, 
+    uint 5 }, section "llvm.metadata"
+%str1 = internal constant [4 x i8] c"int\00", section "llvm.metadata"
 </pre></div>
 
 </div>
@@ -1417,18 +1469,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"unsigned int",
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 32,            ;; Size in Bits
-  i64 32,            ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 7              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([13 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 32, 
+    uint 32, 
+    uint 0, 
+    uint 7 }, section "llvm.metadata"
+%str1 = internal constant [13 x i8] c"unsigned int\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1443,18 +1494,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"long long int",
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 64,            ;; Size in Bits
-  i64 64,            ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 5              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([14 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 64, 
+    uint 64, 
+    uint 0, 
+    uint 5 }, section "llvm.metadata"
+%str1 = internal constant [14 x i8] c"long long int\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1469,18 +1519,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"long long unsigned int",
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 64,            ;; Size in Bits
-  i64 64,            ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 7              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([23 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 64, 
+    uint 64, 
+    uint 0, 
+    uint 7 }, section "llvm.metadata"
+%str1 = internal constant [23 x 8] c"long long unsigned int\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1495,18 +1544,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"float",
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 32,            ;; Size in Bits
-  i64 32,            ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 4              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([6 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 32, 
+    uint 32, 
+    uint 0, 
+    uint 4 }, section "llvm.metadata"
+%str1 = internal constant [6 x i8] c"float\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1521,18 +1569,17 @@
 
 <div class="doc_code">
 <pre>
-!2 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"double",;; Name
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 64,            ;; Size in Bits
-  i64 64,            ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 4              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    8* getelementptr ([7 x 8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 64, 
+    uint 64, 
+    uint 0, 
+    uint 4 }, section "llvm.metadata"
+%str1 = internal constant [7 x 8] c"double\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1560,64 +1607,60 @@
 ;;
 ;; Define the typedef "IntPtr".
 ;;
-!2 = metadata !{
-  i32 458774,          ;; Tag
-  metadata !1,         ;; Context
-  metadata !"IntPtr",  ;; Name
-  metadata !3,         ;; Compile unit
-  i32 0,               ;; Line number
-  i64 0,               ;; Size in bits
-  i64 0,               ;; Align in bits
-  i64 0,               ;; Offset in bits
-  i32 0,               ;; Flags
-  metadata !4          ;; Derived From type
-}
+%<a href="#format_derived_type">llvm.dbg.derivedtype1</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
+    uint add(uint 22, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([7 x 8]* %str1, int 0, int 0), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    int 1, 
+    uint 0, 
+    uint 0, 
+    uint 0, 
+    {  }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype2</a> to {  }*) }, section "llvm.metadata"
+%str1 = internal constant [7 x 8] c"IntPtr\00", section "llvm.metadata"
 
 ;;
 ;; Define the pointer type.
 ;;
-!4 = metadata !{
-  i32 458767,          ;; Tag
-  metadata !1,         ;; Context
-  metadata !"",        ;; Name
-  metadata !1,         ;; Compile unit
-  i32 0,               ;; Line number
-  i64 64,              ;; Size in bits
-  i64 64,              ;; Align in bits
-  i64 0,               ;; Offset in bits
-  i32 0,               ;; Flags
-  metadata !5          ;; Derived From type
-}
+%<a href="#format_derived_type">llvm.dbg.derivedtype2</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
+    uint add(uint 15, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* null, 
+    {  }* null, 
+    int 0, 
+    uint 32, 
+    uint 32, 
+    uint 0, 
+    {  }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype3</a> to {  }*) }, section "llvm.metadata"
+
 ;;
 ;; Define the const type.
 ;;
-!5 = metadata !{
-  i32 458790,          ;; Tag
-  metadata !1,         ;; Context
-  metadata !"",        ;; Name
-  metadata !1,         ;; Compile unit
-  i32 0,               ;; Line number
-  i64 32,              ;; Size in bits
-  i64 32,              ;; Align in bits
-  i64 0,               ;; Offset in bits
-  i32 0,               ;; Flags
-  metadata !6          ;; Derived From type
-}
+%<a href="#format_derived_type">llvm.dbg.derivedtype3</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
+    uint add(uint 38, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* null, 
+    {  }* null, 
+    int 0, 
+    uint 0, 
+    uint 0, 
+    uint 0, 
+    {  }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype1</a> to {  }*) }, section "llvm.metadata"	
+
 ;;
 ;; Define the int type.
 ;;
-!6 = metadata !{
-  i32 458788,          ;; Tag
-  metadata !1,         ;; Context
-  metadata !"int",     ;; Name
-  metadata !1,         ;; Compile unit
-  i32 0,               ;; Line number
-  i64 32,              ;; Size in bits
-  i64 32,              ;; Align in bits
-  i64 0,               ;; Offset in bits
-  i32 0,               ;; Flags
-  5                    ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype1</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    8* getelementptr ([4 x 8]* %str2, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 32, 
+    uint 32, 
+    uint 0, 
+    uint 5 }, section "llvm.metadata"
+%str2 = internal constant [4 x 8] c"int\00", section "llvm.metadata"
 </pre>
 </div>
 
@@ -1649,88 +1692,86 @@
 ;;
 ;; Define basic type for unsigned int.
 ;;
-!5 = metadata !{
-  i32 458788,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"unsigned int",
-  metadata !1,       ;; Compile Unit
-  i32 0,             ;; Line number
-  i64 32,            ;; Size in Bits
-  i64 32,            ;; Align in Bits
-  i64 0,             ;; Offset in Bits
-  i32 0,             ;; Flags
-  i32 7              ;; Encoding
-}
+%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
+    uint add(uint 36, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([13 x i8]* %str1, int 0, int 0), 
+    {  }* null, 
+    int 0, 
+    uint 32, 
+    uint 32, 
+    uint 0, 
+    uint 7 }, section "llvm.metadata"
+%str1 = internal constant [13 x i8] c"unsigned int\00", section "llvm.metadata"
+
 ;;
 ;; Define composite type for struct Color.
 ;;
-!2 = metadata !{
-  i32 458771,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"Color", ;; Name
-  metadata !1,       ;; Compile unit
-  i32 1,             ;; Line number
-  i64 96,            ;; Size in bits
-  i64 32,            ;; Align in bits
-  i64 0,             ;; Offset in bits
-  i32 0,             ;; Flags
-  null,              ;; Derived From
-  metadata !3,       ;; Elements
-  i32 0              ;; Runtime Language
-}
+%<a href="#format_composite_type">llvm.dbg.compositetype</a> = internal constant %<a href="#format_composite_type">llvm.dbg.compositetype.type</a> {
+    uint add(uint 19, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([6 x i8]* %str2, int 0, int 0), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    int 1, 
+    uint 96, 
+    uint 32, 
+    uint 0, 
+    {  }* null,
+    {  }* cast ([3 x {  }*]* %llvm.dbg.array to {  }*) }, section "llvm.metadata"
+%str2 = internal constant [6 x i8] c"Color\00", section "llvm.metadata"
 
 ;;
 ;; Define the Red field.
 ;;
-!4 = metadata !{
-  i32 458765,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"Red",   ;; Name
-  metadata !1,       ;; Compile Unit
-  i32 2,             ;; Line number
-  i64 32,            ;; Size in bits
-  i64 32,            ;; Align in bits
-  i64 0,             ;; Offset in bits
-  i32 0,             ;; Flags
-  metadata !5        ;; Derived From type
-}
+%<a href="#format_derived_type">llvm.dbg.derivedtype1</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
+    uint add(uint 13, uint 262144), 
+    {  }* null, 
+    i8* getelementptr ([4 x i8]* %str3, int 0, int 0), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    int 2, 
+    uint 32, 
+    uint 32, 
+    uint 0, 
+    {  }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to {  }*) }, section "llvm.metadata"
+%str3 = internal constant [4 x i8] c"Red\00", section "llvm.metadata"
 
 ;;
 ;; Define the Green field.
 ;;
-!6 = metadata !{
-  i32 458765,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"Green", ;; Name
-  metadata !1,       ;; Compile Unit
-  i32 3,             ;; Line number
-  i64 32,            ;; Size in bits
-  i64 32,            ;; Align in bits
-  i64 32,             ;; Offset in bits
-  i32 0,             ;; Flags
-  metadata !5        ;; Derived From type
-}
+%<a href="#format_derived_type">llvm.dbg.derivedtype2</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
+    uint add(uint 13, uint 262144), 
+    {  }* null, 
+    i8* getelementptr ([6 x i8]* %str4, int 0, int 0), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    int 3, 
+    uint 32, 
+    uint 32, 
+    uint 32, 
+    {  }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to {  }*) }, section "llvm.metadata"
+%str4 = internal constant [6 x i8] c"Green\00", section "llvm.metadata"
 
 ;;
 ;; Define the Blue field.
 ;;
-!7 = metadata !{
-  i32 458765,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"Blue",  ;; Name
-  metadata !1,       ;; Compile Unit
-  i32 4,             ;; Line number
-  i64 32,            ;; Size in bits
-  i64 32,            ;; Align in bits
-  i64 64,             ;; Offset in bits
-  i32 0,             ;; Flags
-  metadata !5        ;; Derived From type
-}
+%<a href="#format_derived_type">llvm.dbg.derivedtype3</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
+    uint add(uint 13, uint 262144), 
+    {  }* null, 
+    i8* getelementptr ([5 x i8]* %str5, int 0, int 0), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    int 4, 
+    uint 32, 
+    uint 32, 
+    uint 64, 
+    {  }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to {  }*) }, section "llvm.metadata"
+%str5 = internal constant [5 x 8] c"Blue\00", section "llvm.metadata"
 
 ;;
 ;; Define the array of fields used by the composite type Color.
 ;;
-!3 = metadata !{metadata !4, metadata !6, metadata !7}
+%llvm.dbg.array = internal constant [3 x {  }*] [
+      {  }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype1</a> to {  }*),
+      {  }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype2</a> to {  }*),
+      {  }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype3</a> to {  }*) ], section "llvm.metadata"
 </pre>
 </div>
 
@@ -1762,41 +1803,53 @@
 ;;
 ;; Define composite type for enum Trees
 ;;
-!2 = metadata !{
-  i32 458756,        ;; Tag
-  metadata !1,       ;; Context
-  metadata !"Trees", ;; Name
-  metadata !1,       ;; Compile unit
-  i32 1,             ;; Line number
-  i64 32,            ;; Size in bits
-  i64 32,            ;; Align in bits
-  i64 0,             ;; Offset in bits
-  i32 0,             ;; Flags
-  null,              ;; Derived From type
-  metadata !3,       ;; Elements
-  i32 0              ;; Runtime language
-}
-
-;;
-;; Define the array of enumerators used by composite type Trees.
-;;
-!3 = metadata !{metadata !4, metadata !5, metadata !6}
+%<a href="#format_composite_type">llvm.dbg.compositetype</a> = internal constant %<a href="#format_composite_type">llvm.dbg.compositetype.type</a> {
+    uint add(uint 4, uint 262144), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    i8* getelementptr ([6 x i8]* %str1, int 0, int 0), 
+    {  }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to {  }*), 
+    int 1, 
+    uint 32, 
+    uint 32, 
+    uint 0, 
+    {  }* null, 
+    {  }* cast ([3 x {  }*]* %llvm.dbg.array to {  }*) }, section "llvm.metadata"
+%str1 = internal constant [6 x i8] c"Trees\00", section "llvm.metadata"
 
 ;;
 ;; Define Spruce enumerator.
 ;;
-!4 = metadata !{i32 458792, metadata !"Spruce", i64 100}
+%<a href="#format_enumeration">llvm.dbg.enumerator1</a> = internal constant %<a href="#format_enumeration">llvm.dbg.enumerator.type</a> {
+    uint add(uint 40, uint 262144), 
+    i8* getelementptr ([7 x i8]* %str2, int 0, int 0), 
+    int 100 }, section "llvm.metadata"
+%str2 = internal constant [7 x i8] c"Spruce\00", section "llvm.metadata"
 
 ;;
 ;; Define Oak enumerator.
 ;;
-!5 = metadata !{i32 458792, metadata !"Oak", i64 200}
+%<a href="#format_enumeration">llvm.dbg.enumerator2</a> = internal constant %<a href="#format_enumeration">llvm.dbg.enumerator.type</a> {
+    uint add(uint 40, uint 262144), 
+    i8* getelementptr ([4 x i8]* %str3, int 0, int 0), 
+    int 200 }, section "llvm.metadata"
+%str3 = internal constant [4 x i8] c"Oak\00", section "llvm.metadata"
 
 ;;
 ;; Define Maple enumerator.
 ;;
-!6 = metadata !{i32 458792, metadata !"Maple", i64 300}
+%<a href="#format_enumeration">llvm.dbg.enumerator3</a> = internal constant %<a href="#format_enumeration">llvm.dbg.enumerator.type</a> {
+    uint add(uint 40, uint 262144), 
+    i8* getelementptr ([6 x i8]* %str4, int 0, int 0), 
+    int 300 }, section "llvm.metadata"
+%str4 = internal constant [6 x i8] c"Maple\00", section "llvm.metadata"
 
+;;
+;; Define the array of enumerators used by composite type Trees.
+;;
+%llvm.dbg.array = internal constant [3 x {  }*] [
+  {  }* cast (%<a href="#format_enumeration">llvm.dbg.enumerator.type</a>* %<a href="#format_enumeration">llvm.dbg.enumerator1</a> to {  }*),
+  {  }* cast (%<a href="#format_enumeration">llvm.dbg.enumerator.type</a>* %<a href="#format_enumeration">llvm.dbg.enumerator2</a> to {  }*),
+  {  }* cast (%<a href="#format_enumeration">llvm.dbg.enumerator.type</a>* %<a href="#format_enumeration">llvm.dbg.enumerator3</a> to {  }*) ], section "llvm.metadata"
 </pre>
 </div>
 

Modified: llvm/branches/Apple/L2/include/llvm/Analysis/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/Analysis/DebugInfo.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/Analysis/DebugInfo.h (original)
+++ llvm/branches/Apple/L2/include/llvm/Analysis/DebugInfo.h Sun Sep  6 16:39:36 2009
@@ -17,7 +17,6 @@
 #ifndef LLVM_ANALYSIS_DEBUGINFO_H
 #define LLVM_ANALYSIS_DEBUGINFO_H
 
-#include "llvm/Metadata.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/DenseMap.h"
@@ -45,12 +44,12 @@
 
   class DIDescriptor {
   protected:    
-    MDNode *DbgNode;
+    GlobalVariable *DbgGV;
 
-    /// DIDescriptor constructor.  If the specified node is non-null, check
+    /// DIDescriptor constructor.  If the specified GV is non-null, this checks
     /// to make sure that the tag in the descriptor matches 'RequiredTag'.  If
     /// not, the debug info is corrupt and we ignore it.
-    DIDescriptor(MDNode *N, unsigned RequiredTag);
+    DIDescriptor(GlobalVariable *GV, unsigned RequiredTag);
 
     const std::string &getStringField(unsigned Elt, std::string &Result) const;
     unsigned getUnsignedField(unsigned Elt) const {
@@ -61,18 +60,18 @@
 
     template <typename DescTy>
     DescTy getFieldAs(unsigned Elt) const {
-      return DescTy(getDescriptorField(Elt).getNode());
+      return DescTy(getDescriptorField(Elt).getGV());
     }
 
     GlobalVariable *getGlobalVariableField(unsigned Elt) const;
 
   public:
-    explicit DIDescriptor() : DbgNode(0) {}
-    explicit DIDescriptor(MDNode *N) : DbgNode(N) {}
+    explicit DIDescriptor() : DbgGV(0) {}
+    explicit DIDescriptor(GlobalVariable *GV) : DbgGV(GV) {}
 
-    bool isNull() const { return DbgNode == 0; }
+    bool isNull() const { return DbgGV == 0; }
 
-    MDNode *getNode() const { return DbgNode; }
+    GlobalVariable *getGV() const { return DbgGV; }
 
     unsigned getVersion() const {
       return getUnsignedField(0) & LLVMDebugVersionMask;
@@ -82,28 +81,18 @@
       return getUnsignedField(0) & ~LLVMDebugVersionMask;
     }
 
-    /// ValidDebugInfo - Return true if N represents valid debug info value.
-    static bool ValidDebugInfo(MDNode *N, CodeGenOpt::Level OptLevel);
+    /// ValidDebugInfo - Return true if V represents valid debug info value.
+    static bool ValidDebugInfo(Value *V, CodeGenOpt::Level OptLevel);
 
     /// dump - print descriptor.
     void dump() const;
-
-    bool isDerivedType() const;
-    bool isCompositeType() const;
-    bool isBasicType() const;
-    bool isVariable() const;
-    bool isSubprogram() const;
-    bool isGlobalVariable() const;
-    bool isScope() const;
-    bool isCompileUnit() const;
-    bool isLexicalBlock() const;
   };
 
   /// DISubrange - This is used to represent ranges, for array bounds.
   class DISubrange : public DIDescriptor {
   public:
-    explicit DISubrange(MDNode *N = 0)
-      : DIDescriptor(N, dwarf::DW_TAG_subrange_type) {}
+    explicit DISubrange(GlobalVariable *GV = 0)
+      : DIDescriptor(GV, dwarf::DW_TAG_subrange_type) {}
 
     int64_t getLo() const { return (int64_t)getUInt64Field(1); }
     int64_t getHi() const { return (int64_t)getUInt64Field(2); }
@@ -112,8 +101,7 @@
   /// DIArray - This descriptor holds an array of descriptors.
   class DIArray : public DIDescriptor {
   public:
-    explicit DIArray(MDNode *N = 0) 
-      : DIDescriptor(N) {}
+    explicit DIArray(GlobalVariable *GV = 0) : DIDescriptor(GV) {}
 
     unsigned getNumElements() const;
     DIDescriptor getElement(unsigned Idx) const {
@@ -121,32 +109,11 @@
     }
   };
 
-  /// DIScope - A base class for various scopes.
-  class DIScope : public DIDescriptor {
-  public:
-    explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {
-      if (DbgNode && !isScope())
-        DbgNode = 0;
-    }
-    virtual ~DIScope() {}
-
-    virtual const std::string &getFilename(std::string &F) const {
-      return F;
-    }
-
-    virtual const std::string &getDirectory(std::string &D) const {
-      return D;
-    }
-  };
-
   /// DICompileUnit - A wrapper for a compile unit.
-  class DICompileUnit : public DIScope {
+  class DICompileUnit : public DIDescriptor {
   public:
-    explicit DICompileUnit(MDNode *N = 0) {
-      DbgNode = N;
-      if (DbgNode && !isCompileUnit())
-	DbgNode = 0;
-    }
+    explicit DICompileUnit(GlobalVariable *GV = 0)
+      : DIDescriptor(GV, dwarf::DW_TAG_compile_unit) {}
 
     unsigned getLanguage() const     { return getUnsignedField(2); }
     const std::string &getFilename(std::string &F) const {
@@ -187,8 +154,8 @@
   /// type/precision or a file/line pair for location info.
   class DIEnumerator : public DIDescriptor {
   public:
-    explicit DIEnumerator(MDNode *N = 0)
-      : DIDescriptor(N, dwarf::DW_TAG_enumerator) {}
+    explicit DIEnumerator(GlobalVariable *GV = 0)
+      : DIDescriptor(GV, dwarf::DW_TAG_enumerator) {}
 
     const std::string &getName(std::string &F) const {
       return getStringField(1, F);
@@ -202,26 +169,36 @@
   class DIType : public DIDescriptor {
   public:
     enum {
-      FlagPrivate    = 1 << 0,
-      FlagProtected  = 1 << 1,
-      FlagFwdDecl    = 1 << 2,
-      FlagAppleBlock = 1 << 3,
-      FlagBlockByrefStruct = 1 << 4
+      FlagPrivate   = 1 << 0,
+      FlagProtected = 1 << 1,
+      FlagFwdDecl   = 1 << 2
     };
 
   protected:
-    DIType(MDNode *N, unsigned Tag) 
-      : DIDescriptor(N, Tag) {}
+    DIType(GlobalVariable *GV, unsigned Tag) : DIDescriptor(GV, Tag) {}
     // This ctor is used when the Tag has already been validated by a derived
     // ctor.
-    DIType(MDNode *N, bool, bool) : DIDescriptor(N) {}
+    DIType(GlobalVariable *GV, bool, bool) : DIDescriptor(GV) {}
 
   public:
+    /// isDerivedType - Return true if the specified tag is legal for
+    /// DIDerivedType.
+    static bool isDerivedType(unsigned TAG);
+
+    /// isCompositeType - Return true if the specified tag is legal for
+    /// DICompositeType.
+    static bool isCompositeType(unsigned TAG);
+
+    /// isBasicType - Return true if the specified tag is legal for
+    /// DIBasicType.
+    static bool isBasicType(unsigned TAG) {
+      return TAG == dwarf::DW_TAG_base_type;
+    }
 
     /// Verify - Verify that a type descriptor is well formed.
     bool Verify() const;
   public:
-    explicit DIType(MDNode *N);
+    explicit DIType(GlobalVariable *GV);
     explicit DIType() {}
     virtual ~DIType() {}
 
@@ -246,13 +223,6 @@
     bool isForwardDecl() const {
       return (getFlags() & FlagFwdDecl) != 0; 
     }
-    // isAppleBlock - Return true if this is the Apple Blocks extension.
-    bool isAppleBlockExtension() const {
-      return (getFlags() & FlagAppleBlock) != 0; 
-    }
-    bool isBlockByrefStruct() const {
-      return (getFlags() & FlagBlockByrefStruct) != 0;
-    }
 
     /// dump - print type.
     void dump() const;
@@ -261,8 +231,8 @@
   /// DIBasicType - A basic type, like 'int' or 'float'.
   class DIBasicType : public DIType {
   public:
-    explicit DIBasicType(MDNode *N = 0)
-      : DIType(N, dwarf::DW_TAG_base_type) {}
+    explicit DIBasicType(GlobalVariable *GV)
+      : DIType(GV, dwarf::DW_TAG_base_type) {}
 
     unsigned getEncoding() const { return getUnsignedField(9); }
 
@@ -274,13 +244,13 @@
   /// a typedef, a pointer or reference, etc.
   class DIDerivedType : public DIType {
   protected:
-    explicit DIDerivedType(MDNode *N, bool, bool)
-      : DIType(N, true, true) {}
+    explicit DIDerivedType(GlobalVariable *GV, bool, bool)
+      : DIType(GV, true, true) {}
   public:
-    explicit DIDerivedType(MDNode *N = 0)
-      : DIType(N, true, true) {
-      if (DbgNode && !isDerivedType())
-        DbgNode = 0;
+    explicit DIDerivedType(GlobalVariable *GV)
+      : DIType(GV, true, true) {
+      if (GV && !isDerivedType(getTag()))
+        DbgGV = 0;
     }
 
     DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
@@ -302,10 +272,10 @@
   /// FIXME: Why is this a DIDerivedType??
   class DICompositeType : public DIDerivedType {
   public:
-    explicit DICompositeType(MDNode *N = 0)
-      : DIDerivedType(N, true, true) {
-      if (N && !isCompositeType())
-        DbgNode = 0;
+    explicit DICompositeType(GlobalVariable *GV)
+      : DIDerivedType(GV, true, true) {
+      if (GV && !isCompositeType(getTag()))
+        DbgGV = 0;
     }
 
     DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
@@ -321,8 +291,20 @@
   /// DIGlobal - This is a common class for global variables and subprograms.
   class DIGlobal : public DIDescriptor {
   protected:
-    explicit DIGlobal(MDNode *N, unsigned RequiredTag)
-      : DIDescriptor(N, RequiredTag) {}
+    explicit DIGlobal(GlobalVariable *GV, unsigned RequiredTag)
+      : DIDescriptor(GV, RequiredTag) {}
+
+    /// isSubprogram - Return true if the specified tag is legal for
+    /// DISubprogram.
+    static bool isSubprogram(unsigned TAG) {
+      return TAG == dwarf::DW_TAG_subprogram;
+    }
+
+    /// isGlobalVariable - Return true if the specified tag is legal for
+    /// DIGlobalVariable.
+    static bool isGlobalVariable(unsigned TAG) {
+      return TAG == dwarf::DW_TAG_variable;
+    }
 
   public:
     virtual ~DIGlobal() {}
@@ -351,26 +333,11 @@
   };
 
   /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
-  class DISubprogram : public DIScope {
+  class DISubprogram : public DIGlobal {
   public:
-    explicit DISubprogram(MDNode *N = 0) {
-      DbgNode = N;
-      if (DbgNode && !isSubprogram())
-	DbgNode = 0;
-    }
+    explicit DISubprogram(GlobalVariable *GV = 0)
+      : DIGlobal(GV, dwarf::DW_TAG_subprogram) {}
 
-    DIDescriptor getContext() const     { return getDescriptorField(2); }
-    const std::string &getName(std::string &F) const {
-      return getStringField(3, F);
-    }
-    const std::string &getDisplayName(std::string &F) const {
-      return getStringField(4, F);
-    }
-    const std::string &getLinkageName(std::string &F) const {
-      return getStringField(5, F);
-    }
-    DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
-    unsigned getLineNumber() const      { return getUnsignedField(7); }
     DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
 
     /// getReturnTypeName - Subprogram return types are encoded either as
@@ -379,25 +346,13 @@
       DICompositeType DCT(getFieldAs<DICompositeType>(8));
       if (!DCT.isNull()) {
         DIArray A = DCT.getTypeArray();
-        DIType T(A.getElement(0).getNode());
+        DIType T(A.getElement(0).getGV());
         return T.getName(F);
       }
       DIType T(getFieldAs<DIType>(8));
       return T.getName(F);
     }
 
-    /// isLocalToUnit - Return true if this subprogram is local to the current
-    /// compile unit, like 'static' in C.
-    unsigned isLocalToUnit() const      { return getUnsignedField(9); }
-    unsigned isDefinition() const       { return getUnsignedField(10); }
-
-    const std::string &getFilename(std::string &F) const {
-      return getCompileUnit().getFilename(F);
-    }
-    const std::string &getDirectory(std::string &F) const {
-      return getCompileUnit().getDirectory(F);
-    }
-
     /// Verify - Verify that a subprogram descriptor is well formed.
     bool Verify() const;
 
@@ -412,8 +367,8 @@
   /// DIGlobalVariable - This is a wrapper for a global variable.
   class DIGlobalVariable : public DIGlobal {
   public:
-    explicit DIGlobalVariable(MDNode *N = 0)
-      : DIGlobal(N, dwarf::DW_TAG_variable) {}
+    explicit DIGlobalVariable(GlobalVariable *GV = 0)
+      : DIGlobal(GV, dwarf::DW_TAG_variable) {}
 
     GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
 
@@ -428,10 +383,10 @@
   /// global etc).
   class DIVariable : public DIDescriptor {
   public:
-    explicit DIVariable(MDNode *N = 0)
-      : DIDescriptor(N) {
-      if (DbgNode && !isVariable())
-        DbgNode = 0;
+    explicit DIVariable(GlobalVariable *GV = 0)
+      : DIDescriptor(GV) {
+      if (GV && !isVariable(getTag()))
+        DbgGV = 0;
     }
 
     DIDescriptor getContext() const { return getDescriptorField(1); }
@@ -442,54 +397,23 @@
     unsigned getLineNumber() const      { return getUnsignedField(4); }
     DIType getType() const              { return getFieldAs<DIType>(5); }
 
+    /// isVariable - Return true if the specified tag is legal for DIVariable.
+    static bool isVariable(unsigned Tag);
 
     /// Verify - Verify that a variable descriptor is well formed.
     bool Verify() const;
 
-    /// isBlockByrefVariable - Return true if the variable was declared as
-    /// a "__block" variable (Apple Blocks).
-    bool isBlockByrefVariable() const { 
-      return getType().isBlockByrefStruct(); 
-    }
-
     /// dump - print variable.
     void dump() const;
   };
 
-  /// DILexicalBlock - This is a wrapper for a lexical block.
-  class DILexicalBlock : public DIScope {
+  /// DIBlock - This is a wrapper for a block (e.g. a function, scope, etc).
+  class DIBlock : public DIDescriptor {
   public:
-    explicit DILexicalBlock(MDNode *N = 0) {
-      DbgNode = N;
-      if (DbgNode && !isLexicalBlock()) 
-	DbgNode = 0;
-    }
-    DIScope getContext() const { return getFieldAs<DIScope>(1); }
-
-    const std::string &getFilename(std::string &F) const {
-      return getContext().getFilename(F);
-    }
-    const std::string &getDirectory(std::string &D) const {
-      return getContext().getDirectory(D);
-    }
-  };
-
-  /// DILocation - This object holds location information. This object
-  /// is not associated with any DWARF tag.
-  class DILocation : public DIDescriptor {
-  public:
-    explicit DILocation(MDNode *L) { DbgNode = L; }
+    explicit DIBlock(GlobalVariable *GV = 0)
+      : DIDescriptor(GV, dwarf::DW_TAG_lexical_block) {}
 
-    unsigned getLineNumber() const     { return getUnsignedField(0); }
-    unsigned getColumnNumber() const   { return getUnsignedField(1); }
-    DIScope  getScope() const          { return getFieldAs<DIScope>(3); }
-    DILocation getOrigLocation() const { return getFieldAs<DILocation>(4); }
-    std::string getFilename(std::string &F) const  { 
-      return getScope().getFilename(F); 
-    }
-    std::string getDirectory(std::string &D) const { 
-      return getScope().getDirectory(D); 
-    }
+    DIDescriptor getContext() const { return getDescriptorField(1); }
   };
 
   /// DIFactory - This object assists with the construction of the various
@@ -588,13 +512,9 @@
                               DICompileUnit CompileUnit, unsigned LineNo,
                               DIType Type);
 
-    /// CreateLexicalBlock - This creates a descriptor for a lexical block 
-    /// with the specified parent context.
-    DILexicalBlock CreateLexicalBlock(DIDescriptor Context);
-
-    /// CreateLocation - Creates a debug info location.
-    DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo, 
-			      DIScope S, DILocation OrigLoc);
+    /// CreateBlock - This creates a descriptor for a lexical block with the
+    /// specified parent context.
+    DIBlock CreateBlock(DIDescriptor Context);
 
     /// InsertStopPoint - Create a new llvm.dbg.stoppoint intrinsic invocation,
     /// inserting it at the end of the specified basic block.
@@ -618,6 +538,10 @@
 
   private:
     Constant *GetTagConstant(unsigned TAG);
+    Constant *GetStringConstant(const std::string &String);
+
+    /// getCastToEmpty - Return the descriptor as a Constant* with type '{}*'.
+    Constant *getCastToEmpty(DIDescriptor D);
   };
 
   /// Finds the stoppoint coressponding to this instruction, that is the
@@ -679,6 +603,7 @@
 
   /// isInlinedFnEnd - Return true if REI is ending an inlined function.
   bool isInlinedFnEnd(DbgRegionEndInst &REI, const Function *CurrentFn);
+
   /// DebugInfoFinder - This object collects DebugInfo from a module.
   class DebugInfoFinder {
 
@@ -722,7 +647,7 @@
     bool addType(DIType DT);
 
   public:
-    typedef SmallVector<MDNode *, 8>::iterator iterator;
+    typedef SmallVector<GlobalVariable *, 8>::iterator iterator;
     iterator compile_unit_begin()    { return CUs.begin(); }
     iterator compile_unit_end()      { return CUs.end(); }
     iterator subprogram_begin()      { return SPs.begin(); }
@@ -738,11 +663,12 @@
     unsigned type_count()            { return TYs.size(); }
 
   private:
-    SmallVector<MDNode *, 8> CUs;  // Compile Units
-    SmallVector<MDNode *, 8> SPs;  // Subprograms
-    SmallVector<MDNode *, 8> GVs;  // Global Variables;
-    SmallVector<MDNode *, 8> TYs;  // Types
-    SmallPtrSet<MDNode *, 64> NodesSeen;
+    SmallVector<GlobalVariable *, 8> CUs;  // Compile Units
+    SmallVector<GlobalVariable *, 8> SPs;  // Subprograms
+    SmallVector<GlobalVariable *, 8> GVs;  // Global Variables
+    SmallVector<GlobalVariable *, 8> TYs;  // Types
+    SmallPtrSet<GlobalVariable *, 64> NodesSeen;
+    
   };
 } // end namespace llvm
 

Modified: llvm/branches/Apple/L2/include/llvm/AutoUpgrade.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/AutoUpgrade.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/AutoUpgrade.h (original)
+++ llvm/branches/Apple/L2/include/llvm/AutoUpgrade.h Sun Sep  6 16:39:36 2009
@@ -15,7 +15,6 @@
 #define LLVM_AUTOUPGRADE_H
 
 namespace llvm {
-  class Module;
   class Function;
   class CallInst;
 
@@ -35,9 +34,6 @@
   /// so that it can update all calls to the old function.
   void UpgradeCallsToIntrinsic(Function* F);
 
-  /// This function checks debug info intrinsics. If an intrinsic is invalid
-  /// then this function simply removes the intrinsic. 
-  void CheckDebugInfoIntrinsics(Module *M);
 } // End llvm namespace
 
 #endif

Modified: llvm/branches/Apple/L2/include/llvm/CodeGen/DwarfWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/CodeGen/DwarfWriter.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/CodeGen/DwarfWriter.h (original)
+++ llvm/branches/Apple/L2/include/llvm/CodeGen/DwarfWriter.h Sun Sep  6 16:39:36 2009
@@ -33,7 +33,7 @@
 class MachineInstr;
 class Value;
 class Module;
-class MDNode;
+class GlobalVariable;
 class MCAsmInfo;
 class raw_ostream;
 class Instruction;
@@ -88,17 +88,17 @@
   unsigned RecordSourceLine(unsigned Line, unsigned Col, DICompileUnit CU);
 
   /// RecordRegionStart - Indicate the start of a region.
-  unsigned RecordRegionStart(MDNode *N);
+  unsigned RecordRegionStart(GlobalVariable *V);
 
   /// RecordRegionEnd - Indicate the end of a region.
-  unsigned RecordRegionEnd(MDNode *N);
+  unsigned RecordRegionEnd(GlobalVariable *V);
 
   /// getRecordSourceLineCount - Count source lines.
   unsigned getRecordSourceLineCount();
 
   /// RecordVariable - Indicate the declaration of  a local variable.
   ///
-  void RecordVariable(MDNode *N, unsigned FrameIndex);
+  void RecordVariable(GlobalVariable *GV, unsigned FrameIndex);
 
   /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
   /// be emitted.

Modified: llvm/branches/Apple/L2/include/llvm/CodeGen/MachineFunction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/CodeGen/MachineFunction.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/CodeGen/MachineFunction.h (original)
+++ llvm/branches/Apple/L2/include/llvm/CodeGen/MachineFunction.h Sun Sep  6 16:39:36 2009
@@ -327,7 +327,7 @@
   /// getOrCreateDebugLocID - Look up the DebugLocTuple index with the given
   /// source file, line, and column. If none currently exists, create a new
   /// DebugLocTuple, and insert it into the DebugIdMap.
-  unsigned getOrCreateDebugLocID(MDNode *CompileUnit,
+  unsigned getOrCreateDebugLocID(GlobalVariable *CompileUnit,
                                  unsigned Line, unsigned Col);
 
   /// getDebugLocTuple - Get the DebugLocTuple for a given DebugLoc object.

Modified: llvm/branches/Apple/L2/include/llvm/CodeGen/SelectionDAG.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/CodeGen/SelectionDAG.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/CodeGen/SelectionDAG.h (original)
+++ llvm/branches/Apple/L2/include/llvm/CodeGen/SelectionDAG.h Sun Sep  6 16:39:36 2009
@@ -322,7 +322,7 @@
   SDValue getValueType(EVT);
   SDValue getRegister(unsigned Reg, EVT VT);
   SDValue getDbgStopPoint(DebugLoc DL, SDValue Root, 
-                          unsigned Line, unsigned Col, MDNode *CU);
+                          unsigned Line, unsigned Col, Value *CU);
   SDValue getLabel(unsigned Opcode, DebugLoc dl, SDValue Root,
                    unsigned LabelID);
 

Modified: llvm/branches/Apple/L2/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/CodeGen/SelectionDAGNodes.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/branches/Apple/L2/include/llvm/CodeGen/SelectionDAGNodes.h Sun Sep  6 16:39:36 2009
@@ -2016,10 +2016,10 @@
   SDUse Chain;
   unsigned Line;
   unsigned Column;
-  MDNode *CU;
+  Value *CU;
   friend class SelectionDAG;
   DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c,
-                     MDNode *cu)
+                     Value *cu)
     : SDNode(ISD::DBG_STOPPOINT, DebugLoc::getUnknownLoc(),
       getSDVTList(MVT::Other)), Line(l), Column(c), CU(cu) {
     InitOperands(&Chain, ch);
@@ -2027,7 +2027,7 @@
 public:
   unsigned getLine() const { return Line; }
   unsigned getColumn() const { return Column; }
-  MDNode *getCompileUnit() const { return CU; }
+  Value *getCompileUnit() const { return CU; }
 
   static bool classof(const DbgStopPointSDNode *) { return true; }
   static bool classof(const SDNode *N) {

Modified: llvm/branches/Apple/L2/include/llvm/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/Constants.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/Constants.h (original)
+++ llvm/branches/Apple/L2/include/llvm/Constants.h Sun Sep  6 16:39:36 2009
@@ -38,7 +38,7 @@
 template<class ConstantClass, class TypeClass, class ValType>
 struct ConstantCreator;
 template<class ConstantClass, class TypeClass>
-struct ConvertConstantType;
+struct ConvertConstant;
 
 //===----------------------------------------------------------------------===//
 /// This is the shared class of boolean and integer constants. This class 
@@ -559,7 +559,7 @@
 class ConstantExpr : public Constant {
   friend struct ConstantCreator<ConstantExpr,Type,
                             std::pair<unsigned, std::vector<Constant*> > >;
-  friend struct ConvertConstantType<ConstantExpr, Type>;
+  friend struct ConvertConstant<ConstantExpr, Type>;
 
 protected:
   ConstantExpr(const Type *ty, unsigned Opcode, Use *Ops, unsigned NumOps)

Modified: llvm/branches/Apple/L2/include/llvm/IntrinsicInst.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/IntrinsicInst.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/IntrinsicInst.h (original)
+++ llvm/branches/Apple/L2/include/llvm/IntrinsicInst.h Sun Sep  6 16:39:36 2009
@@ -25,7 +25,6 @@
 #define LLVM_INTRINSICINST_H
 
 #include "llvm/Constants.h"
-#include "llvm/Metadata.h"
 #include "llvm/Function.h"
 #include "llvm/Instructions.h"
 #include "llvm/Intrinsics.h"
@@ -86,8 +85,8 @@
   struct DbgStopPointInst : public DbgInfoIntrinsic {
     Value *getLineValue() const { return const_cast<Value*>(getOperand(1)); }
     Value *getColumnValue() const { return const_cast<Value*>(getOperand(2)); }
-    MDNode *getContext() const {
-      return cast<MDNode>(getOperand(3));
+    Value *getContext() const {
+      return StripCast(getOperand(3));
     }
 
     unsigned getLine() const {
@@ -113,7 +112,7 @@
   /// DbgFuncStartInst - This represents the llvm.dbg.func.start instruction.
   ///
   struct DbgFuncStartInst : public DbgInfoIntrinsic {
-    MDNode *getSubprogram() const { return cast<MDNode>(getOperand(1)); }
+    Value *getSubprogram() const { return StripCast(getOperand(1)); }
 
     // Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const DbgFuncStartInst *) { return true; }
@@ -128,7 +127,7 @@
   /// DbgRegionStartInst - This represents the llvm.dbg.region.start
   /// instruction.
   struct DbgRegionStartInst : public DbgInfoIntrinsic {
-    MDNode *getContext() const { return cast<MDNode>(getOperand(1)); }
+    Value *getContext() const { return StripCast(getOperand(1)); }
 
     // Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const DbgRegionStartInst *) { return true; }
@@ -143,7 +142,7 @@
   /// DbgRegionEndInst - This represents the llvm.dbg.region.end instruction.
   ///
   struct DbgRegionEndInst : public DbgInfoIntrinsic {
-    MDNode *getContext() const { return cast<MDNode>(getOperand(1)); }
+    Value *getContext() const { return StripCast(getOperand(1)); }
 
     // Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const DbgRegionEndInst *) { return true; }
@@ -159,7 +158,7 @@
   ///
   struct DbgDeclareInst : public DbgInfoIntrinsic {
     Value *getAddress()  const { return getOperand(1); }
-    MDNode *getVariable() const { return cast<MDNode>(getOperand(2)); }
+    Value *getVariable() const { return StripCast(getOperand(2)); }
 
     // Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const DbgDeclareInst *) { return true; }

Modified: llvm/branches/Apple/L2/include/llvm/Intrinsics.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/Intrinsics.td?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/Intrinsics.td (original)
+++ llvm/branches/Apple/L2/include/llvm/Intrinsics.td Sun Sep  6 16:39:36 2009
@@ -110,7 +110,6 @@
 def llvm_anyptr_ty     : LLVMAnyPointerType<llvm_i8_ty>;          // (space)i8*
 def llvm_empty_ty      : LLVMType<OtherVT>;                       // { }
 def llvm_descriptor_ty : LLVMPointerType<llvm_empty_ty>;          // { }*
-def llvm_metadata_ty   : LLVMType<MetadataVT>;                    // !{...}
 
 def llvm_v2i8_ty       : LLVMType<v2i8>;     //  2 x i8
 def llvm_v4i8_ty       : LLVMType<v4i8>;     //  4 x i8
@@ -279,12 +278,12 @@
 let Properties = [IntrNoMem] in {
   def int_dbg_stoppoint    : Intrinsic<[llvm_void_ty],
                                        [llvm_i32_ty, llvm_i32_ty,
-                                        llvm_metadata_ty]>;
-  def int_dbg_region_start : Intrinsic<[llvm_void_ty], [llvm_metadata_ty]>;
-  def int_dbg_region_end   : Intrinsic<[llvm_void_ty], [llvm_metadata_ty]>;
-  def int_dbg_func_start   : Intrinsic<[llvm_void_ty], [llvm_metadata_ty]>;
+                                        llvm_descriptor_ty]>;
+  def int_dbg_region_start : Intrinsic<[llvm_void_ty], [llvm_descriptor_ty]>;
+  def int_dbg_region_end   : Intrinsic<[llvm_void_ty], [llvm_descriptor_ty]>;
+  def int_dbg_func_start   : Intrinsic<[llvm_void_ty], [llvm_descriptor_ty]>;
   def int_dbg_declare      : Intrinsic<[llvm_void_ty],
-                                       [llvm_descriptor_ty, llvm_metadata_ty]>;
+                                       [llvm_descriptor_ty, llvm_descriptor_ty]>;
 }
 
 //===------------------ Exception Handling Intrinsics----------------------===//

Modified: llvm/branches/Apple/L2/include/llvm/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/Metadata.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/Metadata.h (original)
+++ llvm/branches/Apple/L2/include/llvm/Metadata.h Sun Sep  6 16:39:36 2009
@@ -19,9 +19,7 @@
 #include "llvm/User.h"
 #include "llvm/Type.h"
 #include "llvm/OperandTraits.h"
-#include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/ilist_node.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ValueHandle.h"
@@ -29,6 +27,8 @@
 namespace llvm {
 class Constant;
 class LLVMContext;
+template<class ConstantClass, class TypeClass, class ValType>
+struct ConstantCreator;
 
 //===----------------------------------------------------------------------===//
 // MetadataBase  - A base class for MDNode, MDString and NamedMDNode.
@@ -103,32 +103,15 @@
 /// MDNode - a tuple of other values.
 /// These contain a list of the values that represent the metadata. 
 /// MDNode is always unnamed.
-class MDNode : public MetadataBase, public FoldingSetNode {
+class MDNode : public MetadataBase {
   MDNode(const MDNode &);                // DO NOT IMPLEMENT
   void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   // getNumOperands - Make this only available for private uses.
   unsigned getNumOperands() { return User::getNumOperands();  }
 
-  friend class ElementVH;
-  // Use CallbackVH to hold MDNOde elements.
-  struct ElementVH : public CallbackVH {
-    MDNode *Parent;
-    ElementVH(Value *V, MDNode *P) : CallbackVH(V), Parent(P) {}
-    ~ElementVH() {}
-
-    virtual void deleted() {
-      Parent->replaceElement(this->operator Value*(), 0);
-    }
-
-    virtual void allUsesReplacedWith(Value *NV) {
-      Parent->replaceElement(this->operator Value*(), NV);
-    }
-  };
-  // Replace each instance of F from the element list of this node with T.
-  void replaceElement(Value *F, Value *T);
-
-  SmallVector<ElementVH, 4> Node;
-
+  SmallVector<WeakVH, 4> Node;
+  
+  friend struct ConstantCreator<MDNode, Type, std::vector<Value*> >;
 protected:
   explicit MDNode(LLVMContext &C, Value*const* Vals, unsigned NumVals);
 public:
@@ -158,8 +141,8 @@
   }
 
   // Element access
-  typedef SmallVectorImpl<ElementVH>::const_iterator const_elem_iterator;
-  typedef SmallVectorImpl<ElementVH>::iterator elem_iterator;
+  typedef SmallVectorImpl<WeakVH>::const_iterator const_elem_iterator;
+  typedef SmallVectorImpl<WeakVH>::iterator elem_iterator;
   /// elem_empty - Return true if MDNode is empty.
   bool elem_empty() const                { return Node.empty(); }
   const_elem_iterator elem_begin() const { return Node.begin(); }
@@ -174,10 +157,6 @@
     return false;
   }
 
-  /// Profile - calculate a unique identifier for this MDNode to collapse
-  /// duplicates
-  void Profile(FoldingSetNodeID &ID) const;
-
   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) {
     llvm_unreachable("This should never be called because MDNodes have no ops");
   }

Modified: llvm/branches/Apple/L2/include/llvm/Support/DebugLoc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/include/llvm/Support/DebugLoc.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/include/llvm/Support/DebugLoc.h (original)
+++ llvm/branches/Apple/L2/include/llvm/Support/DebugLoc.h Sun Sep  6 16:39:36 2009
@@ -19,19 +19,19 @@
 #include <vector>
 
 namespace llvm {
-  class MDNode;
+  class GlobalVariable;
 
   /// DebugLocTuple - Debug location tuple of filename id, line and column.
   ///
   struct DebugLocTuple {
-    MDNode *CompileUnit;
+    GlobalVariable *CompileUnit;
     unsigned Line, Col;
 
     DebugLocTuple()
       : CompileUnit(0), Line(~0U), Col(~0U) {};
 
-    DebugLocTuple(MDNode *n, unsigned l, unsigned c)
-      : CompileUnit(n), Line(l), Col(c) {};
+    DebugLocTuple(GlobalVariable *v, unsigned l, unsigned c)
+      : CompileUnit(v), Line(l), Col(c) {};
 
     bool operator==(const DebugLocTuple &DLT) const {
       return CompileUnit == DLT.CompileUnit &&
@@ -69,10 +69,10 @@
       return DebugLocTuple(0, ~0U, ~0U);
     }
     static inline DebugLocTuple getTombstoneKey() {
-      return DebugLocTuple((MDNode*)~1U, ~1U, ~1U);
+      return DebugLocTuple((GlobalVariable*)~1U, ~1U, ~1U);
     }
     static unsigned getHashValue(const DebugLocTuple &Val) {
-      return DenseMapInfo<MDNode*>::getHashValue(Val.CompileUnit) ^
+      return DenseMapInfo<GlobalVariable*>::getHashValue(Val.CompileUnit) ^
              DenseMapInfo<unsigned>::getHashValue(Val.Line) ^
              DenseMapInfo<unsigned>::getHashValue(Val.Col);
     }

Modified: llvm/branches/Apple/L2/lib/Analysis/DbgInfoPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Analysis/DbgInfoPrinter.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Analysis/DbgInfoPrinter.cpp (original)
+++ llvm/branches/Apple/L2/lib/Analysis/DbgInfoPrinter.cpp Sun Sep  6 16:39:36 2009
@@ -90,7 +90,7 @@
 }
 
 void PrintDbgInfo::printFuncStart(const DbgFuncStartInst *FS) {
-  DISubprogram Subprogram(FS->getSubprogram());
+  DISubprogram Subprogram(cast<GlobalVariable>(FS->getSubprogram()));
   std::string Res1, Res2;
   Out << "; fully qualified function name: " << Subprogram.getDisplayName(Res1)
       << " return type: " << Subprogram.getReturnTypeName(Res2)

Modified: llvm/branches/Apple/L2/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Analysis/DebugInfo.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/branches/Apple/L2/lib/Analysis/DebugInfo.cpp Sun Sep  6 16:39:36 2009
@@ -21,7 +21,6 @@
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
 #include "llvm/Analysis/ValueTracking.h"
-#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/DebugLoc.h"
 #include "llvm/Support/raw_ostream.h"
@@ -33,12 +32,18 @@
 //===----------------------------------------------------------------------===//
 
 /// ValidDebugInfo - Return true if V represents valid debug info value.
-/// FIXME : Add DIDescriptor.isValid()
-bool DIDescriptor::ValidDebugInfo(MDNode *N, CodeGenOpt::Level OptLevel) {
-  if (!N)
+bool DIDescriptor::ValidDebugInfo(Value *V, CodeGenOpt::Level OptLevel) {
+  if (!V)
     return false;
 
-  DIDescriptor DI(N);
+  GlobalVariable *GV = dyn_cast<GlobalVariable>(V->stripPointerCasts());
+  if (!GV)
+    return false;
+
+  if (!GV->hasInternalLinkage () && !GV->hasLinkOnceLinkage())
+    return false;
+
+  DIDescriptor DI(GV);
 
   // Check current version. Allow Version6 for now.
   unsigned Version = DI.getVersion();
@@ -48,13 +53,13 @@
   unsigned Tag = DI.getTag();
   switch (Tag) {
   case DW_TAG_variable:
-    assert(DIVariable(N).Verify() && "Invalid DebugInfo value");
+    assert(DIVariable(GV).Verify() && "Invalid DebugInfo value");
     break;
   case DW_TAG_compile_unit:
-    assert(DICompileUnit(N).Verify() && "Invalid DebugInfo value");
+    assert(DICompileUnit(GV).Verify() && "Invalid DebugInfo value");
     break;
   case DW_TAG_subprogram:
-    assert(DISubprogram(N).Verify() && "Invalid DebugInfo value");
+    assert(DISubprogram(GV).Verify() && "Invalid DebugInfo value");
     break;
   case DW_TAG_lexical_block:
     // FIXME: This interfers with the quality of generated code during
@@ -69,78 +74,85 @@
   return true;
 }
 
-DIDescriptor::DIDescriptor(MDNode *N, unsigned RequiredTag) {
-  DbgNode = N;
+DIDescriptor::DIDescriptor(GlobalVariable *GV, unsigned RequiredTag) {
+  DbgGV = GV;
   
   // If this is non-null, check to see if the Tag matches. If not, set to null.
-  if (N && getTag() != RequiredTag) {
-    DbgNode = 0;
-  }
+  if (GV && getTag() != RequiredTag)
+    DbgGV = 0;
 }
 
 const std::string &
 DIDescriptor::getStringField(unsigned Elt, std::string &Result) const {
-  Result.clear();
-  if (DbgNode == 0)
+  if (DbgGV == 0) {
+    Result.clear();
     return Result;
+  }
+
+  Constant *C = DbgGV->getInitializer();
+  if (C == 0 || Elt >= C->getNumOperands()) {
+    Result.clear();
+    return Result;
+  }
+
+  // Fills in the string if it succeeds
+  if (!GetConstantStringInfo(C->getOperand(Elt), Result))
+    Result.clear();
 
-  if (Elt < DbgNode->getNumElements()) 
-    if (MDString *MDS = dyn_cast_or_null<MDString>(DbgNode->getElement(Elt))) {
-      Result.assign(MDS->begin(), MDS->begin() + MDS->length());
-      return Result;
-    }
-  
   return Result;
 }
 
 uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const {
-  if (DbgNode == 0) 
+  if (DbgGV == 0) return 0;
+  if (!DbgGV->hasInitializer()) return 0;
+
+  Constant *C = DbgGV->getInitializer();
+  if (C == 0 || Elt >= C->getNumOperands())
     return 0;
 
-  if (Elt < DbgNode->getNumElements())
-    if (ConstantInt *CI = dyn_cast<ConstantInt>(DbgNode->getElement(Elt)))
-      return CI->getZExtValue();
-  
+  if (ConstantInt *CI = dyn_cast<ConstantInt>(C->getOperand(Elt)))
+    return CI->getZExtValue();
   return 0;
 }
 
 DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const {
-  if (DbgNode == 0) 
-    return DIDescriptor();
+  if (DbgGV == 0) return DIDescriptor();
 
-  if (Elt < DbgNode->getNumElements() && DbgNode->getElement(Elt))
-    return DIDescriptor(dyn_cast<MDNode>(DbgNode->getElement(Elt)));
+  Constant *C = DbgGV->getInitializer();
+  if (C == 0 || Elt >= C->getNumOperands())
+    return DIDescriptor();
 
-  return DIDescriptor();
+  C = C->getOperand(Elt);
+  return DIDescriptor(dyn_cast<GlobalVariable>(C->stripPointerCasts()));
 }
 
 GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) const {
-  if (DbgNode == 0) 
+  if (DbgGV == 0) return 0;
+
+  Constant *C = DbgGV->getInitializer();
+  if (C == 0 || Elt >= C->getNumOperands())
     return 0;
 
-  if (Elt < DbgNode->getNumElements())
-      return dyn_cast<GlobalVariable>(DbgNode->getElement(Elt));
-  return 0;
+  C = C->getOperand(Elt);
+  return dyn_cast<GlobalVariable>(C->stripPointerCasts());
 }
 
 //===----------------------------------------------------------------------===//
-// Predicates
+// Simple Descriptor Constructors and other Methods
 //===----------------------------------------------------------------------===//
 
-/// isBasicType - Return true if the specified tag is legal for
-/// DIBasicType.
-bool DIDescriptor::isBasicType() const {
-  assert (!isNull() && "Invalid descriptor!");
-  unsigned Tag = getTag();
-  
-  return Tag == dwarf::DW_TAG_base_type;
+// Needed by DIVariable::getType().
+DIType::DIType(GlobalVariable *GV) : DIDescriptor(GV) {
+  if (!GV) return;
+  unsigned tag = getTag();
+  if (tag != dwarf::DW_TAG_base_type && !DIDerivedType::isDerivedType(tag) &&
+      !DICompositeType::isCompositeType(tag))
+    DbgGV = 0;
 }
 
-/// isDerivedType - Return true if the specified tag is legal for DIDerivedType.
-bool DIDescriptor::isDerivedType() const {
-  assert (!isNull() && "Invalid descriptor!");
-  unsigned Tag = getTag();
-
+/// isDerivedType - Return true if the specified tag is legal for
+/// DIDerivedType.
+bool DIType::isDerivedType(unsigned Tag) {
   switch (Tag) {
   case dwarf::DW_TAG_typedef:
   case dwarf::DW_TAG_pointer_type:
@@ -152,18 +164,16 @@
   case dwarf::DW_TAG_inheritance:
     return true;
   default:
-    // CompositeTypes are currently modelled as DerivedTypes.
-    return isCompositeType();
+    // FIXME: Even though it doesn't make sense, CompositeTypes are current
+    // modelled as DerivedTypes, this should return true for them as well.
+    return false;
   }
 }
 
 /// isCompositeType - Return true if the specified tag is legal for
 /// DICompositeType.
-bool DIDescriptor::isCompositeType() const {
-  assert (!isNull() && "Invalid descriptor!");
-  unsigned Tag = getTag();
-
-  switch (Tag) {
+bool DIType::isCompositeType(unsigned TAG) {
+  switch (TAG) {
   case dwarf::DW_TAG_array_type:
   case dwarf::DW_TAG_structure_type:
   case dwarf::DW_TAG_union_type:
@@ -178,10 +188,7 @@
 }
 
 /// isVariable - Return true if the specified tag is legal for DIVariable.
-bool DIDescriptor::isVariable() const {
-  assert (!isNull() && "Invalid descriptor!");
-  unsigned Tag = getTag();
-
+bool DIVariable::isVariable(unsigned Tag) {
   switch (Tag) {
   case dwarf::DW_TAG_auto_variable:
   case dwarf::DW_TAG_arg_variable:
@@ -192,71 +199,11 @@
   }
 }
 
-/// isSubprogram - Return true if the specified tag is legal for
-/// DISubprogram.
-bool DIDescriptor::isSubprogram() const {
-  assert (!isNull() && "Invalid descriptor!");
-  unsigned Tag = getTag();
-  
-  return Tag == dwarf::DW_TAG_subprogram;
-}
-
-/// isGlobalVariable - Return true if the specified tag is legal for
-/// DIGlobalVariable.
-bool DIDescriptor::isGlobalVariable() const {
-  assert (!isNull() && "Invalid descriptor!");
-  unsigned Tag = getTag();
-
-  return Tag == dwarf::DW_TAG_variable;
-}
-
-/// isScope - Return true if the specified tag is one of the scope 
-/// related tag.
-bool DIDescriptor::isScope() const {
-  assert (!isNull() && "Invalid descriptor!");
-  unsigned Tag = getTag();
-
-  switch (Tag) {
-    case dwarf::DW_TAG_compile_unit:
-    case dwarf::DW_TAG_lexical_block:
-    case dwarf::DW_TAG_subprogram:
-      return true;
-    default:
-      break;
-  }
-  return false;
-}
-
-/// isCompileUnit - Return true if the specified tag is DW_TAG_compile_unit.
-bool DIDescriptor::isCompileUnit() const {
-  assert (!isNull() && "Invalid descriptor!");
-  unsigned Tag = getTag();
-
-  return Tag == dwarf::DW_TAG_compile_unit;
-}
-
-/// isLexicalBlock - Return true if the specified tag is DW_TAG_lexical_block.
-bool DIDescriptor::isLexicalBlock() const {
-  assert (!isNull() && "Invalid descriptor!");
-  unsigned Tag = getTag();
-
-  return Tag == dwarf::DW_TAG_lexical_block;
-}
-
-//===----------------------------------------------------------------------===//
-// Simple Descriptor Constructors and other Methods
-//===----------------------------------------------------------------------===//
-
-DIType::DIType(MDNode *N) : DIDescriptor(N) {
-  if (!N) return;
-  if (!isBasicType() && !isDerivedType() && !isCompositeType()) {
-    DbgNode = 0;
-  }
-}
-
 unsigned DIArray::getNumElements() const {
-  assert (DbgNode && "Invalid DIArray");
-  return DbgNode->getNumElements();
+  assert (DbgGV && "Invalid DIArray");
+  Constant *C = DbgGV->getInitializer();
+  assert (C && "Invalid DIArray initializer");
+  return C->getNumOperands();
 }
 
 /// replaceAllUsesWith - Replace all uses of debug info referenced by
@@ -267,8 +214,8 @@
     return;
 
   assert (!D.isNull() && "Can not replace with null");
-  DbgNode->replaceAllUsesWith(D.getNode());
-  delete DbgNode;
+  getGV()->replaceAllUsesWith(D.getGV());
+  getGV()->eraseFromParent();
 }
 
 /// Verify - Verify that a compile unit is well formed.
@@ -394,8 +341,8 @@
 
 /// dump - Print descriptor.
 void DIDescriptor::dump() const {
-  errs() << "[" << dwarf::TagString(getTag()) << "] ";
-  errs().write_hex((intptr_t)DbgNode) << ']';
+  errs() << "[" << dwarf::TagString(getTag()) << "] [GV:";
+  errs().write_hex((intptr_t)DbgGV) << ']';
 }
 
 /// dump - Print compile unit.
@@ -435,12 +382,12 @@
   if (isForwardDecl())
     errs() << " [fwd] ";
 
-  if (isBasicType())
-    DIBasicType(DbgNode).dump();
-  else if (isDerivedType())
-    DIDerivedType(DbgNode).dump();
-  else if (isCompositeType())
-    DICompositeType(DbgNode).dump();
+  if (isBasicType(Tag))
+    DIBasicType(DbgGV).dump();
+  else if (isDerivedType(Tag))
+    DIDerivedType(DbgGV).dump();
+  else if (isCompositeType(Tag))
+    DICompositeType(DbgGV).dump();
   else {
     errs() << "Invalid DIType\n";
     return;
@@ -486,32 +433,15 @@
   if (isDefinition())
     errs() << " [def] ";
 
-  if (isGlobalVariable())
-    DIGlobalVariable(DbgNode).dump();
+  if (isGlobalVariable(Tag))
+    DIGlobalVariable(DbgGV).dump();
 
   errs() << "\n";
 }
 
 /// dump - Print subprogram.
 void DISubprogram::dump() const {
-  std::string Res;
-  if (!getName(Res).empty())
-    errs() << " [" << Res << "] ";
-
-  unsigned Tag = getTag();
-  errs() << " [" << dwarf::TagString(Tag) << "] ";
-
-  // TODO : Print context
-  getCompileUnit().dump();
-  errs() << " [" << getLineNumber() << "] ";
-
-  if (isLocalToUnit())
-    errs() << " [local] ";
-
-  if (isDefinition())
-    errs() << " [def] ";
-
-  errs() << "\n";
+  DIGlobal::dump();
 }
 
 /// dump - Print global variable.
@@ -544,12 +474,43 @@
   EmptyStructPtr = PointerType::getUnqual(StructType::get(VMContext));
 }
 
+/// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'.
+/// This is only valid when the descriptor is non-null.
+Constant *DIFactory::getCastToEmpty(DIDescriptor D) {
+  if (D.isNull()) return llvm::Constant::getNullValue(EmptyStructPtr);
+  return ConstantExpr::getBitCast(D.getGV(), EmptyStructPtr);
+}
+
 Constant *DIFactory::GetTagConstant(unsigned TAG) {
   assert((TAG & LLVMDebugVersionMask) == 0 &&
          "Tag too large for debug encoding!");
   return ConstantInt::get(Type::getInt32Ty(VMContext), TAG | LLVMDebugVersion);
 }
 
+Constant *DIFactory::GetStringConstant(const std::string &String) {
+  // Check string cache for previous edition.
+  Constant *&Slot = StringCache[String];
+  
+  // Return Constant if previously defined.
+  if (Slot) return Slot;
+  
+  const PointerType *DestTy = PointerType::getUnqual(Type::getInt8Ty(VMContext));
+  
+  // If empty string then use a i8* null instead.
+  if (String.empty())
+    return Slot = ConstantPointerNull::get(DestTy);
+
+  // Construct string as an llvm constant.
+  Constant *ConstStr = ConstantArray::get(VMContext, String);
+    
+  // Otherwise create and return a new string global.
+  GlobalVariable *StrGV = new GlobalVariable(M, ConstStr->getType(), true,
+                                             GlobalVariable::InternalLinkage,
+                                             ConstStr, ".str");
+  StrGV->setSection("llvm.metadata");
+  return Slot = ConstantExpr::getBitCast(StrGV, DestTy);
+}
+
 //===----------------------------------------------------------------------===//
 // DIFactory: Primary Constructors
 //===----------------------------------------------------------------------===//
@@ -557,27 +518,50 @@
 /// GetOrCreateArray - Create an descriptor for an array of descriptors. 
 /// This implicitly uniques the arrays created.
 DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) {
-  SmallVector<Value*, 16> Elts;
+  SmallVector<Constant*, 16> Elts;
   
-  if (NumTys == 0)
-    Elts.push_back(llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)));
-  else
-    for (unsigned i = 0; i != NumTys; ++i)
-      Elts.push_back(Tys[i].getNode());
-
-  return DIArray(MDNode::get(VMContext,Elts.data(), Elts.size()));
+  for (unsigned i = 0; i != NumTys; ++i)
+    Elts.push_back(getCastToEmpty(Tys[i]));
+  
+  Constant *Init = ConstantArray::get(ArrayType::get(EmptyStructPtr,
+                                                     Elts.size()),
+                                      Elts.data(), Elts.size());
+  // If we already have this array, just return the uniqued version.
+  DIDescriptor &Entry = SimpleConstantCache[Init];
+  if (!Entry.isNull()) return DIArray(Entry.getGV());
+
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::InternalLinkage,
+                                          Init, "llvm.dbg.array");
+  GV->setSection("llvm.metadata");
+  Entry = DIDescriptor(GV);
+  return DIArray(GV);
 }
 
 /// GetOrCreateSubrange - Create a descriptor for a value range.  This
 /// implicitly uniques the values returned.
 DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) {
-  Value *Elts[] = {
+  Constant *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_subrange_type),
     ConstantInt::get(Type::getInt64Ty(VMContext), Lo),
     ConstantInt::get(Type::getInt64Ty(VMContext), Hi)
   };
   
-  return DISubrange(MDNode::get(VMContext, &Elts[0], 3));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
+
+  // If we already have this range, just return the uniqued version.
+  DIDescriptor &Entry = SimpleConstantCache[Init];
+  if (!Entry.isNull()) return DISubrange(Entry.getGV());
+  
+  M.addTypeName("llvm.dbg.subrange.type", Init->getType());
+
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::InternalLinkage,
+                                          Init, "llvm.dbg.subrange");
+  GV->setSection("llvm.metadata");
+  Entry = DIDescriptor(GV);
+  return DISubrange(GV);
 }
 
 
@@ -592,30 +576,47 @@
                                            bool isOptimized,
                                            const char *Flags,
                                            unsigned RunTimeVer) {
-  Value *Elts[] = {
+  Constant *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_compile_unit),
-    llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
+    llvm::Constant::getNullValue(EmptyStructPtr),
     ConstantInt::get(Type::getInt32Ty(VMContext), LangID),
-    MDString::get(VMContext, Filename),
-    MDString::get(VMContext, Directory),
-    MDString::get(VMContext, Producer),
+    GetStringConstant(Filename),
+    GetStringConstant(Directory),
+    GetStringConstant(Producer),
     ConstantInt::get(Type::getInt1Ty(VMContext), isMain),
     ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
-    MDString::get(VMContext, Flags),
+    GetStringConstant(Flags),
     ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer)
   };
-
-  return DICompileUnit(MDNode::get(VMContext, &Elts[0], 10));
+  
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
+  
+  M.addTypeName("llvm.dbg.compile_unit.type", Init->getType());
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::InternalLinkage,
+                                          Init, "llvm.dbg.compile_unit");
+  GV->setSection("llvm.metadata");
+  return DICompileUnit(GV);
 }
 
 /// CreateEnumerator - Create a single enumerator value.
 DIEnumerator DIFactory::CreateEnumerator(const std::string &Name, uint64_t Val){
-  Value *Elts[] = {
+  Constant *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_enumerator),
-    MDString::get(VMContext, Name),
+    GetStringConstant(Name),
     ConstantInt::get(Type::getInt64Ty(VMContext), Val)
   };
-  return DIEnumerator(MDNode::get(VMContext, &Elts[0], 3));
+  
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
+  
+  M.addTypeName("llvm.dbg.enumerator.type", Init->getType());
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::InternalLinkage,
+                                          Init, "llvm.dbg.enumerator");
+  GV->setSection("llvm.metadata");
+  return DIEnumerator(GV);
 }
 
 
@@ -628,11 +629,11 @@
                                        uint64_t AlignInBits,
                                        uint64_t OffsetInBits, unsigned Flags,
                                        unsigned Encoding) {
-  Value *Elts[] = {
+  Constant *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_base_type),
-    Context.getNode(),
-    MDString::get(VMContext, Name),
-    CompileUnit.getNode(),
+    getCastToEmpty(Context),
+    GetStringConstant(Name),
+    getCastToEmpty(CompileUnit),
     ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
     ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
     ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
@@ -640,7 +641,16 @@
     ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
     ConstantInt::get(Type::getInt32Ty(VMContext), Encoding)
   };
-  return DIBasicType(MDNode::get(VMContext, &Elts[0], 10));
+  
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
+  
+  M.addTypeName("llvm.dbg.basictype.type", Init->getType());
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::InternalLinkage,
+                                          Init, "llvm.dbg.basictype");
+  GV->setSection("llvm.metadata");
+  return DIBasicType(GV);
 }
 
 /// CreateDerivedType - Create a derived type like const qualified type,
@@ -655,19 +665,28 @@
                                            uint64_t OffsetInBits,
                                            unsigned Flags,
                                            DIType DerivedFrom) {
-  Value *Elts[] = {
+  Constant *Elts[] = {
     GetTagConstant(Tag),
-    Context.getNode(),
-    MDString::get(VMContext, Name),
-    CompileUnit.getNode(),
+    getCastToEmpty(Context),
+    GetStringConstant(Name),
+    getCastToEmpty(CompileUnit),
     ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
     ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
     ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
     ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
     ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
-    DerivedFrom.getNode(),
+    getCastToEmpty(DerivedFrom)
   };
-  return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10));
+  
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
+  
+  M.addTypeName("llvm.dbg.derivedtype.type", Init->getType());
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::InternalLinkage,
+                                          Init, "llvm.dbg.derivedtype");
+  GV->setSection("llvm.metadata");
+  return DIDerivedType(GV);
 }
 
 /// CreateCompositeType - Create a composite type like array, struct, etc.
@@ -684,21 +703,30 @@
                                                DIArray Elements,
                                                unsigned RuntimeLang) {
 
-  Value *Elts[] = {
+  Constant *Elts[] = {
     GetTagConstant(Tag),
-    Context.getNode(),
-    MDString::get(VMContext, Name),
-    CompileUnit.getNode(),
+    getCastToEmpty(Context),
+    GetStringConstant(Name),
+    getCastToEmpty(CompileUnit),
     ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
     ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
     ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
     ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
     ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
-    DerivedFrom.getNode(),
-    Elements.getNode(),
+    getCastToEmpty(DerivedFrom),
+    getCastToEmpty(Elements),
     ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang)
   };
-  return DICompositeType(MDNode::get(VMContext, &Elts[0], 12));
+  
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
+  
+  M.addTypeName("llvm.dbg.composite.type", Init->getType());
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::InternalLinkage,
+                                          Init, "llvm.dbg.composite");
+  GV->setSection("llvm.metadata");
+  return DICompositeType(GV);
 }
 
 
@@ -714,20 +742,29 @@
                                          bool isLocalToUnit,
                                          bool isDefinition) {
 
-  Value *Elts[] = {
+  Constant *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_subprogram),
-    llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
-    Context.getNode(),
-    MDString::get(VMContext, Name),
-    MDString::get(VMContext, DisplayName),
-    MDString::get(VMContext, LinkageName),
-    CompileUnit.getNode(),
+    llvm::Constant::getNullValue(EmptyStructPtr),
+    getCastToEmpty(Context),
+    GetStringConstant(Name),
+    GetStringConstant(DisplayName),
+    GetStringConstant(LinkageName),
+    getCastToEmpty(CompileUnit),
     ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
-    Type.getNode(),
+    getCastToEmpty(Type),
     ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
     ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition)
   };
-  return DISubprogram(MDNode::get(VMContext, &Elts[0], 11));
+  
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
+  
+  M.addTypeName("llvm.dbg.subprogram.type", Init->getType());
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::InternalLinkage,
+                                          Init, "llvm.dbg.subprogram");
+  GV->setSection("llvm.metadata");
+  return DISubprogram(GV);
 }
 
 /// CreateGlobalVariable - Create a new descriptor for the specified global.
@@ -738,29 +775,30 @@
                                 DICompileUnit CompileUnit,
                                 unsigned LineNo, DIType Type,bool isLocalToUnit,
                                 bool isDefinition, llvm::GlobalVariable *Val) {
-  Value *Elts[] = { 
+  Constant *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_variable),
-    llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
-    Context.getNode(),
-    MDString::get(VMContext, Name),
-    MDString::get(VMContext, DisplayName),
-    MDString::get(VMContext, LinkageName),
-    CompileUnit.getNode(),
+    llvm::Constant::getNullValue(EmptyStructPtr),
+    getCastToEmpty(Context),
+    GetStringConstant(Name),
+    GetStringConstant(DisplayName),
+    GetStringConstant(LinkageName),
+    getCastToEmpty(CompileUnit),
     ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
-    Type.getNode(),
+    getCastToEmpty(Type),
     ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
     ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
-    Val
+    ConstantExpr::getBitCast(Val, EmptyStructPtr)
   };
-
-  Value *const *Vs = &Elts[0];
-  MDNode *Node = MDNode::get(VMContext,Vs, 12);
-
-  // Create a named metadata so that we do not lose this mdnode.
-  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv");
-  NMD->addElement(Node);
-
-  return DIGlobalVariable(Node);
+  
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
+  
+  M.addTypeName("llvm.dbg.global_variable.type", Init->getType());
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::LinkOnceAnyLinkage,
+                                          Init, "llvm.dbg.global_variable");
+  GV->setSection("llvm.metadata");
+  return DIGlobalVariable(GV);
 }
 
 
@@ -769,38 +807,44 @@
                                      const std::string &Name,
                                      DICompileUnit CompileUnit, unsigned LineNo,
                                      DIType Type) {
-  Value *Elts[] = {
+  Constant *Elts[] = {
     GetTagConstant(Tag),
-    Context.getNode(),
-    MDString::get(VMContext, Name),
-    CompileUnit.getNode(),
+    getCastToEmpty(Context),
+    GetStringConstant(Name),
+    getCastToEmpty(CompileUnit),
     ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
-    Type.getNode(),
+    getCastToEmpty(Type)
   };
-  return DIVariable(MDNode::get(VMContext, &Elts[0], 6));
+  
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
+  
+  M.addTypeName("llvm.dbg.variable.type", Init->getType());
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::InternalLinkage,
+                                          Init, "llvm.dbg.variable");
+  GV->setSection("llvm.metadata");
+  return DIVariable(GV);
 }
 
 
 /// CreateBlock - This creates a descriptor for a lexical block with the
 /// specified parent VMContext.
-DILexicalBlock DIFactory::CreateLexicalBlock(DIDescriptor Context) {
-  Value *Elts[] = {
+DIBlock DIFactory::CreateBlock(DIDescriptor Context) {
+  Constant *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_lexical_block),
-    Context.getNode()
-  };
-  return DILexicalBlock(MDNode::get(VMContext, &Elts[0], 2));
-}
-
-/// CreateLocation - Creates a debug info location.
-DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo, 
-				     DIScope S, DILocation OrigLoc) {
-  Value *Elts[] = {
-    ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
-    ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo),
-    S.getNode(),
-    OrigLoc.getNode(),
+    getCastToEmpty(Context)
   };
-  return DILocation(MDNode::get(VMContext, &Elts[0], 4));
+  
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
+  
+  M.addTypeName("llvm.dbg.block.type", Init->getType());
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
+                                          GlobalValue::InternalLinkage,
+                                          Init, "llvm.dbg.block");
+  GV->setSection("llvm.metadata");
+  return DIBlock(GV);
 }
 
 
@@ -822,7 +866,7 @@
   Value *Args[] = {
     ConstantInt::get(llvm::Type::getInt32Ty(VMContext), LineNo),
     ConstantInt::get(llvm::Type::getInt32Ty(VMContext), ColNo),
-    CU.getNode()
+    getCastToEmpty(CU)
   };
   CallInst::Create(StopPointFn, Args, Args+3, "", BB);
 }
@@ -835,7 +879,7 @@
     FuncStartFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_func_start);
   
   // Call llvm.dbg.func.start which also implicitly sets a stoppoint.
-  CallInst::Create(FuncStartFn, SP.getNode(), "", BB);
+  CallInst::Create(FuncStartFn, getCastToEmpty(SP), "", BB);
 }
 
 /// InsertRegionStart - Insert a new llvm.dbg.region.start intrinsic call to
@@ -846,7 +890,7 @@
     RegionStartFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_region_start);
 
   // Call llvm.dbg.func.start.
-  CallInst::Create(RegionStartFn, D.getNode(), "", BB);
+  CallInst::Create(RegionStartFn, getCastToEmpty(D), "", BB);
 }
 
 /// InsertRegionEnd - Insert a new llvm.dbg.region.end intrinsic call to
@@ -857,7 +901,7 @@
     RegionEndFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_region_end);
 
   // Call llvm.dbg.region.end.
-  CallInst::Create(RegionEndFn, D.getNode(), "", BB);
+  CallInst::Create(RegionEndFn, getCastToEmpty(D), "", BB);
 }
 
 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
@@ -868,19 +912,17 @@
   if (!DeclareFn)
     DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
 
-  Value *Args[] = { Storage, D.getNode() };
+  Value *Args[] = { Storage, getCastToEmpty(D) };
   CallInst::Create(DeclareFn, Args, Args+2, "", BB);
 }
 
-
 //===----------------------------------------------------------------------===//
 // DebugInfoFinder implementations.
 //===----------------------------------------------------------------------===//
 
 /// processModule - Process entire module and collect debug info.
 void DebugInfoFinder::processModule(Module &M) {
-
-
+  
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
     for (Function::iterator FI = (*I).begin(), FE = (*I).end(); FI != FE; ++FI)
       for (BasicBlock::iterator BI = (*FI).begin(), BE = (*FI).end(); BI != BE;
@@ -896,13 +938,15 @@
         else if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(BI))
           processDeclare(DDI);
       }
-
-  NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.gv");
-  if (!NMD)
-    return;
-
-  for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) {
-    DIGlobalVariable DIG(cast<MDNode>(NMD->getElement(i)));
+  
+  for (Module::global_iterator GVI = M.global_begin(), GVE = M.global_end();
+       GVI != GVE; ++GVI) {
+    GlobalVariable *GV = GVI;
+    if (!GV->hasName() || !GV->isConstant() 
+        || strncmp(GV->getName().data(), "llvm.dbg.global_variable", 24)
+        || !GV->hasInitializer())
+      continue;
+    DIGlobalVariable DIG(GV);
     if (addGlobalVariable(DIG)) {
       addCompileUnit(DIG.getCompileUnit());
       processType(DIG.getType());
@@ -916,21 +960,21 @@
     return;
 
   addCompileUnit(DT.getCompileUnit());
-  if (DT.isCompositeType()) {
-    DICompositeType DCT(DT.getNode());
+  if (DT.isCompositeType(DT.getTag())) {
+    DICompositeType DCT(DT.getGV());
     processType(DCT.getTypeDerivedFrom());
     DIArray DA = DCT.getTypeArray();
     if (!DA.isNull())
       for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) {
         DIDescriptor D = DA.getElement(i);
-        DIType TypeE = DIType(D.getNode());
+        DIType TypeE = DIType(D.getGV());
         if (!TypeE.isNull())
           processType(TypeE);
         else 
-          processSubprogram(DISubprogram(D.getNode()));
+          processSubprogram(DISubprogram(D.getGV()));
       }
-  } else if (DT.isDerivedType()) {
-    DIDerivedType DDT(DT.getNode());
+  } else if (DT.isDerivedType(DT.getTag())) {
+    DIDerivedType DDT(DT.getGV());
     if (!DDT.isNull()) 
       processType(DDT.getTypeDerivedFrom());
   }
@@ -948,35 +992,35 @@
 
 /// processStopPoint - Process DbgStopPointInst.
 void DebugInfoFinder::processStopPoint(DbgStopPointInst *SPI) {
-  MDNode *Context = dyn_cast<MDNode>(SPI->getContext());
+  GlobalVariable *Context = dyn_cast<GlobalVariable>(SPI->getContext());
   addCompileUnit(DICompileUnit(Context));
 }
 
 /// processFuncStart - Process DbgFuncStartInst.
 void DebugInfoFinder::processFuncStart(DbgFuncStartInst *FSI) {
-  MDNode *SP = dyn_cast<MDNode>(FSI->getSubprogram());
+  GlobalVariable *SP = dyn_cast<GlobalVariable>(FSI->getSubprogram());
   processSubprogram(DISubprogram(SP));
 }
 
 /// processRegionStart - Process DbgRegionStart.
 void DebugInfoFinder::processRegionStart(DbgRegionStartInst *DRS) {
-  MDNode *SP = dyn_cast<MDNode>(DRS->getContext());
+  GlobalVariable *SP = dyn_cast<GlobalVariable>(DRS->getContext());
   processSubprogram(DISubprogram(SP));
 }
 
 /// processRegionEnd - Process DbgRegionEnd.
 void DebugInfoFinder::processRegionEnd(DbgRegionEndInst *DRE) {
-  MDNode *SP = dyn_cast<MDNode>(DRE->getContext());
+  GlobalVariable *SP = dyn_cast<GlobalVariable>(DRE->getContext());
   processSubprogram(DISubprogram(SP));
 }
 
 /// processDeclare - Process DbgDeclareInst.
 void DebugInfoFinder::processDeclare(DbgDeclareInst *DDI) {
-  DIVariable DV(cast<MDNode>(DDI->getVariable()));
+  DIVariable DV(cast<GlobalVariable>(DDI->getVariable()));
   if (DV.isNull())
     return;
 
-  if (!NodesSeen.insert(DV.getNode()))
+  if (!NodesSeen.insert(DV.getGV()))
     return;
 
   addCompileUnit(DV.getCompileUnit());
@@ -988,10 +1032,10 @@
   if (DT.isNull())
     return false;
 
-  if (!NodesSeen.insert(DT.getNode()))
+  if (!NodesSeen.insert(DT.getGV()))
     return false;
 
-  TYs.push_back(DT.getNode());
+  TYs.push_back(DT.getGV());
   return true;
 }
 
@@ -1000,10 +1044,10 @@
   if (CU.isNull())
     return false;
 
-  if (!NodesSeen.insert(CU.getNode()))
+  if (!NodesSeen.insert(CU.getGV()))
     return false;
 
-  CUs.push_back(CU.getNode());
+  CUs.push_back(CU.getGV());
   return true;
 }
     
@@ -1012,10 +1056,10 @@
   if (DIG.isNull())
     return false;
 
-  if (!NodesSeen.insert(DIG.getNode()))
+  if (!NodesSeen.insert(DIG.getGV()))
     return false;
 
-  GVs.push_back(DIG.getNode());
+  GVs.push_back(DIG.getGV());
   return true;
 }
 
@@ -1024,10 +1068,10 @@
   if (SP.isNull())
     return false;
   
-  if (!NodesSeen.insert(SP.getNode()))
+  if (!NodesSeen.insert(SP.getGV()))
     return false;
 
-  SPs.push_back(SP.getNode());
+  SPs.push_back(SP.getGV());
   return true;
 }
 
@@ -1080,17 +1124,31 @@
 
   Value *findDbgGlobalDeclare(GlobalVariable *V) {
     const Module *M = V->getParent();
-    NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.gv");
-    if (!NMD)
-      return 0;
     
-    for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) {
-      DIGlobalVariable DIG(cast_or_null<MDNode>(NMD->getElement(i)));
-      if (DIG.isNull())
-        continue;
-      if (DIG.getGlobal() == V)
-        return DIG.getNode();
+    const Type *Ty = M->getTypeByName("llvm.dbg.global_variable.type");
+    if (!Ty) return 0;
+
+    Ty = PointerType::get(Ty, 0);
+
+    Value *Val = V->stripPointerCasts();
+    for (Value::use_iterator I = Val->use_begin(), E = Val->use_end();
+         I != E; ++I) {
+      if (ConstantExpr *CE = dyn_cast<ConstantExpr>(I)) {
+        if (CE->getOpcode() == Instruction::BitCast) {
+          Value *VV = CE;
+
+          while (VV->hasOneUse())
+            VV = *VV->use_begin();
+
+          if (VV->getType() == Ty)
+            return VV;
+        }
+      }
     }
+    
+    if (Val->getType() == Ty)
+      return Val;
+
     return 0;
   }
 
@@ -1127,7 +1185,7 @@
     if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) {
       Value *DIGV = findDbgGlobalDeclare(GV);
       if (!DIGV) return false;
-      DIGlobalVariable Var(cast<MDNode>(DIGV));
+      DIGlobalVariable Var(cast<GlobalVariable>(DIGV));
 
       Var.getDisplayName(DisplayName);
       LineNo = Var.getLineNumber();
@@ -1136,7 +1194,7 @@
     } else {
       const DbgDeclareInst *DDI = findDbgDeclare(V);
       if (!DDI) return false;
-      DIVariable Var(cast<MDNode>(DDI->getVariable()));
+      DIVariable Var(cast<GlobalVariable>(DDI->getVariable()));
 
       Var.getName(DisplayName);
       LineNo = Var.getLineNumber();
@@ -1194,7 +1252,7 @@
     Value *Context = SPI.getContext();
 
     // If this location is already tracked then use it.
-    DebugLocTuple Tuple(cast<MDNode>(Context), SPI.getLine(), 
+    DebugLocTuple Tuple(cast<GlobalVariable>(Context), SPI.getLine(), 
                         SPI.getColumn());
     DenseMap<DebugLocTuple, unsigned>::iterator II
       = DebugLocInfo.DebugIdMap.find(Tuple);
@@ -1216,12 +1274,12 @@
     DebugLoc DL;
     Value *SP = FSI.getSubprogram();
 
-    DISubprogram Subprogram(cast<MDNode>(SP));
+    DISubprogram Subprogram(cast<GlobalVariable>(SP));
     unsigned Line = Subprogram.getLineNumber();
     DICompileUnit CU(Subprogram.getCompileUnit());
 
     // If this location is already tracked then use it.
-    DebugLocTuple Tuple(CU.getNode(), Line, /* Column */ 0);
+    DebugLocTuple Tuple(CU.getGV(), Line, /* Column */ 0);
     DenseMap<DebugLocTuple, unsigned>::iterator II
       = DebugLocInfo.DebugIdMap.find(Tuple);
     if (II != DebugLocInfo.DebugIdMap.end())
@@ -1237,7 +1295,7 @@
 
   /// isInlinedFnStart - Return true if FSI is starting an inlined function.
   bool isInlinedFnStart(DbgFuncStartInst &FSI, const Function *CurrentFn) {
-    DISubprogram Subprogram(cast<MDNode>(FSI.getSubprogram()));
+    DISubprogram Subprogram(cast<GlobalVariable>(FSI.getSubprogram()));
     if (Subprogram.describes(CurrentFn))
       return false;
 
@@ -1246,10 +1304,11 @@
 
   /// isInlinedFnEnd - Return true if REI is ending an inlined function.
   bool isInlinedFnEnd(DbgRegionEndInst &REI, const Function *CurrentFn) {
-    DISubprogram Subprogram(cast<MDNode>(REI.getContext()));
+    DISubprogram Subprogram(cast<GlobalVariable>(REI.getContext()));
     if (Subprogram.isNull() || Subprogram.describes(CurrentFn))
       return false;
 
     return true;
   }
+
 }

Modified: llvm/branches/Apple/L2/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Analysis/ValueTracking.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/branches/Apple/L2/lib/Analysis/ValueTracking.cpp Sun Sep  6 16:39:36 2009
@@ -1058,11 +1058,6 @@
                                  StopAtNul);
   }
   
-  if (MDString *MDStr = dyn_cast<MDString>(V)) {
-    Str = MDStr->getString();
-    return true;
-  }
-
   // The GEP instruction, constant or instruction, must reference a global
   // variable that is a constant and is initialized. The referenced constant
   // initializer is the array that we'll use for optimization.

Modified: llvm/branches/Apple/L2/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/AsmParser/LLParser.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/AsmParser/LLParser.cpp (original)
+++ llvm/branches/Apple/L2/lib/AsmParser/LLParser.cpp Sun Sep  6 16:39:36 2009
@@ -98,8 +98,6 @@
   for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; )
     UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
   
-  // Check debug info intrinsics.
-  CheckDebugInfoIntrinsics(M);
   return false;
 }
 

Modified: llvm/branches/Apple/L2/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Bitcode/Reader/BitcodeReader.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/Apple/L2/lib/Bitcode/Reader/BitcodeReader.cpp Sun Sep  6 16:39:36 2009
@@ -16,7 +16,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/InlineAsm.h"
-#include "llvm/IntrinsicInst.h"
+#include "llvm/Instructions.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Metadata.h"
 #include "llvm/Module.h"
@@ -332,9 +332,6 @@
   Value *PrevVal = OldV;
   OldV->replaceAllUsesWith(V);
   delete PrevVal;
-  // Deleting PrevVal sets Idx value in MDValuePtrs to null. Set new
-  // value for Idx.
-  MDValuePtrs[Idx] = V;
 }
 
 Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) {
@@ -2197,10 +2194,7 @@
     }
   }
   std::vector<std::pair<Function*, Function*> >().swap(UpgradedIntrinsics);
-
-  // Check debug info intrinsics.
-  CheckDebugInfoIntrinsics(TheModule);
-
+  
   return TheModule;
 }
 

Modified: llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sun Sep  6 16:39:36 2009
@@ -1781,10 +1781,11 @@
   // Print source line info.
   O.PadToColumn(MAI->getCommentColumn());
   O << MAI->getCommentString() << " SrcLine ";
-  if (DLT.CompileUnit) {
-    std::string Str;
-    DICompileUnit CU(DLT.CompileUnit);
-    O << CU.getFilename(Str) << " ";
+  if (DLT.CompileUnit->hasInitializer()) {
+    Constant *Name = DLT.CompileUnit->getInitializer();
+    if (ConstantArray *NameString = dyn_cast<ConstantArray>(Name))
+      if (NameString->isString())
+        O << NameString->getAsString() << " ";
   }
   O << DLT.Line;
   if (DLT.Col != 0) 
@@ -1802,10 +1803,11 @@
   // Print source line info
   O.PadToColumn(MAI->getCommentColumn());
   O << MAI->getCommentString() << " SrcLine ";
-  if (DLT.CompileUnit) {
-    std::string Str;
-    DICompileUnit CU(DLT.CompileUnit);
-    O << CU.getFilename(Str) << " ";
+  if (DLT.CompileUnit->hasInitializer()) {
+    Constant *Name = DLT.CompileUnit->getInitializer();
+    if (ConstantArray *NameString = dyn_cast<ConstantArray>(Name))
+      if (NameString->isString())
+        O << NameString->getAsString() << " ";
   }
   O << DLT.Line;
   if (DLT.Col != 0) 

Modified: llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sun Sep  6 16:39:36 2009
@@ -10,7 +10,7 @@
 // This file contains support for writing dwarf debug info into asm files.
 //
 //===----------------------------------------------------------------------===//
-#define DEBUG_TYPE "dwarfdebug"
+
 #include "DwarfDebug.h"
 #include "llvm/Module.h"
 #include "llvm/CodeGen/MachineFunction.h"
@@ -24,7 +24,6 @@
 #include "llvm/Target/TargetRegisterInfo.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Timer.h"
-#include "llvm/Support/Debug.h"
 #include "llvm/System/Path.h"
 using namespace llvm;
 
@@ -57,13 +56,11 @@
 
   /// GVToDieMap - Tracks the mapping of unit level debug informaton
   /// variables to debug information entries.
-  /// FIXME : Rename GVToDieMap -> NodeToDieMap
-  std::map<MDNode *, DIE *> GVToDieMap;
+  std::map<GlobalVariable *, DIE *> GVToDieMap;
 
   /// GVToDIEEntryMap - Tracks the mapping of unit level debug informaton
   /// descriptors to debug information entries using a DIEEntry proxy.
-  /// FIXME : Rename
-  std::map<MDNode *, DIEEntry *> GVToDIEEntryMap;
+  std::map<GlobalVariable *, DIEEntry *> GVToDIEEntryMap;
 
   /// Globals - A map of globally visible named entities for this unit.
   ///
@@ -92,12 +89,12 @@
 
   /// getDieMapSlotFor - Returns the debug information entry map slot for the
   /// specified debug variable.
-  DIE *&getDieMapSlotFor(MDNode *N) { return GVToDieMap[N]; }
+  DIE *&getDieMapSlotFor(GlobalVariable *GV) { return GVToDieMap[GV]; }
 
   /// getDIEEntrySlotFor - Returns the debug information entry proxy slot for
   /// the specified debug variable.
-  DIEEntry *&getDIEEntrySlotFor(MDNode *N) {
-    return GVToDIEEntryMap[N];
+  DIEEntry *&getDIEEntrySlotFor(GlobalVariable *GV) {
+    return GVToDIEEntryMap[GV];
   }
 
   /// AddDie - Adds or interns the DIE to the compile unit.
@@ -242,7 +239,7 @@
   for (unsigned j = 0, M = Values.size(); j < M; ++j)
     delete Values[j];
 
-  for (DenseMap<const MDNode *, DbgScope *>::iterator
+  for (DenseMap<const GlobalVariable *, DbgScope *>::iterator
          I = AbstractInstanceRootMap.begin(),
          E = AbstractInstanceRootMap.end(); I != E;++I)
     delete I->second;
@@ -487,23 +484,6 @@
   AddUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
   AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
 }
-
-/// AddSourceLine - Add location information to specified debug information
-/// entry.
-void DwarfDebug::AddSourceLine(DIE *Die, const DISubprogram *SP) {
-  // If there is no compile unit specified, don't add a line #.
-  if (SP->getCompileUnit().isNull())
-    return;
-
-  unsigned Line = SP->getLineNumber();
-  unsigned FileID = FindCompileUnit(SP->getCompileUnit()).getID();
-  assert(FileID && "Invalid file id");
-  AddUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
-  AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
-}
-
-/// AddSourceLine - Add location information to specified debug information
-/// entry.
 void DwarfDebug::AddSourceLine(DIE *Die, const DIType *Ty) {
   // If there is no compile unit specified, don't add a line #.
   DICompileUnit CU = Ty->getCompileUnit();
@@ -517,238 +497,6 @@
   AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
 }
 
-/* Byref variables, in Blocks, are declared by the programmer as
-   "SomeType VarName;", but the compiler creates a
-   __Block_byref_x_VarName struct, and gives the variable VarName
-   either the struct, or a pointer to the struct, as its type.  This
-   is necessary for various behind-the-scenes things the compiler
-   needs to do with by-reference variables in blocks.
-
-   However, as far as the original *programmer* is concerned, the
-   variable should still have type 'SomeType', as originally declared.
-
-   The following function dives into the __Block_byref_x_VarName
-   struct to find the original type of the variable.  This will be
-   passed back to the code generating the type for the Debug
-   Information Entry for the variable 'VarName'.  'VarName' will then
-   have the original type 'SomeType' in its debug information.
-
-   The original type 'SomeType' will be the type of the field named
-   'VarName' inside the __Block_byref_x_VarName struct.
-
-   NOTE: In order for this to not completely fail on the debugger
-   side, the Debug Information Entry for the variable VarName needs to
-   have a DW_AT_location that tells the debugger how to unwind through
-   the pointers and __Block_byref_x_VarName struct to find the actual
-   value of the variable.  The function AddBlockByrefType does this.  */
-
-/// Find the type the programmer originally declared the variable to be
-/// and return that type.
-///
-DIType DwarfDebug::GetBlockByrefType(DIType Ty, std::string Name) {
-
-  DIType subType = Ty;
-  unsigned tag = Ty.getTag();
-
-  if (tag == dwarf::DW_TAG_pointer_type) {
-    DIDerivedType DTy = DIDerivedType (Ty.getNode());
-    subType = DTy.getTypeDerivedFrom();
-  }
-
-  DICompositeType blockStruct = DICompositeType(subType.getNode());
-
-  DIArray Elements = blockStruct.getTypeArray();
-
-  if (Elements.isNull())
-    return Ty;
-
-  for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
-    DIDescriptor Element = Elements.getElement(i);
-    DIDerivedType DT = DIDerivedType(Element.getNode());
-    std::string Name2;
-    DT.getName(Name2);
-    if (Name == Name2)
-      return (DT.getTypeDerivedFrom());
-  }
-
-  return Ty;
-}
-
-/* Byref variables, in Blocks, are declared by the programmer as "SomeType
-   VarName;", but the compiler creates a __Block_byref_x_VarName struct, and
-   gives the variable VarName either the struct, or a pointer to the struct, as
-   its type.  This is necessary for various behind-the-scenes things the
-   compiler needs to do with by-reference variables in Blocks.
-
-   However, as far as the original *programmer* is concerned, the variable
-   should still have type 'SomeType', as originally declared.
-
-   The function GetBlockByrefType dives into the __Block_byref_x_VarName
-   struct to find the original type of the variable, which is then assigned to
-   the variable's Debug Information Entry as its real type.  So far, so good.
-   However now the debugger will expect the variable VarName to have the type
-   SomeType.  So we need the location attribute for the variable to be an
-   expression that explains to the debugger how to navigate through the 
-   pointers and struct to find the actual variable of type SomeType.
-
-   The following function does just that.  We start by getting
-   the "normal" location for the variable. This will be the location
-   of either the struct __Block_byref_x_VarName or the pointer to the
-   struct __Block_byref_x_VarName.
-
-   The struct will look something like:
-
-   struct __Block_byref_x_VarName {
-     ... <various fields>
-     struct __Block_byref_x_VarName *forwarding;
-     ... <various other fields>
-     SomeType VarName;
-     ... <maybe more fields>
-   };
-
-   If we are given the struct directly (as our starting point) we
-   need to tell the debugger to:
-
-   1).  Add the offset of the forwarding field.
-
-   2).  Follow that pointer to get the the real __Block_byref_x_VarName
-   struct to use (the real one may have been copied onto the heap).
-
-   3).  Add the offset for the field VarName, to find the actual variable.
-
-   If we started with a pointer to the struct, then we need to
-   dereference that pointer first, before the other steps.
-   Translating this into DWARF ops, we will need to append the following
-   to the current location description for the variable:
-
-   DW_OP_deref                    -- optional, if we start with a pointer
-   DW_OP_plus_uconst <forward_fld_offset>
-   DW_OP_deref
-   DW_OP_plus_uconst <varName_fld_offset>
-
-   That is what this function does.  */
-
-/// AddBlockByrefAddress - Start with the address based on the location
-/// provided, and generate the DWARF information necessary to find the
-/// actual Block variable (navigating the Block struct) based on the
-/// starting location.  Add the DWARF information to the die.  For
-/// more information, read large comment just above here.
-///
-void DwarfDebug::AddBlockByrefAddress(DbgVariable *&DV, DIE *Die, 
-                                       unsigned Attribute,
-                                       const MachineLocation &Location) {
-  const DIVariable &VD = DV->getVariable();
-  DIType Ty = VD.getType();
-  DIType TmpTy = Ty;
-  unsigned Tag = Ty.getTag();
-  bool isPointer = false;
-
-  std::string varName;
-  VD.getName(varName);
-
-  if (Tag == dwarf::DW_TAG_pointer_type) {
-    DIDerivedType DTy = DIDerivedType (Ty.getNode());
-    TmpTy = DTy.getTypeDerivedFrom();
-    isPointer = true;
-  }
-
-  DICompositeType blockStruct = DICompositeType(TmpTy.getNode());
-
-  std::string typeName;
-  blockStruct.getName(typeName);
-
-   assert(typeName.find ("__Block_byref_") == 0
-          && "Attempting to get Block location of non-Block variable!");
-
-   // Find the __forwarding field and the variable field in the __Block_byref
-   // struct.
-   
-   DIArray Fields = blockStruct.getTypeArray();
-   DIDescriptor varField = DIDescriptor();
-   DIDescriptor forwardingField = DIDescriptor();
-
-
-   for (unsigned i = 0, N = Fields.getNumElements(); i < N; ++i) {
-     DIDescriptor Element = Fields.getElement(i);
-     DIDerivedType DT = DIDerivedType(Element.getNode());
-     std::string fieldName;
-     DT.getName(fieldName);
-     if (fieldName == "__forwarding")
-       forwardingField = Element;
-     else if (fieldName == varName)
-       varField = Element;
-   }
-     
-   assert (!varField.isNull() && "Can't find byref variable in Block struct");
-   assert (!forwardingField.isNull() 
-           && "Can't find forwarding field in Block struct");
-
-   // Get the offsets for the forwarding field and the variable field.
-
-   unsigned int forwardingFieldOffset = 
-     DIDerivedType(forwardingField.getNode()).getOffsetInBits() >> 3;
-   unsigned int varFieldOffset = 
-     DIDerivedType(varField.getNode()).getOffsetInBits() >> 3;
-
-   // Decode the original location, and use that as the start of the 
-   // byref variable's location.
-
-   unsigned Reg = RI->getDwarfRegNum(Location.getReg(), false);
-   DIEBlock *Block = new DIEBlock();
-
-   if (Location.isReg()) {
-     if (Reg < 32)
-       AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_reg0 + Reg);
-     else {
-       Reg = Reg - dwarf::DW_OP_reg0;
-       AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + Reg);
-       AddUInt(Block, 0, dwarf::DW_FORM_udata, Reg);
-     }
-   } else {
-     if (Reg < 32)
-       AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + Reg);
-     else {
-       AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_bregx);
-       AddUInt(Block, 0, dwarf::DW_FORM_udata, Reg);
-     }
-
-     AddUInt(Block, 0, dwarf::DW_FORM_sdata, Location.getOffset());
-   }
-
-   // If we started with a pointer to the__Block_byref... struct, then
-   // the first thing we need to do is dereference the pointer (DW_OP_deref).
-
-   if (isPointer)
-     AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
-
-   // Next add the offset for the '__forwarding' field:
-   // DW_OP_plus_uconst ForwardingFieldOffset.  Note there's no point in
-   // adding the offset if it's 0.
-
-   if (forwardingFieldOffset > 0) {
-     AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
-     AddUInt(Block, 0, dwarf::DW_FORM_udata, forwardingFieldOffset);
-   }
-
-   // Now dereference the __forwarding field to get to the real __Block_byref
-   // struct:  DW_OP_deref.
-
-   AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
-
-   // Now that we've got the real __Block_byref... struct, add the offset
-   // for the variable's field to get to the location of the actual variable:
-   // DW_OP_plus_uconst varFieldOffset.  Again, don't add if it's 0.
-
-   if (varFieldOffset > 0) {
-     AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
-     AddUInt(Block, 0, dwarf::DW_FORM_udata, varFieldOffset);
-   }
-
-   // Now attach the location information to the DIE.
-
-   AddBlock(Die, Attribute, 0, Block);
-}
-
 /// AddAddress - Add an address attribute to a die based on the location
 /// provided.
 void DwarfDebug::AddAddress(DIE *Die, unsigned Attribute,
@@ -783,7 +531,7 @@
     return;
 
   // Check for pre-existence.
-  DIEEntry *&Slot = DW_Unit->getDIEEntrySlotFor(Ty.getNode());
+  DIEEntry *&Slot = DW_Unit->getDIEEntrySlotFor(Ty.getGV());
 
   // If it exists then use the existing value.
   if (Slot) {
@@ -796,21 +544,20 @@
 
   // Construct type.
   DIE Buffer(dwarf::DW_TAG_base_type);
-  if (Ty.isBasicType())
-    ConstructTypeDIE(DW_Unit, Buffer, DIBasicType(Ty.getNode()));
-  else if (Ty.isCompositeType())
-    ConstructTypeDIE(DW_Unit, Buffer, DICompositeType(Ty.getNode()));
+  if (Ty.isBasicType(Ty.getTag()))
+    ConstructTypeDIE(DW_Unit, Buffer, DIBasicType(Ty.getGV()));
+  else if (Ty.isDerivedType(Ty.getTag()))
+    ConstructTypeDIE(DW_Unit, Buffer, DIDerivedType(Ty.getGV()));
   else {
-    assert(Ty.isDerivedType() && "Unknown kind of DIType");
-    ConstructTypeDIE(DW_Unit, Buffer, DIDerivedType(Ty.getNode()));
-
+    assert(Ty.isCompositeType(Ty.getTag()) && "Unknown kind of DIType");
+    ConstructTypeDIE(DW_Unit, Buffer, DICompositeType(Ty.getGV()));
   }
 
   // Add debug information entry to entity and appropriate context.
   DIE *Die = NULL;
   DIDescriptor Context = Ty.getContext();
   if (!Context.isNull())
-    Die = DW_Unit->getDieMapSlotFor(Context.getNode());
+    Die = DW_Unit->getDieMapSlotFor(Context.getGV());
 
   if (Die) {
     DIE *Child = new DIE(Buffer);
@@ -895,7 +642,7 @@
     // Add enumerators to enumeration type.
     for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
       DIE *ElemDie = NULL;
-      DIEnumerator Enum(Elements.getElement(i).getNode());
+      DIEnumerator Enum(Elements.getElement(i).getGV());
       ElemDie = ConstructEnumTypeDIE(DW_Unit, &Enum);
       Buffer.AddChild(ElemDie);
     }
@@ -905,7 +652,7 @@
     // Add return type.
     DIArray Elements = CTy.getTypeArray();
     DIDescriptor RTy = Elements.getElement(0);
-    AddType(DW_Unit, &Buffer, DIType(RTy.getNode()));
+    AddType(DW_Unit, &Buffer, DIType(RTy.getGV()));
 
     // Add prototype flag.
     AddUInt(&Buffer, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1);
@@ -914,7 +661,7 @@
     for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) {
       DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
       DIDescriptor Ty = Elements.getElement(i);
-      AddType(DW_Unit, Arg, DIType(Ty.getNode()));
+      AddType(DW_Unit, Arg, DIType(Ty.getGV()));
       Buffer.AddChild(Arg);
     }
   }
@@ -932,19 +679,20 @@
     // Add elements to structure type.
     for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
       DIDescriptor Element = Elements.getElement(i);
-      if (Element.isNull())
-        continue;
       DIE *ElemDie = NULL;
       if (Element.getTag() == dwarf::DW_TAG_subprogram)
         ElemDie = CreateSubprogramDIE(DW_Unit,
-                                      DISubprogram(Element.getNode()));
+                                      DISubprogram(Element.getGV()));
       else
         ElemDie = CreateMemberDIE(DW_Unit,
-                                  DIDerivedType(Element.getNode()));
+                                  DIDerivedType(Element.getGV()));
       Buffer.AddChild(ElemDie);
     }
 
-    if (CTy.isAppleBlockExtension())
+    // FIXME: We'd like an API to register additional attributes for the
+    // frontend to use while synthesizing, and then we'd use that api in clang
+    // instead of this.
+    if (Name == "__block_literal_generic")
       AddUInt(&Buffer, dwarf::DW_AT_APPLE_block, dwarf::DW_FORM_flag, 1);
 
     unsigned RLang = CTy.getRunTimeLang();
@@ -1017,7 +765,7 @@
   for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
     DIDescriptor Element = Elements.getElement(i);
     if (Element.getTag() == dwarf::DW_TAG_subrange_type)
-      ConstructSubrangeDIE(Buffer, DISubrange(Element.getNode()), IndexTy);
+      ConstructSubrangeDIE(Buffer, DISubrange(Element.getGV()), IndexTy);
   }
 }
 
@@ -1144,7 +892,7 @@
     if (Args.isNull() || SPTag != dwarf::DW_TAG_subroutine_type)
       AddType(DW_Unit, SPDie, SPTy);
     else
-      AddType(DW_Unit, SPDie, DIType(Args.getElement(0).getNode()));
+      AddType(DW_Unit, SPDie, DIType(Args.getElement(0).getGV()));
   }
 
   if (!SP.isDefinition()) {
@@ -1155,7 +903,7 @@
     if (SPTag == dwarf::DW_TAG_subroutine_type)
       for (unsigned i = 1, N =  Args.getNumElements(); i < N; ++i) {
         DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
-        AddType(DW_Unit, Arg, DIType(Args.getElement(i).getNode()));
+        AddType(DW_Unit, Arg, DIType(Args.getElement(i).getGV()));
         AddUInt(Arg, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1); // ??
         SPDie->AddChild(Arg);
       }
@@ -1165,7 +913,7 @@
     AddUInt(SPDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1);
 
   // DW_TAG_inlined_subroutine may refer to this DIE.
-  DIE *&Slot = DW_Unit->getDieMapSlotFor(SP.getNode());
+  DIE *&Slot = DW_Unit->getDieMapSlotFor(SP.getGV());
   Slot = SPDie;
   return SPDie;
 }
@@ -1174,7 +922,7 @@
 ///
 CompileUnit &DwarfDebug::FindCompileUnit(DICompileUnit Unit) const {
   DenseMap<Value *, CompileUnit *>::const_iterator I =
-    CompileUnitMap.find(Unit.getNode());
+    CompileUnitMap.find(Unit.getGV());
   assert(I != CompileUnitMap.end() && "Missing compile unit.");
   return *I->second;
 }
@@ -1210,10 +958,7 @@
   AddSourceLine(VariableDie, &VD);
 
   // Add variable type.
-  if (VD.isBlockByrefVariable())
-    AddType(Unit, VariableDie, GetBlockByrefType(VD.getType(), Name));
-  else
-    AddType(Unit, VariableDie, VD.getType());
+  AddType(Unit, VariableDie, VD.getType());
 
   // Add variable address.
   if (!DV->isInlinedFnVar()) {
@@ -1222,11 +967,7 @@
     MachineLocation Location;
     Location.set(RI->getFrameRegister(*MF),
                  RI->getFrameIndexOffset(*MF, DV->getFrameIndex()));
-
-    if (VD.isBlockByrefVariable())
-      AddBlockByrefAddress (DV, VariableDie, dwarf::DW_AT_location, Location);
-    else
-      AddAddress(VariableDie, dwarf::DW_AT_location, Location);
+    AddAddress(VariableDie, dwarf::DW_AT_location, Location);
   }
 
   return VariableDie;
@@ -1234,26 +975,26 @@
 
 /// getOrCreateScope - Returns the scope associated with the given descriptor.
 ///
-DbgScope *DwarfDebug::getOrCreateScope(MDNode *N) {
-  DbgScope *&Slot = DbgScopeMap[N];
+DbgScope *DwarfDebug::getOrCreateScope(GlobalVariable *V) {
+  DbgScope *&Slot = DbgScopeMap[V];
   if (Slot) return Slot;
 
   DbgScope *Parent = NULL;
-  DILexicalBlock Block(N);
+  DIBlock Block(V);
 
   // Don't create a new scope if we already created one for an inlined function.
-  DenseMap<const MDNode *, DbgScope *>::iterator
-    II = AbstractInstanceRootMap.find(N);
+  DenseMap<const GlobalVariable *, DbgScope *>::iterator
+    II = AbstractInstanceRootMap.find(V);
   if (II != AbstractInstanceRootMap.end())
     return LexicalScopeStack.back();
 
   if (!Block.isNull()) {
     DIDescriptor ParentDesc = Block.getContext();
     Parent =
-      ParentDesc.isNull() ?  NULL : getOrCreateScope(ParentDesc.getNode());
+      ParentDesc.isNull() ?  NULL : getOrCreateScope(ParentDesc.getGV());
   }
 
-  Slot = new DbgScope(Parent, DIDescriptor(N));
+  Slot = new DbgScope(Parent, DIDescriptor(V));
 
   if (Parent)
     Parent->AddScope(Slot);
@@ -1362,10 +1103,10 @@
     return;
 
   // Get the subprogram debug information entry.
-  DISubprogram SPD(Desc.getNode());
+  DISubprogram SPD(Desc.getGV());
 
   // Get the subprogram die.
-  DIE *SPDie = ModuleCU->getDieMapSlotFor(SPD.getNode());
+  DIE *SPDie = ModuleCU->getDieMapSlotFor(SPD.getGV());
   assert(SPDie && "Missing subprogram descriptor");
 
   if (!AbstractScope) {
@@ -1438,8 +1179,8 @@
   return SrcId;
 }
 
-void DwarfDebug::ConstructCompileUnit(MDNode *N) {
-  DICompileUnit DIUnit(N);
+void DwarfDebug::ConstructCompileUnit(GlobalVariable *GV) {
+  DICompileUnit DIUnit(GV);
   std::string Dir, FN, Prod;
   unsigned ID = GetOrCreateSourceID(DIUnit.getDirectory(Dir),
                                     DIUnit.getFilename(FN));
@@ -1476,19 +1217,19 @@
     ModuleCU = Unit;
   }
 
-  CompileUnitMap[DIUnit.getNode()] = Unit;
+  CompileUnitMap[DIUnit.getGV()] = Unit;
   CompileUnits.push_back(Unit);
 }
 
-void DwarfDebug::ConstructGlobalVariableDIE(MDNode *N) {
-  DIGlobalVariable DI_GV(N);
+void DwarfDebug::ConstructGlobalVariableDIE(GlobalVariable *GV) {
+  DIGlobalVariable DI_GV(GV);
   
   // If debug information is malformed then ignore it.
   if (DI_GV.Verify() == false)
     return;
 
   // Check for pre-existence.
-  DIE *&Slot = ModuleCU->getDieMapSlotFor(DI_GV.getNode());
+  DIE *&Slot = ModuleCU->getDieMapSlotFor(DI_GV.getGV());
   if (Slot)
     return;
 
@@ -1514,11 +1255,11 @@
   return;
 }
 
-void DwarfDebug::ConstructSubprogram(MDNode *N) {
-  DISubprogram SP(N);
+void DwarfDebug::ConstructSubprogram(GlobalVariable *GV) {
+  DISubprogram SP(GV);
 
   // Check for pre-existence.
-  DIE *&Slot = ModuleCU->getDieMapSlotFor(N);
+  DIE *&Slot = ModuleCU->getDieMapSlotFor(GV);
   if (Slot)
     return;
 
@@ -1801,9 +1542,6 @@
 /// correspondence to the source line list.
 unsigned DwarfDebug::RecordSourceLine(unsigned Line, unsigned Col,
                                       DICompileUnit CU) {
-  if (!MMI)
-    return 0;
-
   if (TimePassesIsEnabled)
     DebugTimer->startTimer();
 
@@ -1838,11 +1576,11 @@
 }
 
 /// RecordRegionStart - Indicate the start of a region.
-unsigned DwarfDebug::RecordRegionStart(MDNode *N) {
+unsigned DwarfDebug::RecordRegionStart(GlobalVariable *V) {
   if (TimePassesIsEnabled)
     DebugTimer->startTimer();
 
-  DbgScope *Scope = getOrCreateScope(N);
+  DbgScope *Scope = getOrCreateScope(V);
   unsigned ID = MMI->NextLabelID();
   if (!Scope->getStartLabelID()) Scope->setStartLabelID(ID);
   LexicalScopeStack.push_back(Scope);
@@ -1854,11 +1592,11 @@
 }
 
 /// RecordRegionEnd - Indicate the end of a region.
-unsigned DwarfDebug::RecordRegionEnd(MDNode *N) {
+unsigned DwarfDebug::RecordRegionEnd(GlobalVariable *V) {
   if (TimePassesIsEnabled)
     DebugTimer->startTimer();
 
-  DbgScope *Scope = getOrCreateScope(N);
+  DbgScope *Scope = getOrCreateScope(V);
   unsigned ID = MMI->NextLabelID();
   Scope->setEndLabelID(ID);
   // FIXME : region.end() may not be in the last basic block.
@@ -1875,36 +1613,41 @@
 }
 
 /// RecordVariable - Indicate the declaration of a local variable.
-void DwarfDebug::RecordVariable(MDNode *N, unsigned FrameIndex) {
+void DwarfDebug::RecordVariable(GlobalVariable *GV, unsigned FrameIndex) {
   if (TimePassesIsEnabled)
     DebugTimer->startTimer();
 
-  DIDescriptor Desc(N);
+  DIDescriptor Desc(GV);
   DbgScope *Scope = NULL;
   bool InlinedFnVar = false;
 
-  if (Desc.getTag() == dwarf::DW_TAG_variable)
-    Scope = getOrCreateScope(DIGlobalVariable(N).getContext().getNode());
-  else {
+  if (Desc.getTag() == dwarf::DW_TAG_variable) {
+    // GV is a global variable.
+    DIGlobalVariable DG(GV);
+    Scope = getOrCreateScope(DG.getContext().getGV());
+  } else {
     bool InlinedVar = false;
-    MDNode *Context = DIVariable(N).getContext().getNode();
-    DISubprogram SP(Context);
+    DIVariable DV(GV);
+    GlobalVariable *V = DV.getContext().getGV();
+    DISubprogram SP(V);
     if (!SP.isNull()) {
       // SP is inserted into DbgAbstractScopeMap when inlined function
       // start was recorded by RecordInlineFnStart.
-      DenseMap<MDNode *, DbgScope *>::iterator
-        I = DbgAbstractScopeMap.find(SP.getNode());
+      DenseMap<GlobalVariable *, DbgScope *>::iterator
+        I = DbgAbstractScopeMap.find(SP.getGV());
       if (I != DbgAbstractScopeMap.end()) {
         InlinedVar = true;
         Scope = I->second;
       }
     }
-    if (!InlinedVar) 
-      Scope = getOrCreateScope(Context);
+    if (!InlinedVar) {
+      // GV is a local variable.
+      Scope = getOrCreateScope(V);
+    }
   }
 
   assert(Scope && "Unable to find the variable's scope");
-  DbgVariable *DV = new DbgVariable(DIVariable(N), FrameIndex, InlinedFnVar);
+  DbgVariable *DV = new DbgVariable(DIVariable(GV), FrameIndex, InlinedFnVar);
   Scope->AddVariable(DV);
 
   if (TimePassesIsEnabled)
@@ -1922,17 +1665,17 @@
   if (TimePassesIsEnabled)
     DebugTimer->startTimer();
 
-  MDNode *Node = SP.getNode();
-  DenseMap<const MDNode *, DbgScope *>::iterator
-    II = AbstractInstanceRootMap.find(Node);
+  GlobalVariable *GV = SP.getGV();
+  DenseMap<const GlobalVariable *, DbgScope *>::iterator
+    II = AbstractInstanceRootMap.find(GV);
 
   if (II == AbstractInstanceRootMap.end()) {
     // Create an abstract instance entry for this inlined function if it doesn't
     // already exist.
-    DbgScope *Scope = new DbgScope(NULL, DIDescriptor(Node));
+    DbgScope *Scope = new DbgScope(NULL, DIDescriptor(GV));
 
     // Get the compile unit context.
-    DIE *SPDie = ModuleCU->getDieMapSlotFor(Node);
+    DIE *SPDie = ModuleCU->getDieMapSlotFor(GV);
     if (!SPDie)
       SPDie = CreateSubprogramDIE(ModuleCU, SP, false, true);
 
@@ -1944,18 +1687,18 @@
     AddUInt(SPDie, dwarf::DW_AT_inline, 0, dwarf::DW_INL_declared_not_inlined);
 
     // Keep track of the abstract scope for this function.
-    DbgAbstractScopeMap[Node] = Scope;
+    DbgAbstractScopeMap[GV] = Scope;
 
-    AbstractInstanceRootMap[Node] = Scope;
+    AbstractInstanceRootMap[GV] = Scope;
     AbstractInstanceRootList.push_back(Scope);
   }
 
   // Create a concrete inlined instance for this inlined function.
-  DbgConcreteScope *ConcreteScope = new DbgConcreteScope(DIDescriptor(Node));
+  DbgConcreteScope *ConcreteScope = new DbgConcreteScope(DIDescriptor(GV));
   DIE *ScopeDie = new DIE(dwarf::DW_TAG_inlined_subroutine);
   ScopeDie->setAbstractCompileUnit(ModuleCU);
 
-  DIE *Origin = ModuleCU->getDieMapSlotFor(Node);
+  DIE *Origin = ModuleCU->getDieMapSlotFor(GV);
   AddDIEEntry(ScopeDie, dwarf::DW_AT_abstract_origin,
               dwarf::DW_FORM_ref4, Origin);
   AddUInt(ScopeDie, dwarf::DW_AT_call_file, 0, ModuleCU->getID());
@@ -1969,20 +1712,20 @@
   LexicalScopeStack.back()->AddConcreteInst(ConcreteScope);
 
   // Keep track of the concrete scope that's inlined into this function.
-  DenseMap<MDNode *, SmallVector<DbgScope *, 8> >::iterator
-    SI = DbgConcreteScopeMap.find(Node);
+  DenseMap<GlobalVariable *, SmallVector<DbgScope *, 8> >::iterator
+    SI = DbgConcreteScopeMap.find(GV);
 
   if (SI == DbgConcreteScopeMap.end())
-    DbgConcreteScopeMap[Node].push_back(ConcreteScope);
+    DbgConcreteScopeMap[GV].push_back(ConcreteScope);
   else
     SI->second.push_back(ConcreteScope);
 
   // Track the start label for this inlined function.
-  DenseMap<MDNode *, SmallVector<unsigned, 4> >::iterator
-    I = InlineInfo.find(Node);
+  DenseMap<GlobalVariable *, SmallVector<unsigned, 4> >::iterator
+    I = InlineInfo.find(GV);
 
   if (I == InlineInfo.end())
-    InlineInfo[Node].push_back(LabelID);
+    InlineInfo[GV].push_back(LabelID);
   else
     I->second.push_back(LabelID);
 
@@ -2000,9 +1743,9 @@
   if (TimePassesIsEnabled)
     DebugTimer->startTimer();
 
-  MDNode *Node = SP.getNode();
-  DenseMap<MDNode *, SmallVector<DbgScope *, 8> >::iterator
-    I = DbgConcreteScopeMap.find(Node);
+  GlobalVariable *GV = SP.getGV();
+  DenseMap<GlobalVariable *, SmallVector<DbgScope *, 8> >::iterator
+    I = DbgConcreteScopeMap.find(GV);
 
   if (I == DbgConcreteScopeMap.end()) {
     // FIXME: Can this situation actually happen? And if so, should it?
@@ -2707,11 +2450,11 @@
   Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("Dwarf Version");
   Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)");
 
-  for (DenseMap<MDNode *, SmallVector<unsigned, 4> >::iterator
+  for (DenseMap<GlobalVariable *, SmallVector<unsigned, 4> >::iterator
          I = InlineInfo.begin(), E = InlineInfo.end(); I != E; ++I) {
-    MDNode *Node = I->first;
+    GlobalVariable *GV = I->first;
     SmallVector<unsigned, 4> &Labels = I->second;
-    DISubprogram SP(Node);
+    DISubprogram SP(GV);
     std::string Name;
     std::string LName;
 
@@ -2737,7 +2480,7 @@
 
     for (SmallVector<unsigned, 4>::iterator LI = Labels.begin(),
            LE = Labels.end(); LI != LE; ++LI) {
-      DIE *SP = ModuleCU->getDieMapSlotFor(Node);
+      DIE *SP = ModuleCU->getDieMapSlotFor(GV);
       Asm->EmitInt32(SP->getOffset()); Asm->EOL("DIE offset");
 
       if (TD->getPointerSize() == sizeof(int32_t))

Modified: llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfDebug.h Sun Sep  6 16:39:36 2009
@@ -139,25 +139,25 @@
   DbgScope *FunctionDbgScope;
   
   /// DbgScopeMap - Tracks the scopes in the current function.
-  DenseMap<MDNode *, DbgScope *> DbgScopeMap;
+  DenseMap<GlobalVariable *, DbgScope *> DbgScopeMap;
 
   /// DbgAbstractScopeMap - Tracks abstract instance scopes in the current
   /// function.
-  DenseMap<MDNode *, DbgScope *> DbgAbstractScopeMap;
+  DenseMap<GlobalVariable *, DbgScope *> DbgAbstractScopeMap;
 
   /// DbgConcreteScopeMap - Tracks concrete instance scopes in the current
   /// function.
-  DenseMap<MDNode *,
+  DenseMap<GlobalVariable *,
            SmallVector<DbgScope *, 8> > DbgConcreteScopeMap;
 
   /// InlineInfo - Keep track of inlined functions and their location.  This
   /// information is used to populate debug_inlined section.
-  DenseMap<MDNode *, SmallVector<unsigned, 4> > InlineInfo;
+  DenseMap<GlobalVariable *, SmallVector<unsigned, 4> > InlineInfo;
 
   /// AbstractInstanceRootMap - Map of abstract instance roots of inlined
   /// functions. These are subroutine entries that contain a DW_AT_inline
   /// attribute.
-  DenseMap<const MDNode *, DbgScope *> AbstractInstanceRootMap;
+  DenseMap<const GlobalVariable *, DbgScope *> AbstractInstanceRootMap;
 
   /// AbstractInstanceRootList - List of abstract instance roots of inlined
   /// functions. These are subroutine entries that contain a DW_AT_inline
@@ -275,8 +275,11 @@
   /// AddSourceLine - Add location information to specified debug information
   /// entry.
   void AddSourceLine(DIE *Die, const DIVariable *V);
+
+  /// AddSourceLine - Add location information to specified debug information
+  /// entry.
   void AddSourceLine(DIE *Die, const DIGlobal *G);
-  void AddSourceLine(DIE *Die, const DISubprogram *SP);
+
   void AddSourceLine(DIE *Die, const DIType *Ty);
 
   /// AddAddress - Add an address attribute to a die based on the location
@@ -284,14 +287,6 @@
   void AddAddress(DIE *Die, unsigned Attribute,
                   const MachineLocation &Location);
 
-  /// AddBlockByrefAddress - Start with the address based on the location
-  /// provided, and generate the DWARF information necessary to find the
-  /// actual Block variable (navigating the Block struct) based on the
-  /// starting location.  Add the DWARF information to the die.
-  ///
-  void AddBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
-                            const MachineLocation &Location);
-
   /// AddType - Add a new type attribute to the specified entity.
   void AddType(CompileUnit *DW_Unit, DIE *Entity, DIType Ty);
 
@@ -340,7 +335,7 @@
 
   /// getOrCreateScope - Returns the scope associated with the given descriptor.
   ///
-  DbgScope *getOrCreateScope(MDNode *N);
+  DbgScope *getOrCreateScope(GlobalVariable *V);
 
   /// ConstructDbgScope - Construct the components of a scope.
   ///
@@ -453,16 +448,11 @@
   unsigned GetOrCreateSourceID(const std::string &DirName,
                                const std::string &FileName);
 
-  void ConstructCompileUnit(MDNode *N);
+  void ConstructCompileUnit(GlobalVariable *GV);
 
-  void ConstructGlobalVariableDIE(MDNode *N);
+  void ConstructGlobalVariableDIE(GlobalVariable *GV);
 
-  void ConstructSubprogram(MDNode *N);
-
-  /// Find the type the programmer originally declared the variable to be
-  /// and return that type.
-  ///
-  DIType GetBlockByrefType(DIType Ty, std::string Name);
+  void ConstructSubprogram(GlobalVariable *GV);
 
 public:
   //===--------------------------------------------------------------------===//
@@ -516,13 +506,13 @@
                                const std::string &FileName);
 
   /// RecordRegionStart - Indicate the start of a region.
-  unsigned RecordRegionStart(MDNode *N);
+  unsigned RecordRegionStart(GlobalVariable *V);
 
   /// RecordRegionEnd - Indicate the end of a region.
-  unsigned RecordRegionEnd(MDNode *N);
+  unsigned RecordRegionEnd(GlobalVariable *V);
 
   /// RecordVariable - Indicate the declaration of  a local variable.
-  void RecordVariable(MDNode *N, unsigned FrameIndex);
+  void RecordVariable(GlobalVariable *GV, unsigned FrameIndex);
 
   //// RecordInlinedFnStart - Indicate the start of inlined subroutine.
   unsigned RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU,

Modified: llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/branches/Apple/L2/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Sun Sep  6 16:39:36 2009
@@ -80,13 +80,13 @@
 }
 
 /// RecordRegionStart - Indicate the start of a region.
-unsigned DwarfWriter::RecordRegionStart(MDNode *N) {
-  return DD->RecordRegionStart(N);
+unsigned DwarfWriter::RecordRegionStart(GlobalVariable *V) {
+  return DD->RecordRegionStart(V);
 }
 
 /// RecordRegionEnd - Indicate the end of a region.
-unsigned DwarfWriter::RecordRegionEnd(MDNode *N) {
-  return DD->RecordRegionEnd(N);
+unsigned DwarfWriter::RecordRegionEnd(GlobalVariable *V) {
+  return DD->RecordRegionEnd(V);
 }
 
 /// getRecordSourceLineCount - Count source lines.
@@ -96,8 +96,8 @@
 
 /// RecordVariable - Indicate the declaration of  a local variable.
 ///
-void DwarfWriter::RecordVariable(MDNode *N, unsigned FrameIndex) {
-  DD->RecordVariable(N, FrameIndex);
+void DwarfWriter::RecordVariable(GlobalVariable *GV, unsigned FrameIndex) {
+  DD->RecordVariable(GV, FrameIndex);
 }
 
 /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
@@ -106,7 +106,8 @@
   return DD && DD->ShouldEmitDwarfDebug();
 }
 
-//// RecordInlinedFnStart
+//// RecordInlinedFnStart - Global variable GV is inlined at the location marked
+//// by LabelID label.
 unsigned DwarfWriter::RecordInlinedFnStart(DISubprogram SP, DICompileUnit CU,
                                            unsigned Line, unsigned Col) {
   return DD->RecordInlinedFnStart(SP, CU, Line, Col);

Modified: llvm/branches/Apple/L2/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/CodeGen/MachineFunction.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/branches/Apple/L2/lib/CodeGen/MachineFunction.cpp Sun Sep  6 16:39:36 2009
@@ -333,7 +333,7 @@
 /// getOrCreateDebugLocID - Look up the DebugLocTuple index with the given
 /// source file, line, and column. If none currently exists, create a new
 /// DebugLocTuple, and insert it into the DebugIdMap.
-unsigned MachineFunction::getOrCreateDebugLocID(MDNode *CompileUnit,
+unsigned MachineFunction::getOrCreateDebugLocID(GlobalVariable *CompileUnit,
                                                 unsigned Line, unsigned Col) {
   DebugLocTuple Tuple(CompileUnit, Line, Col);
   DenseMap<DebugLocTuple, unsigned>::iterator II

Modified: llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/FastISel.cpp Sun Sep  6 16:39:36 2009
@@ -335,7 +335,7 @@
     if (isValidDebugInfoIntrinsic(*RSI, CodeGenOpt::None) && DW
         && DW->ShouldEmitDwarfDebug()) {
       unsigned ID = 
-        DW->RecordRegionStart(RSI->getContext());
+        DW->RecordRegionStart(cast<GlobalVariable>(RSI->getContext()));
       const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
       BuildMI(MBB, DL, II).addImm(ID);
     }
@@ -346,7 +346,7 @@
     if (isValidDebugInfoIntrinsic(*REI, CodeGenOpt::None) && DW
         && DW->ShouldEmitDwarfDebug()) {
      unsigned ID = 0;
-     DISubprogram Subprogram(REI->getContext());
+     DISubprogram Subprogram(cast<GlobalVariable>(REI->getContext()));
      if (isInlinedFnEnd(*REI, MF.getFunction())) {
         // This is end of an inlined function.
         const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
@@ -359,7 +359,7 @@
           BuildMI(MBB, DL, II).addImm(ID);
       } else {
         const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
-        ID =  DW->RecordRegionEnd(REI->getContext());
+        ID =  DW->RecordRegionEnd(cast<GlobalVariable>(REI->getContext()));
         BuildMI(MBB, DL, II).addImm(ID);
       }
     }
@@ -384,7 +384,7 @@
       setCurDebugLoc(ExtractDebugLocation(*FSI, MF.getDebugLocInfo()));
       
       DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc);
-      DISubprogram SP(FSI->getSubprogram());
+      DISubprogram SP(cast<GlobalVariable>(FSI->getSubprogram()));
       unsigned LabelID = DW->RecordInlinedFnStart(SP,
                                                   DICompileUnit(PrevLocTpl.CompileUnit),
                                                   PrevLocTpl.Line,
@@ -398,7 +398,7 @@
     MF.setDefaultDebugLoc(ExtractDebugLocation(*FSI, MF.getDebugLocInfo()));
     
     // llvm.dbg.func_start also defines beginning of function scope.
-    DW->RecordRegionStart(FSI->getSubprogram());
+    DW->RecordRegionStart(cast<GlobalVariable>(FSI->getSubprogram()));
     return true;
   }
   case Intrinsic::dbg_declare: {
@@ -419,7 +419,10 @@
     if (SI == StaticAllocaMap.end()) break; // VLAs.
     int FI = SI->second;
     
-    DW->RecordVariable(cast<MDNode>(Variable), FI);
+    // Determine the debug globalvariable.
+    GlobalValue *GV = cast<GlobalVariable>(Variable);
+    
+    DW->RecordVariable(cast<GlobalVariable>(GV), FI);
     return true;
   }
   case Intrinsic::eh_exception: {

Modified: llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sun Sep  6 16:39:36 2009
@@ -1596,9 +1596,9 @@
   bool useLABEL = TLI.isOperationLegalOrCustom(ISD::DBG_LABEL, MVT::Other);
 
   const DbgStopPointSDNode *DSP = cast<DbgStopPointSDNode>(Node);
-  MDNode *CU_Node = DSP->getCompileUnit();
-  if (DW && (useDEBUG_LOC || useLABEL)) {
-    DICompileUnit CU(CU_Node);
+  GlobalVariable *CU_GV = cast<GlobalVariable>(DSP->getCompileUnit());
+  if (DW && (useDEBUG_LOC || useLABEL) && !CU_GV->isDeclaration()) {
+    DICompileUnit CU(cast<GlobalVariable>(DSP->getCompileUnit()));
 
     unsigned Line = DSP->getLine();
     unsigned Col = DSP->getColumn();
@@ -1610,7 +1610,7 @@
         return DAG.getNode(ISD::DEBUG_LOC, dl, MVT::Other, Node->getOperand(0),
                            DAG.getConstant(Line, MVT::i32),
                            DAG.getConstant(Col, MVT::i32),
-                           DAG.getSrcValue(CU.getNode()));
+                           DAG.getSrcValue(CU.getGV()));
       } else {
         unsigned ID = DW->RecordSourceLine(Line, Col, CU);
         return DAG.getLabel(ISD::DBG_LABEL, dl, Node->getOperand(0), ID);

Modified: llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun Sep  6 16:39:36 2009
@@ -1286,7 +1286,7 @@
 
 SDValue SelectionDAG::getDbgStopPoint(DebugLoc DL, SDValue Root,
                                       unsigned Line, unsigned Col,
-                                      MDNode *CU) {
+                                      Value *CU) {
   SDNode *N = NodeAllocator.Allocate<DbgStopPointSDNode>();
   new (N) DbgStopPointSDNode(Root, Line, Col, CU);
   N->setDebugLoc(DL);

Modified: llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/branches/Apple/L2/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Sun Sep  6 16:39:36 2009
@@ -3871,7 +3871,7 @@
     if (isValidDebugInfoIntrinsic(RSI, OptLevel) && DW
         && DW->ShouldEmitDwarfDebug()) {
       unsigned LabelID =
-        DW->RecordRegionStart(RSI.getContext());
+        DW->RecordRegionStart(cast<GlobalVariable>(RSI.getContext()));
       DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
                                getRoot(), LabelID));
     }
@@ -3886,7 +3886,7 @@
       return 0;
 
     MachineFunction &MF = DAG.getMachineFunction();
-    DISubprogram Subprogram(REI.getContext());
+    DISubprogram Subprogram(cast<GlobalVariable>(REI.getContext()));
     
     if (isInlinedFnEnd(REI, MF.getFunction())) {
       // This is end of inlined function. Debugging information for inlined
@@ -3905,7 +3905,7 @@
     } 
 
     unsigned LabelID =
-      DW->RecordRegionEnd(REI.getContext());
+      DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext()));
     DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
                              getRoot(), LabelID));
     return 0;
@@ -3937,7 +3937,7 @@
       if (!DW || !DW->ShouldEmitDwarfDebug())
         return 0;
       DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc);
-      DISubprogram SP(FSI.getSubprogram());
+      DISubprogram SP(cast<GlobalVariable>(FSI.getSubprogram()));
       DICompileUnit CU(PrevLocTpl.CompileUnit);
       unsigned LabelID = DW->RecordInlinedFnStart(SP, CU,
                                                   PrevLocTpl.Line,
@@ -3953,7 +3953,7 @@
     if (!DW || !DW->ShouldEmitDwarfDebug())
       return 0;
     // llvm.dbg.func_start also defines beginning of function scope.
-    DW->RecordRegionStart(FSI.getSubprogram());
+    DW->RecordRegionStart(cast<GlobalVariable>(FSI.getSubprogram()));
     return 0;
   }
   case Intrinsic::dbg_declare: {
@@ -3980,7 +3980,7 @@
     if (SI == FuncInfo.StaticAllocaMap.end()) 
       return 0; // VLAs.
     int FI = SI->second;
-    DW->RecordVariable(cast<MDNode>(Variable), FI);
+    DW->RecordVariable(cast<GlobalVariable>(Variable), FI);
     return 0;
   }
   case Intrinsic::eh_exception: {

Modified: llvm/branches/Apple/L2/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Linker/LinkModules.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Linker/LinkModules.cpp (original)
+++ llvm/branches/Apple/L2/lib/Linker/LinkModules.cpp Sun Sep  6 16:39:36 2009
@@ -395,8 +395,14 @@
       assert(!isa<GlobalValue>(CPV) && "Unmapped global?");
       llvm_unreachable("Unknown type of derived type constant value!");
     }
-  } else if (isa<MetadataBase>(In)) {
-    Result = const_cast<Value*>(In);
+  } else if (const MDNode *N = dyn_cast<MDNode>(In)) {
+    std::vector<Value*> Elems;
+    for (unsigned i = 0, e = N->getNumElements(); i !=e; ++i)
+      Elems.push_back(RemapOperand(N->getElement(i), ValueMap, Context));
+    if (!Elems.empty())
+      Result = MDNode::get(Context, &Elems[0], Elems.size());
+  } else if (const MDString *MDS = dyn_cast<MDString>(In)) {
+    Result = MDString::get(Context, MDS->getString());
   } else if (isa<InlineAsm>(In)) {
     Result = const_cast<Value*>(In);
   }

Modified: llvm/branches/Apple/L2/lib/Target/PIC16/PIC16DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Target/PIC16/PIC16DebugInfo.cpp (original)
+++ llvm/branches/Apple/L2/lib/Target/PIC16/PIC16DebugInfo.cpp Sun Sep  6 16:39:36 2009
@@ -1,4 +1,3 @@
-
 //===-- PIC16DebugInfo.cpp - Implementation for PIC16 Debug Information ======//
 //
 //                     The LLVM Compiler Infrastructure
@@ -28,11 +27,11 @@
 void PIC16DbgInfo::PopulateDebugInfo (DIType Ty, unsigned short &TypeNo,
                                       bool &HasAux, int Aux[], 
                                       std::string &TagName) {
-  if (Ty.isBasicType())
+  if (Ty.isBasicType(Ty.getTag())) 
     PopulateBasicTypeInfo (Ty, TypeNo);
-  else if (Ty.isDerivedType())
+  else if (Ty.isDerivedType(Ty.getTag())) 
     PopulateDerivedTypeInfo (Ty, TypeNo, HasAux, Aux, TagName);
-  else if (Ty.isCompositeType())
+  else if (Ty.isCompositeType(Ty.getTag())) 
     PopulateCompositeTypeInfo (Ty, TypeNo, HasAux, Aux, TagName);
   else {
     TypeNo = PIC16Dbg::T_NULL;
@@ -70,7 +69,7 @@
   
   // We also need to encode the the information about the base type of
   // pointer in TypeNo.
-  DIType BaseType = DIDerivedType(Ty.getNode()).getTypeDerivedFrom();
+  DIType BaseType = DIDerivedType(Ty.getGV()).getTypeDerivedFrom();
   PopulateDebugInfo(BaseType, TypeNo, HasAux, Aux, TagName);
 }
 
@@ -79,7 +78,7 @@
                                           bool &HasAux, int Aux[],
                                           std::string &TagName) {
 
-  DICompositeType CTy = DICompositeType(Ty.getNode());
+  DICompositeType CTy = DICompositeType(Ty.getGV());
   DIArray Elements = CTy.getTypeArray();
   unsigned short size = 1;
   unsigned short Dimension[4]={0,0,0,0};
@@ -88,7 +87,7 @@
     if (Element.getTag() == dwarf::DW_TAG_subrange_type) {
       TypeNo = TypeNo << PIC16Dbg::S_DERIVED;
       TypeNo = TypeNo | PIC16Dbg::DT_ARY;
-      DISubrange SubRange = DISubrange(Element.getNode());
+      DISubrange SubRange = DISubrange(Element.getGV());
       Dimension[i] = SubRange.getHi() - SubRange.getLo() + 1;
       // Each dimension is represented by 2 bytes starting at byte 9.
       Aux[8+i*2+0] = Dimension[i];
@@ -111,7 +110,7 @@
                                                   unsigned short &TypeNo,
                                                   bool &HasAux, int Aux[],
                                                   std::string &TagName) {
-  DICompositeType CTy = DICompositeType(Ty.getNode());
+  DICompositeType CTy = DICompositeType(Ty.getGV());
   TypeNo = TypeNo << PIC16Dbg::S_BASIC;
   if (Ty.getTag() == dwarf::DW_TAG_structure_type)
     TypeNo = TypeNo | PIC16Dbg::T_STRUCT;
@@ -124,7 +123,7 @@
   // llvm.dbg.composite* global variable. Since we need to revisit 
   // PIC16DebugInfo implementation anyways after the MDNodes based 
   // framework is done, let us continue with the way it is.
-  std::string UniqueSuffix = "." + Ty.getNode()->getNameStr().substr(18);
+  std::string UniqueSuffix = "." + Ty.getGV()->getNameStr().substr(18);
   TagName += UniqueSuffix;
   unsigned short size = CTy.getSizeInBits()/8;
   // 7th and 8th byte represent size.
@@ -211,10 +210,11 @@
   DbgFinder.processModule(M);
   if (DbgFinder.compile_unit_count() != 0) {
     // FIXME : What if more then one CUs are present in a module ?
-    MDNode *CU = *DbgFinder.compile_unit_begin();
+    GlobalVariable *CU = *DbgFinder.compile_unit_begin();
     EmitDebugDirectives = true;
     SwitchToCU(CU);
   }
+
   // Emit debug info for decls of composite types.
   EmitCompositeTypeDecls(M);
 }
@@ -259,7 +259,7 @@
   if (! EmitDebugDirectives) return;
   assert (! DL.isUnknown()  && "can't change to invalid debug loc");
 
-  MDNode *CU = MF.getDebugLocTuple(DL).CompileUnit;
+  GlobalVariable *CU = MF.getDebugLocTuple(DL).CompileUnit;
   unsigned line = MF.getDebugLocTuple(DL).Line;
 
   SwitchToCU(CU);
@@ -306,7 +306,8 @@
     int ElementAux[PIC16Dbg::AuxSize] = { 0 };
     std::string TagName = "";
     std::string ElementName;
-    DIDerivedType DITy(Element.getNode());
+    GlobalVariable *GV = Element.getGV();
+    DIDerivedType DITy(GV);
     DITy.getName(ElementName);
     unsigned short ElementSize = DITy.getSizeInBits()/8;
     // Get mangleddd name for this structure/union  element.
@@ -342,7 +343,7 @@
       CTy.getName(Name);
       // Get the number after llvm.dbg.composite and make UniqueSuffix from 
       // it.
-      std::string DIVar = CTy.getNode()->getNameStr();
+      std::string DIVar = CTy.getGV()->getNameStr();
       std::string UniqueSuffix = "." + DIVar.substr(18);
       std::string MangledCTyName = Name + UniqueSuffix;
       unsigned short size = CTy.getSizeInBits()/8;
@@ -440,7 +441,7 @@
 void PIC16DbgInfo::EmitVarDebugInfo(Module &M) {
   DebugInfoFinder DbgFinder;
   DbgFinder.processModule(M);
-  
+
   for (DebugInfoFinder::iterator I = DbgFinder.global_variable_begin(),
          E = DbgFinder.global_variable_end(); I != E; ++I) {
     DIGlobalVariable DIGV(*I);
@@ -465,7 +466,7 @@
 
 /// SwitchToCU - Switch to a new compilation unit.
 ///
-void PIC16DbgInfo::SwitchToCU(MDNode *CU) {
+void PIC16DbgInfo::SwitchToCU(GlobalVariable *CU) {
   // Get the file path from CU.
   DICompileUnit cu(CU);
   std::string DirName, FileName;

Modified: llvm/branches/Apple/L2/lib/Target/PIC16/PIC16DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Target/PIC16/PIC16DebugInfo.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Target/PIC16/PIC16DebugInfo.h (original)
+++ llvm/branches/Apple/L2/lib/Target/PIC16/PIC16DebugInfo.h Sun Sep  6 16:39:36 2009
@@ -117,7 +117,7 @@
 
 
     private:
-    void SwitchToCU (MDNode *CU);
+    void SwitchToCU (GlobalVariable *CU);
     void SwitchToLine (unsigned Line, bool IsInBeginFunction = false);
 
     void PopulateDebugInfo (DIType Ty, unsigned short &TypeNo, bool &HasAux,

Modified: llvm/branches/Apple/L2/lib/Transforms/IPO/StripSymbols.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Transforms/IPO/StripSymbols.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Transforms/IPO/StripSymbols.cpp (original)
+++ llvm/branches/Apple/L2/lib/Transforms/IPO/StripSymbols.cpp Sun Sep  6 16:39:36 2009
@@ -202,56 +202,167 @@
 // llvm.dbg.region.end calls, and any globals they point to if now dead.
 static bool StripDebugInfo(Module &M) {
 
-  // Remove all of the calls to the debugger intrinsics, and remove them from
-  // the module.
+  SmallPtrSet<const GlobalValue*, 8> llvmUsedValues;
+  findUsedValues(M.getGlobalVariable("llvm.used"), llvmUsedValues);
+  findUsedValues(M.getGlobalVariable("llvm.compiler.used"), llvmUsedValues);
+
+  DebugInfoFinder DbgFinder;
+  DbgFinder.processModule(M);
+
+  // These anchors use LinkOnce linkage so that the optimizer does not
+  // remove them accidently. Set InternalLinkage for all these debug
+  // info anchors.
+  for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(),
+         E = DbgFinder.compile_unit_end(); I != E; ++I)
+    (*I)->setLinkage(GlobalValue::InternalLinkage);
+  for (DebugInfoFinder::iterator I = DbgFinder.global_variable_begin(),
+         E = DbgFinder.global_variable_end(); I != E; ++I)
+    (*I)->setLinkage(GlobalValue::InternalLinkage);
+  for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),
+         E = DbgFinder.subprogram_end(); I != E; ++I)
+    (*I)->setLinkage(GlobalValue::InternalLinkage);
+
+
+ // Delete all dbg variables.
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); 
+       I != E; ++I) {
+    GlobalVariable *GV = dyn_cast<GlobalVariable>(I);
+    if (!GV) continue;
+    if (!GV->use_empty() && llvmUsedValues.count(I) == 0) {
+      if (GV->getName().startswith("llvm.dbg")) {
+        GV->replaceAllUsesWith(UndefValue::get(GV->getType()));
+      }
+    }
+  }
+
   Function *FuncStart = M.getFunction("llvm.dbg.func.start");
   Function *StopPoint = M.getFunction("llvm.dbg.stoppoint");
   Function *RegionStart = M.getFunction("llvm.dbg.region.start");
   Function *RegionEnd = M.getFunction("llvm.dbg.region.end");
   Function *Declare = M.getFunction("llvm.dbg.declare");
 
+  std::vector<Constant*> DeadConstants;
+
+  // Remove all of the calls to the debugger intrinsics, and remove them from
+  // the module.
   if (FuncStart) {
     while (!FuncStart->use_empty()) {
       CallInst *CI = cast<CallInst>(FuncStart->use_back());
+      Value *Arg = CI->getOperand(1);
+      assert(CI->use_empty() && "llvm.dbg intrinsic should have void result");
       CI->eraseFromParent();
+      if (Arg->use_empty())
+        if (Constant *C = dyn_cast<Constant>(Arg)) 
+          DeadConstants.push_back(C);
     }
     FuncStart->eraseFromParent();
   }
   if (StopPoint) {
     while (!StopPoint->use_empty()) {
       CallInst *CI = cast<CallInst>(StopPoint->use_back());
+      Value *Arg = CI->getOperand(3);
+      assert(CI->use_empty() && "llvm.dbg intrinsic should have void result");
       CI->eraseFromParent();
+      if (Arg->use_empty())
+        if (Constant *C = dyn_cast<Constant>(Arg)) 
+          DeadConstants.push_back(C);
     }
     StopPoint->eraseFromParent();
   }
   if (RegionStart) {
     while (!RegionStart->use_empty()) {
       CallInst *CI = cast<CallInst>(RegionStart->use_back());
+      Value *Arg = CI->getOperand(1);
+      assert(CI->use_empty() && "llvm.dbg intrinsic should have void result");
       CI->eraseFromParent();
+      if (Arg->use_empty())
+        if (Constant *C = dyn_cast<Constant>(Arg)) 
+          DeadConstants.push_back(C);
     }
     RegionStart->eraseFromParent();
   }
   if (RegionEnd) {
     while (!RegionEnd->use_empty()) {
       CallInst *CI = cast<CallInst>(RegionEnd->use_back());
+      Value *Arg = CI->getOperand(1);
+      assert(CI->use_empty() && "llvm.dbg intrinsic should have void result");
       CI->eraseFromParent();
+      if (Arg->use_empty())
+        if (Constant *C = dyn_cast<Constant>(Arg)) 
+          DeadConstants.push_back(C);
     }
     RegionEnd->eraseFromParent();
   }
   if (Declare) {
     while (!Declare->use_empty()) {
       CallInst *CI = cast<CallInst>(Declare->use_back());
+      Value *Arg1 = CI->getOperand(1);
+      Value *Arg2 = CI->getOperand(2);
+      assert(CI->use_empty() && "llvm.dbg intrinsic should have void result");
       CI->eraseFromParent();
+      if (Arg1->use_empty()) {
+        if (Constant *C = dyn_cast<Constant>(Arg1)) 
+          DeadConstants.push_back(C);
+        else 
+          RecursivelyDeleteTriviallyDeadInstructions(Arg1);
+      }
+      if (Arg2->use_empty())
+        if (Constant *C = dyn_cast<Constant>(Arg2)) 
+          DeadConstants.push_back(C);
     }
     Declare->eraseFromParent();
   }
 
-  NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.gv");
-  if (NMD)
-    NMD->eraseFromParent();
+  // llvm.dbg.compile_units and llvm.dbg.subprograms are marked as linkonce
+  // but since we are removing all debug information, make them internal now.
+  // FIXME: Use private linkage maybe?
+  if (Constant *C = M.getNamedGlobal("llvm.dbg.compile_units"))
+    if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
+      GV->setLinkage(GlobalValue::InternalLinkage);
+
+  if (Constant *C = M.getNamedGlobal("llvm.dbg.subprograms"))
+    if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
+      GV->setLinkage(GlobalValue::InternalLinkage);
+ 
+  if (Constant *C = M.getNamedGlobal("llvm.dbg.global_variables"))
+    if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
+      GV->setLinkage(GlobalValue::InternalLinkage);
+
+  // Delete all dbg variables.
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); 
+       I != E; ++I) {
+    GlobalVariable *GV = dyn_cast<GlobalVariable>(I);
+    if (!GV) continue;
+    if (GV->use_empty() && llvmUsedValues.count(I) == 0
+        && (!GV->hasSection() 
+            || strcmp(GV->getSection().c_str(), "llvm.metadata") == 0))
+      DeadConstants.push_back(GV);
+  }
+
+  if (DeadConstants.empty())
+    return false;
+
+  // Delete any internal globals that were only used by the debugger intrinsics.
+  while (!DeadConstants.empty()) {
+    Constant *C = DeadConstants.back();
+    DeadConstants.pop_back();
+    if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
+      if (GV->hasLocalLinkage())
+        RemoveDeadConstant(GV);
+    }
+    else
+      RemoveDeadConstant(C);
+  }
 
-  // Remove dead metadata.
-  M.getContext().RemoveDeadMetadata();
+  // Remove all llvm.dbg types.
+  TypeSymbolTable &ST = M.getTypeSymbolTable();
+  for (TypeSymbolTable::iterator TI = ST.begin(), TE = ST.end(); TI != TE; ) {
+    if (!strncmp(TI->first.c_str(), "llvm.dbg.", 9))
+      ST.remove(TI++);
+    else 
+      ++TI;
+  }
+  
   return true;
 }
 

Modified: llvm/branches/Apple/L2/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/branches/Apple/L2/lib/Transforms/Scalar/DeadStoreElimination.cpp Sun Sep  6 16:39:36 2009
@@ -27,6 +27,7 @@
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Analysis/MemoryDependenceAnalysis.h"
+#include "llvm/Support/ValueHandle.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Transforms/Utils/Local.h"
 using namespace llvm;

Modified: llvm/branches/Apple/L2/lib/Transforms/Utils/CloneFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Transforms/Utils/CloneFunction.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Transforms/Utils/CloneFunction.cpp (original)
+++ llvm/branches/Apple/L2/lib/Transforms/Utils/CloneFunction.cpp Sun Sep  6 16:39:36 2009
@@ -238,7 +238,7 @@
     // Do not clone llvm.dbg.region.end. It will be adjusted by the inliner.
     if (const DbgFuncStartInst *DFSI = dyn_cast<DbgFuncStartInst>(II)) {
       if (DbgFnStart == NULL) {
-        DISubprogram SP(DFSI->getSubprogram());
+        DISubprogram SP(cast<GlobalVariable>(DFSI->getSubprogram()));
         if (SP.describes(BB->getParent()))
           DbgFnStart = DFSI->getSubprogram();
       }

Modified: llvm/branches/Apple/L2/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/Transforms/Utils/InlineFunction.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/branches/Apple/L2/lib/Transforms/Utils/InlineFunction.cpp Sun Sep  6 16:39:36 2009
@@ -216,17 +216,17 @@
 ///
 static const DbgRegionEndInst *findFnRegionEndMarker(const Function *F) {
 
-  MDNode *FnStart = NULL;
+  GlobalVariable *FnStart = NULL;
   const DbgRegionEndInst *FnEnd = NULL;
   for (Function::const_iterator FI = F->begin(), FE =F->end(); FI != FE; ++FI) 
     for (BasicBlock::const_iterator BI = FI->begin(), BE = FI->end(); BI != BE;
          ++BI) {
       if (FnStart == NULL)  {
         if (const DbgFuncStartInst *FSI = dyn_cast<DbgFuncStartInst>(BI)) {
-          DISubprogram SP(FSI->getSubprogram());
+          DISubprogram SP(cast<GlobalVariable>(FSI->getSubprogram()));
           assert (SP.isNull() == false && "Invalid llvm.dbg.func.start");
           if (SP.describes(F))
-            FnStart = SP.getNode();
+            FnStart = SP.getGV();
         }
         continue;
       }

Modified: llvm/branches/Apple/L2/lib/VMCore/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/VMCore/AutoUpgrade.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/VMCore/AutoUpgrade.cpp (original)
+++ llvm/branches/Apple/L2/lib/VMCore/AutoUpgrade.cpp Sun Sep  6 16:39:36 2009
@@ -16,7 +16,8 @@
 #include "llvm/Function.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
-#include "llvm/IntrinsicInst.h"
+#include "llvm/Instructions.h"
+#include "llvm/Intrinsics.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/ErrorHandling.h"
 #include <cstring>
@@ -433,74 +434,3 @@
     }
   }
 }
-
-/// This function checks debug info intrinsics. If an intrinsic is invalid
-/// then this function simply removes the intrinsic. 
-void llvm::CheckDebugInfoIntrinsics(Module *M) {
-
-
-  if (Function *FuncStart = M->getFunction("llvm.dbg.func.start")) {
-    if (!FuncStart->use_empty()) {
-      DbgFuncStartInst *DFSI = cast<DbgFuncStartInst>(FuncStart->use_back());
-      if (!isa<MDNode>(DFSI->getOperand(1))) {
-        while (!FuncStart->use_empty()) {
-          CallInst *CI = cast<CallInst>(FuncStart->use_back());
-          CI->eraseFromParent();
-        }
-        FuncStart->eraseFromParent();
-      }
-    }
-  }
-
-  if (Function *StopPoint = M->getFunction("llvm.dbg.stoppoint")) {
-    if (!StopPoint->use_empty()) {
-      DbgStopPointInst *DSPI = cast<DbgStopPointInst>(StopPoint->use_back());
-      if (!isa<MDNode>(DSPI->getOperand(3))) {
-        while (!StopPoint->use_empty()) {
-          CallInst *CI = cast<CallInst>(StopPoint->use_back());
-          CI->eraseFromParent();
-        }
-        StopPoint->eraseFromParent();
-      }
-    }
-  }
-
-  if (Function *RegionStart = M->getFunction("llvm.dbg.region.start")) {
-    if (!RegionStart->use_empty()) {
-      DbgRegionStartInst *DRSI = cast<DbgRegionStartInst>(RegionStart->use_back());
-      if (!isa<MDNode>(DRSI->getOperand(1))) {
-        while (!RegionStart->use_empty()) {
-          CallInst *CI = cast<CallInst>(RegionStart->use_back());
-          CI->eraseFromParent();
-        }
-        RegionStart->eraseFromParent();
-      }
-    }
-  }
-
-  if (Function *RegionEnd = M->getFunction("llvm.dbg.region.end")) {
-    if (!RegionEnd->use_empty()) {
-      DbgRegionEndInst *DREI = cast<DbgRegionEndInst>(RegionEnd->use_back());
-      if (!isa<MDNode>(DREI->getOperand(1))) {
-        while (!RegionEnd->use_empty()) {
-          CallInst *CI = cast<CallInst>(RegionEnd->use_back());
-          CI->eraseFromParent();
-      }
-        RegionEnd->eraseFromParent();
-      }
-    }
-  }
-  
-  if (Function *Declare = M->getFunction("llvm.dbg.declare")) {
-    if (!Declare->use_empty()) {
-      DbgDeclareInst *DDI = cast<DbgDeclareInst>(Declare->use_back());
-      if (!isa<MDNode>(DDI->getOperand(2))) {
-        while (!Declare->use_empty()) {
-          CallInst *CI = cast<CallInst>(Declare->use_back());
-          CI->eraseFromParent();
-        }
-        Declare->eraseFromParent();
-      }
-    }
-  }
-}

Modified: llvm/branches/Apple/L2/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/VMCore/Constants.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/VMCore/Constants.cpp (original)
+++ llvm/branches/Apple/L2/lib/VMCore/Constants.cpp Sun Sep  6 16:39:36 2009
@@ -1880,7 +1880,7 @@
       pImpl->ArrayConstants.InsertOrGetItem(Lookup, Exists);
     
     if (Exists) {
-      Replacement = I->second;
+      Replacement = cast<Constant>(I->second);
     } else {
       // Okay, the new shape doesn't exist in the system yet.  Instead of
       // creating a new constant array, inserting it, replaceallusesof'ing the
@@ -1967,7 +1967,7 @@
       pImpl->StructConstants.InsertOrGetItem(Lookup, Exists);
     
     if (Exists) {
-      Replacement = I->second;
+      Replacement = cast<Constant>(I->second);
     } else {
       // Okay, the new shape doesn't exist in the system yet.  Instead of
       // creating a new constant struct, inserting it, replaceallusesof'ing the

Modified: llvm/branches/Apple/L2/lib/VMCore/ConstantsContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/VMCore/ConstantsContext.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/VMCore/ConstantsContext.h (original)
+++ llvm/branches/Apple/L2/lib/VMCore/ConstantsContext.h Sun Sep  6 16:39:36 2009
@@ -16,6 +16,7 @@
 #define LLVM_CONSTANTSCONTEXT_H
 
 #include "llvm/Instructions.h"
+#include "llvm/Metadata.h"
 #include "llvm/Operator.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -340,7 +341,7 @@
 };
 
 template<class ConstantClass, class TypeClass>
-struct ConvertConstantType {
+struct ConvertConstant {
   static void convert(ConstantClass *OldC, const TypeClass *NewTy) {
     llvm_unreachable("This type cannot be converted!");
   }
@@ -391,7 +392,7 @@
 };
 
 template<>
-struct ConvertConstantType<ConstantExpr, Type> {
+struct ConvertConstant<ConstantExpr, Type> {
   static void convert(ConstantExpr *OldC, const Type *NewTy) {
     Constant *New;
     switch (OldC->getOpcode()) {
@@ -444,7 +445,14 @@
 };
 
 template<>
-struct ConvertConstantType<ConstantVector, VectorType> {
+struct ConstantCreator<MDNode, Type, std::vector<Value*> > {
+  static MDNode *create(const Type* Ty, const std::vector<Value*> &V) {
+    return new MDNode(Ty->getContext(), &V[0], V.size());
+  }
+};
+
+template<>
+struct ConvertConstant<ConstantVector, VectorType> {
   static void convert(ConstantVector *OldC, const VectorType *NewTy) {
     // Make everyone now use a constant of the new type...
     std::vector<Constant*> C;
@@ -458,7 +466,7 @@
 };
 
 template<>
-struct ConvertConstantType<ConstantAggregateZero, Type> {
+struct ConvertConstant<ConstantAggregateZero, Type> {
   static void convert(ConstantAggregateZero *OldC, const Type *NewTy) {
     // Make everyone now use a constant of the new type...
     Constant *New = ConstantAggregateZero::get(NewTy);
@@ -469,7 +477,7 @@
 };
 
 template<>
-struct ConvertConstantType<ConstantArray, ArrayType> {
+struct ConvertConstant<ConstantArray, ArrayType> {
   static void convert(ConstantArray *OldC, const ArrayType *NewTy) {
     // Make everyone now use a constant of the new type...
     std::vector<Constant*> C;
@@ -483,7 +491,7 @@
 };
 
 template<>
-struct ConvertConstantType<ConstantStruct, StructType> {
+struct ConvertConstant<ConstantStruct, StructType> {
   static void convert(ConstantStruct *OldC, const StructType *NewTy) {
     // Make everyone now use a constant of the new type...
     std::vector<Constant*> C;
@@ -506,7 +514,7 @@
 };
 
 template<>
-struct ConvertConstantType<ConstantPointerNull, PointerType> {
+struct ConvertConstant<ConstantPointerNull, PointerType> {
   static void convert(ConstantPointerNull *OldC, const PointerType *NewTy) {
     // Make everyone now use a constant of the new type...
     Constant *New = ConstantPointerNull::get(NewTy);
@@ -525,7 +533,7 @@
 };
 
 template<>
-struct ConvertConstantType<UndefValue, Type> {
+struct ConvertConstant<UndefValue, Type> {
   static void convert(UndefValue *OldC, const Type *NewTy) {
     // Make everyone now use a constant of the new type.
     Constant *New = UndefValue::get(NewTy);
@@ -540,8 +548,8 @@
 class ValueMap : public AbstractTypeUser {
 public:
   typedef std::pair<const Type*, ValType> MapKey;
-  typedef std::map<MapKey, Constant *> MapTy;
-  typedef std::map<Constant*, typename MapTy::iterator> InverseMapTy;
+  typedef std::map<MapKey, Value *> MapTy;
+  typedef std::map<Value*, typename MapTy::iterator> InverseMapTy;
   typedef std::map<const Type*, typename MapTy::iterator> AbstractTypeMapTy;
 private:
   /// Map - This is the main map from the element descriptor to the Constants.
@@ -759,8 +767,7 @@
     // leaving will remove() itself, causing the AbstractTypeMapEntry to be
     // eliminated eventually.
     do {
-      ConvertConstantType<ConstantClass,
-                          TypeClass>::convert(
+      ConvertConstant<ConstantClass, TypeClass>::convert(
                               static_cast<ConstantClass *>(I->second->second),
                                               cast<TypeClass>(NewTy));
 

Modified: llvm/branches/Apple/L2/lib/VMCore/IntrinsicInst.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/VMCore/IntrinsicInst.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/VMCore/IntrinsicInst.cpp (original)
+++ llvm/branches/Apple/L2/lib/VMCore/IntrinsicInst.cpp Sun Sep  6 16:39:36 2009
@@ -61,11 +61,17 @@
 Value *DbgStopPointInst::getFileName() const {
   // Once the operand indices are verified, update this assert
   assert(LLVMDebugVersion == (7 << 16) && "Verify operand indices");
-  return getContext()->getElement(3);
+  GlobalVariable *GV = cast<GlobalVariable>(getContext());
+  if (!GV->hasInitializer()) return NULL;
+  ConstantStruct *CS = cast<ConstantStruct>(GV->getInitializer());
+  return CS->getOperand(3);
 }
 
 Value *DbgStopPointInst::getDirectory() const {
   // Once the operand indices are verified, update this assert
   assert(LLVMDebugVersion == (7 << 16) && "Verify operand indices");
-  return getContext()->getElement(4);
+  GlobalVariable *GV = cast<GlobalVariable>(getContext());
+  if (!GV->hasInitializer()) return NULL;
+  ConstantStruct *CS = cast<ConstantStruct>(GV->getInitializer());
+  return CS->getOperand(4);
 }

Modified: llvm/branches/Apple/L2/lib/VMCore/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/VMCore/LLVMContext.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/VMCore/LLVMContext.cpp (original)
+++ llvm/branches/Apple/L2/lib/VMCore/LLVMContext.cpp Sun Sep  6 16:39:36 2009
@@ -13,11 +13,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/LLVMContext.h"
-#include "llvm/Metadata.h"
 #include "llvm/Constants.h"
 #include "llvm/Instruction.h"
 #include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/ValueHandle.h"
 #include "LLVMContextImpl.h"
 #include <set>
 
@@ -46,26 +44,24 @@
 }
 
 bool LLVMContext::RemoveDeadMetadata() {
-  std::vector<WeakVH> DeadMDNodes;
+  std::vector<const MDNode *> DeadMDNodes;
   bool Changed = false;
   while (1) {
 
-    for (FoldingSet<MDNode>::iterator 
-           I = pImpl->MDNodeSet.begin(),
-           E = pImpl->MDNodeSet.end(); I != E; ++I) {
-      MDNode *N = &(*I);
+    for (LLVMContextImpl::MDNodeMapTy::MapTy::iterator
+           I = pImpl->MDNodes.map_begin(),
+           E = pImpl->MDNodes.map_end(); I != E; ++I) {
+      const MDNode *N = cast<MDNode>(I->second);
       if (N->use_empty()) 
-        DeadMDNodes.push_back(WeakVH(N));
+        DeadMDNodes.push_back(N);
     }
     
     if (DeadMDNodes.empty())
       return Changed;
 
     while (!DeadMDNodes.empty()) {
-      Value *V = DeadMDNodes.back(); DeadMDNodes.pop_back();
-      if (const MDNode *N = dyn_cast_or_null<MDNode>(V))
-        if (N->use_empty())
-          delete N;
+      const MDNode *N = DeadMDNodes.back(); DeadMDNodes.pop_back();
+      delete N;
     }
   }
   return Changed;

Modified: llvm/branches/Apple/L2/lib/VMCore/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/VMCore/LLVMContextImpl.h?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/VMCore/LLVMContextImpl.h (original)
+++ llvm/branches/Apple/L2/lib/VMCore/LLVMContextImpl.h Sun Sep  6 16:39:36 2009
@@ -19,7 +19,6 @@
 #include "LeaksContext.h"
 #include "TypesContext.h"
 #include "llvm/LLVMContext.h"
-#include "llvm/Metadata.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/System/Mutex.h"
@@ -107,12 +106,13 @@
   
   StringMap<MDString*> MDStringCache;
   
-  FoldingSet<MDNode> MDNodeSet;
-  
   ValueMap<char, Type, ConstantAggregateZero> AggZeroConstants;
 
-  SmallPtrSet<const MDNode *, 8> MDNodes;
+  typedef ValueMap<std::vector<Value*>, Type, MDNode, true /*largekey*/> 
+  MDNodeMapTy;
 
+  MDNodeMapTy MDNodes;
+  
   typedef ValueMap<std::vector<Constant*>, ArrayType, 
     ConstantArray, true /*largekey*/> ArrayConstantsTy;
   ArrayConstantsTy ArrayConstants;
@@ -202,6 +202,7 @@
     ArrayConstants.freeConstants();
     StructConstants.freeConstants();
     VectorConstants.freeConstants();
+
     AggZeroConstants.freeConstants();
     NullPtrConstants.freeConstants();
     UndefValueConstants.freeConstants();

Modified: llvm/branches/Apple/L2/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/VMCore/Metadata.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/VMCore/Metadata.cpp (original)
+++ llvm/branches/Apple/L2/lib/VMCore/Metadata.cpp Sun Sep  6 16:39:36 2009
@@ -72,40 +72,18 @@
     // Only record metadata uses.
     if (MetadataBase *MB = dyn_cast_or_null<MetadataBase>(Vals[i]))
       OperandList[NumOperands++] = MB;
-    else if(Vals[i] && 
-            Vals[i]->getType()->getTypeID() == Type::MetadataTyID)
-      OperandList[NumOperands++] = Vals[i];
-    Node.push_back(ElementVH(Vals[i], this));
+    Node.push_back(WeakVH(Vals[i]));
   }
 }
 
-void MDNode::Profile(FoldingSetNodeID &ID) const {
-  for (const_elem_iterator I = elem_begin(), E = elem_end(); I != E; ++I)
-    ID.AddPointer(*I);
-}
-
 MDNode *MDNode::get(LLVMContext &Context, Value*const* Vals, unsigned NumVals) {
   LLVMContextImpl *pImpl = Context.pImpl;
-  FoldingSetNodeID ID;
-  for (unsigned i = 0; i != NumVals; ++i)
-    ID.AddPointer(Vals[i]);
-
-  pImpl->ConstantsLock.reader_acquire();
-  void *InsertPoint;
-  MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
-  pImpl->ConstantsLock.reader_release();
+  std::vector<Value*> V;
+  V.reserve(NumVals);
+  for (unsigned i = 0; i < NumVals; ++i)
+    V.push_back(Vals[i]);
   
-  if (!N) {
-    sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
-    N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
-    if (!N) {
-      // InsertPoint will have been set by the FindNodeOrInsertPos call.
-      N = new MDNode(Context, Vals, NumVals);
-      pImpl->MDNodeSet.InsertNode(N, InsertPoint);
-    }
-  }
-
-  return N;
+  return pImpl->MDNodes.getOrCreate(Type::getMetadataTy(Context), V);
 }
 
 /// dropAllReferences - Remove all uses and clear node vector.
@@ -114,93 +92,17 @@
   Node.clear();
 }
 
-MDNode::~MDNode() {
-  getType()->getContext().pImpl->MDNodeSet.RemoveNode(this);
-  dropAllReferences();
+static std::vector<Value*> getValType(MDNode *N) {
+  std::vector<Value*> Elements;
+  Elements.reserve(N->getNumElements());
+  for (unsigned i = 0, e = N->getNumElements(); i != e; ++i)
+    Elements.push_back(N->getElement(i));
+  return Elements;
 }
 
-// Replace value from this node's element list.
-void MDNode::replaceElement(Value *From, Value *To) {
-  if (From == To || !getType())
-    return;
-  LLVMContext &Context = getType()->getContext();
-  LLVMContextImpl *pImpl = Context.pImpl;
-
-  // Find value. This is a linear search, do something if it consumes 
-  // lot of time. It is possible that to have multiple instances of
-  // From in this MDNode's element list.
-  SmallVector<unsigned, 4> Indexes;
-  unsigned Index = 0;
-  for (SmallVector<ElementVH, 4>::iterator I = Node.begin(),
-         E = Node.end(); I != E; ++I, ++Index) {
-    Value *V = *I;
-    if (V && V == From) 
-      Indexes.push_back(Index);
-  }
-
-  if (Indexes.empty())
-    return;
-
-  // Remove "this" from the context map. 
-  {
-    sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
-    pImpl->MDNodeSet.RemoveNode(this);
-  }
-
-  // MDNode only lists metadata elements in operand list, because MDNode
-  // used by MDNode is considered a valid use. However on the side, MDNode
-  // using a non-metadata value is not considered a "use" of non-metadata
-  // value.
-  SmallVector<unsigned, 4> OpIndexes;
-  unsigned OpIndex = 0;
-  for (User::op_iterator OI = op_begin(), OE = op_end();
-       OI != OE; ++OI, OpIndex++) {
-    if (*OI == From)
-      OpIndexes.push_back(OpIndex);
-  }
-  if (MetadataBase *MDTo = dyn_cast_or_null<MetadataBase>(To)) {
-    for (SmallVector<unsigned, 4>::iterator OI = OpIndexes.begin(),
-           OE = OpIndexes.end(); OI != OE; ++OI)
-      setOperand(*OI, MDTo);
-  } else {
-    for (SmallVector<unsigned, 4>::iterator OI = OpIndexes.begin(),
-           OE = OpIndexes.end(); OI != OE; ++OI)
-      setOperand(*OI, 0);
-  }
-
-  // Replace From element(s) in place.
-  for (SmallVector<unsigned, 4>::iterator I = Indexes.begin(), E = Indexes.end(); 
-       I != E; ++I) {
-    unsigned Index = *I;
-    Node[Index] = ElementVH(To, this);
-  }
-
-  // Insert updated "this" into the context's folding node set.
-  // If a node with same element list already exist then before inserting 
-  // updated "this" into the folding node set, replace all uses of existing 
-  // node with updated "this" node.
-  FoldingSetNodeID ID;
-  Profile(ID);
-  pImpl->ConstantsLock.reader_acquire();
-  void *InsertPoint;
-  MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
-  pImpl->ConstantsLock.reader_release();
-
-  if (N) {
-    N->replaceAllUsesWith(this);
-    delete N;
-    N = 0;
-  }
-
-  {
-    sys::SmartScopedWriter<true> Writer(pImpl->ConstantsLock);
-    N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
-    if (!N) {
-      // InsertPoint will have been set by the FindNodeOrInsertPos call.
-      N = this;
-      pImpl->MDNodeSet.InsertNode(N, InsertPoint);
-    }
-  }
+MDNode::~MDNode() {
+  dropAllReferences();
+  getType()->getContext().pImpl->MDNodes.remove(this);
 }
 
 //===----------------------------------------------------------------------===//

Modified: llvm/branches/Apple/L2/lib/VMCore/ValueTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/lib/VMCore/ValueTypes.cpp?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/lib/VMCore/ValueTypes.cpp (original)
+++ llvm/branches/Apple/L2/lib/VMCore/ValueTypes.cpp Sun Sep  6 16:39:36 2009
@@ -169,7 +169,6 @@
   case MVT::v8f32:   return VectorType::get(Type::getFloatTy(Context), 8);
   case MVT::v2f64:   return VectorType::get(Type::getDoubleTy(Context), 2);
   case MVT::v4f64:   return VectorType::get(Type::getDoubleTy(Context), 4); 
-  case MVT::Metadata: return Type::getMetadataTy(Context);
  }
 }
 

Removed: llvm/branches/Apple/L2/test/Linker/2009-09-03-mdnode.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/test/Linker/2009-09-03-mdnode.ll?rev=81136&view=auto

==============================================================================
--- llvm/branches/Apple/L2/test/Linker/2009-09-03-mdnode.ll (original)
+++ llvm/branches/Apple/L2/test/Linker/2009-09-03-mdnode.ll (removed)
@@ -1,30 +0,0 @@
-; RUN: llvm-as < %s > %t.bc
-; RUN: llvm-as < %p/2009-09-03-mdnode2.ll > %t2.bc
-; RUN: llvm-link %t.bc %t2.bc
-
-declare void @f() nounwind
-
-define i32 @main(...) nounwind {
-entry:
-  %retval = alloca i32                            ; <i32*> [#uses=2]
-  call void @llvm.dbg.func.start(metadata !0)
-  store i32 0, i32* %retval
-  call void @llvm.dbg.stoppoint(i32 4, i32 5, metadata !1)
-  call void @f()
-  br label %return
-
-return:                                           ; preds = %entry
-  %0 = load i32* %retval                          ; <i32> [#uses=1]
-  call void @llvm.dbg.stoppoint(i32 5, i32 1, metadata !1)
-  call void @llvm.dbg.region.end(metadata !0)
-  ret i32 %0
-}
-
-declare void @llvm.dbg.func.start(metadata) nounwind readnone
-
-declare void @llvm.dbg.stoppoint(i32, i32, metadata) nounwind readnone
-
-declare void @llvm.dbg.region.end(metadata) nounwind readnone
-
-!0 = metadata !{i32 458798, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"main", metadata !1, i32 2, null, i1 false, i1 true}
-!1 = metadata !{i32 458769, i32 0, i32 12, metadata !"a.c", metadata !"/home/rich/ellcc/test/source", metadata !"ellcc 0.1.0", i1 true, i1 true, metadata !"", i32 0}

Removed: llvm/branches/Apple/L2/test/Linker/2009-09-03-mdnode2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/test/Linker/2009-09-03-mdnode2.ll?rev=81136&view=auto

==============================================================================
--- llvm/branches/Apple/L2/test/Linker/2009-09-03-mdnode2.ll (original)
+++ llvm/branches/Apple/L2/test/Linker/2009-09-03-mdnode2.ll (removed)
@@ -1,25 +0,0 @@
-; This file is used by 2009-09-03-mdnode.ll, so it doesn't actually do anything itself
-;
-; RUN: true
-
-define i32 @f(...) nounwind {
-entry:
-  %retval = alloca i32                            ; <i32*> [#uses=1]
-  call void @llvm.dbg.func.start(metadata !0)
-  br label %return
-
-return:                                           ; preds = %entry
-  %0 = load i32* %retval                          ; <i32> [#uses=1]
-  call void @llvm.dbg.stoppoint(i32 3, i32 1, metadata !1)
-  call void @llvm.dbg.region.end(metadata !0)
-  ret i32 %0
-}
-
-declare void @llvm.dbg.func.start(metadata) nounwind readnone
-
-declare void @llvm.dbg.stoppoint(i32, i32, metadata) nounwind readnone
-
-declare void @llvm.dbg.region.end(metadata) nounwind readnone
-
-!0 = metadata !{i32 458798, i32 0, metadata !1, metadata !"f", metadata !"f", metadata !"f", metadata !1, i32 1, null, i1 false, i1 true}
-!1 = metadata !{i32 458769, i32 0, i32 12, metadata !"b.c", metadata !"/home/rich/ellcc/test/source", metadata !"ellcc 0.1.0", i1 true, i1 true, metadata !"", i32 0}

Removed: llvm/branches/Apple/L2/test/Transforms/GlobalDCE/2009-09-03-MDNode.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/test/Transforms/GlobalDCE/2009-09-03-MDNode.ll?rev=81136&view=auto

==============================================================================
--- llvm/branches/Apple/L2/test/Transforms/GlobalDCE/2009-09-03-MDNode.ll (original)
+++ llvm/branches/Apple/L2/test/Transforms/GlobalDCE/2009-09-03-MDNode.ll (removed)
@@ -1,264 +0,0 @@
-; RUN: llvm-as < %s | opt -globaldce | llc -O0 -o /dev/null
-
-%struct..0__pthread_mutex_s = type { i32, i32, i32, i32, i32, i32, %struct.__pthread_list_t }
-%"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>" = type { i32 }
-%struct.__pthread_list_t = type { %struct.__pthread_list_t*, %struct.__pthread_list_t* }
-%struct.pthread_attr_t = type { i64, [48 x i8] }
-%struct.pthread_mutex_t = type { %struct..0__pthread_mutex_s }
-
- at _ZL20__gthrw_pthread_oncePiPFvvE = alias weak i32 (i32*, void ()*)* @pthread_once ; <i32 (i32*, void ()*)*> [#uses=0]
- at _ZL27__gthrw_pthread_getspecificj = alias weak i8* (i32)* @pthread_getspecific ; <i8* (i32)*> [#uses=0]
- at _ZL27__gthrw_pthread_setspecificjPKv = alias weak i32 (i32, i8*)* @pthread_setspecific ; <i32 (i32, i8*)*> [#uses=0]
- at _ZL22__gthrw_pthread_createPmPK14pthread_attr_tPFPvS3_ES3_ = alias weak i32 (i64*, %struct.pthread_attr_t*, i8* (i8*)*, i8*)* @pthread_create ; <i32 (i64*, %struct.pthread_attr_t*, i8* (i8*)*, i8*)*> [#uses=0]
- at _ZL22__gthrw_pthread_cancelm = alias weak i32 (i64)* @pthread_cancel ; <i32 (i64)*> [#uses=0]
- at _ZL26__gthrw_pthread_mutex_lockP15pthread_mutex_t = alias weak i32 (%struct.pthread_mutex_t*)* @pthread_mutex_lock ; <i32 (%struct.pthread_mutex_t*)*> [#uses=0]
- at _ZL29__gthrw_pthread_mutex_trylockP15pthread_mutex_t = alias weak i32 (%struct.pthread_mutex_t*)* @pthread_mutex_trylock ; <i32 (%struct.pthread_mutex_t*)*> [#uses=0]
- at _ZL28__gthrw_pthread_mutex_unlockP15pthread_mutex_t = alias weak i32 (%struct.pthread_mutex_t*)* @pthread_mutex_unlock ; <i32 (%struct.pthread_mutex_t*)*> [#uses=0]
- at _ZL26__gthrw_pthread_mutex_initP15pthread_mutex_tPK19pthread_mutexattr_t = alias weak i32 (%struct.pthread_mutex_t*, %"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*)* @pthread_mutex_init ; <i32 (%struct.pthread_mutex_t*, %"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*)*> [#uses=0]
- at _ZL26__gthrw_pthread_key_createPjPFvPvE = alias weak i32 (i32*, void (i8*)*)* @pthread_key_create ; <i32 (i32*, void (i8*)*)*> [#uses=0]
- at _ZL26__gthrw_pthread_key_deletej = alias weak i32 (i32)* @pthread_key_delete ; <i32 (i32)*> [#uses=0]
- at _ZL30__gthrw_pthread_mutexattr_initP19pthread_mutexattr_t = alias weak i32 (%"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*)* @pthread_mutexattr_init ; <i32 (%"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*)*> [#uses=0]
- at _ZL33__gthrw_pthread_mutexattr_settypeP19pthread_mutexattr_ti = alias weak i32 (%"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*, i32)* @pthread_mutexattr_settype ; <i32 (%"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*, i32)*> [#uses=0]
- at _ZL33__gthrw_pthread_mutexattr_destroyP19pthread_mutexattr_t = alias weak i32 (%"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*)* @pthread_mutexattr_destroy ; <i32 (%"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*)*> [#uses=0]
-
-define weak void @_ZN9__gnu_cxx26__aux_require_boolean_exprIbEEvRKT_(i8* %__t) {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !0)
-  tail call void @llvm.dbg.stoppoint(i32 240, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !0)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_19_ConvertibleConceptIjjEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !8)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !8)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPcEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !11)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !11)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPKcEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !12)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !12)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPwEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !13)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !13)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPKwEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !14)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !14)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIPwEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !15)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !15)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIPcEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !16)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !16)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIiEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !17)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !17)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIlEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !18)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !18)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIxEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !19)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !19)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIjEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !20)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !20)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_22_OutputIteratorConceptISt19ostreambuf_iteratorIcSt11char_traitsIcEEcEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !21)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !21)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_22_OutputIteratorConceptISt19ostreambuf_iteratorIwSt11char_traitsIwEEwEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !22)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !22)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPcEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !23)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !23)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPKcEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !24)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !24)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPKcSsEEEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !25)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !25)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPcSsEEEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !26)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !26)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPKwSbIwSt11char_traitsIwESaIwEEEEEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !27)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !27)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPwSbIwSt11char_traitsIwESaIwEEEEEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !28)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !28)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPwEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !29)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !29)
-  ret void
-}
-
-define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPKwEEEEvv() {
-entry:
-  tail call void @llvm.dbg.func.start(metadata !30)
-  tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2)
-  tail call void @llvm.dbg.region.end(metadata !30)
-  ret void
-}
-
-declare void @llvm.dbg.func.start(metadata) nounwind readnone
-
-declare void @llvm.dbg.stoppoint(i32, i32, metadata) nounwind readnone
-
-declare void @llvm.dbg.region.end(metadata) nounwind readnone
-
-declare extern_weak i32 @pthread_once(i32*, void ()*)
-
-declare extern_weak i8* @pthread_getspecific(i32)
-
-declare extern_weak i32 @pthread_setspecific(i32, i8*)
-
-declare extern_weak i32 @pthread_create(i64*, %struct.pthread_attr_t*, i8* (i8*)*, i8*)
-
-declare extern_weak i32 @pthread_cancel(i64)
-
-declare extern_weak i32 @pthread_mutex_lock(%struct.pthread_mutex_t*)
-
-declare extern_weak i32 @pthread_mutex_trylock(%struct.pthread_mutex_t*)
-
-declare extern_weak i32 @pthread_mutex_unlock(%struct.pthread_mutex_t*)
-
-declare extern_weak i32 @pthread_mutex_init(%struct.pthread_mutex_t*, %"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*)
-
-declare extern_weak i32 @pthread_key_create(i32*, void (i8*)*)
-
-declare extern_weak i32 @pthread_key_delete(i32)
-
-declare extern_weak i32 @pthread_mutexattr_init(%"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*)
-
-declare extern_weak i32 @pthread_mutexattr_settype(%"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*, i32)
-
-declare extern_weak i32 @pthread_mutexattr_destroy(%"struct.__gnu_cxx::_ConvertibleConcept<unsigned int,unsigned int>"*)
-
-!0 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__aux_require_boolean_expr<bool>", metadata !"__aux_require_boolean_expr<bool>", metadata !"_ZN9__gnu_cxx26__aux_require_boolean_exprIbEEvRKT_", metadata !2, i32 239, metadata !3, i1 false, i1 true}
-!1 = metadata !{i32 458769, i32 0, i32 4, metadata !"concept-inst.cc", metadata !"/home/buildbot/buildslave/llvm-x86_64-linux-selfhost/llvm-gcc.obj/x86_64-unknown-linux-gnu/libstdc++-v3/src/../../../../llvm-gcc.src/libstdc++-v3/src", metadata !"4.2.1 (Based on Apple Inc. build 5649) (LLVM build)", i1 true, i1 true, metadata !"", i32 0}
-!2 = metadata !{i32 458769, i32 0, i32 4, metadata !"boost_concept_check.h", metadata !"/home/buildbot/buildslave/llvm-x86_64-linux-selfhost/llvm-gcc.obj/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits", metadata !"4.2.1 (Based on Apple Inc. build 5649) (LLVM build)", i1 false, i1 true, metadata !"", i32 0}
-!3 = metadata !{i32 458773, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0}
-!4 = metadata !{null, metadata !5}
-!5 = metadata !{i32 458768, metadata !1, metadata !"", metadata !1, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !6}
-!6 = metadata !{i32 458790, metadata !1, metadata !"", metadata !1, i32 0, i64 8, i64 8, i64 0, i32 0, metadata !7}
-!7 = metadata !{i32 458788, metadata !1, metadata !"bool", metadata !1, i32 0, i64 8, i64 8, i64 0, i32 0, i32 2}
-!8 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_ConvertibleConcept<unsigned int, unsigned int> >", metadata !"__function_requires<__gnu_cxx::_ConvertibleConcept<unsigned int, unsigned int> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_19_ConvertibleConceptIjjEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!9 = metadata !{i32 458773, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !10, i32 0}
-!10 = metadata !{null}
-!11 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept<char*> >", metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept<char*> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!12 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept<const char*> >", metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept<const char*> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPKcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!13 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept<wchar_t*> >", metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept<wchar_t*> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!14 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept<const wchar_t*> >", metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept<const wchar_t*> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPKwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!15 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<wchar_t*> >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<wchar_t*> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIPwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!16 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<char*> >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<char*> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIPcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!17 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<int> >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<int> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIiEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!18 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<long int> >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<long int> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIlEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!19 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<long long int> >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<long long int> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIxEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!20 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<unsigned int> >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept<unsigned int> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIjEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!21 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_OutputIteratorConcept<std::ostreambuf_iterator<char, std::char_traits<char> >, char> >", metadata !"__function_requires<__gnu_cxx::_OutputIteratorConcept<std::ostreambuf_iterator<char, std::char_traits<char> >, char> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_22_OutputIteratorConceptISt19ostreambuf_iteratorIcSt11char_traitsIcEEcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!22 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_OutputIteratorConcept<std::ostreambuf_iterator<wchar_t, std::char_traits<wchar_t> >, wchar_t> >", metadata !"__function_requires<__gnu_cxx::_OutputIteratorConcept<std::ostreambuf_iterator<wchar_t, std::char_traits<wchar_t> >, wchar_t> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_22_OutputIteratorConceptISt19ostreambuf_iteratorIwSt11char_traitsIwEEwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!23 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<char*> >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<char*> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!24 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<const char*> >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<const char*> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPKcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!25 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPKcSsEEEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!26 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPcSsEEEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!27 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator<const wchar_t*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator<const wchar_t*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPKwSbIwSt11char_traitsIwESaIwEEEEEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!28 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator<wchar_t*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator<wchar_t*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPwSbIwSt11char_traitsIwESaIwEEEEEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!29 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<wchar_t*> >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<wchar_t*> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}
-!30 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<const wchar_t*> >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<const wchar_t*> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPKwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true}

Modified: llvm/branches/Apple/L2/test/Transforms/SimplifyCFG/dbginfo.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/L2/test/Transforms/SimplifyCFG/dbginfo.ll?rev=81137&r1=81136&r2=81137&view=diff

==============================================================================
--- llvm/branches/Apple/L2/test/Transforms/SimplifyCFG/dbginfo.ll (original)
+++ llvm/branches/Apple/L2/test/Transforms/SimplifyCFG/dbginfo.ll Sun Sep  6 16:39:36 2009
@@ -1,3 +1,5 @@
+; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | grep region | count 2
+; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | grep func.start | count 2
 ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep "br label"
 
 	%llvm.dbg.anchor.type = type { i32, i32 }





More information about the llvm-branch-commits mailing list