1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
5 <title>Source Level Debugging with LLVM</title>
6 <link rel="stylesheet" href="llvm.css" type="text/css">
10 <div class="doc_title">Source Level Debugging with LLVM</div>
12 <table class="layout" style="width:100%">
16 <li><a href="#introduction">Introduction</a>
18 <li><a href="#phil">Philosophy behind LLVM debugging information</a></li>
19 <li><a href="#debugopt">Debugging optimized code</a></li>
21 <li><a href="#format">Debugging information format</a>
23 <li><a href="#debug_info_descriptors">Debug information descriptors</a>
25 <li><a href="#format_anchors">Anchor descriptors</a></li>
26 <li><a href="#format_compile_units">Compile unit descriptors</a></li>
27 <li><a href="#format_global_variables">Global variable descriptors</a></li>
28 <li><a href="#format_subprograms">Subprogram descriptors</a></li>
29 <li><a href="#format_basic_type">Basic type descriptors</a></li>
30 <li><a href="#format_derived_type">Derived type descriptors</a></li>
31 <li><a href="#format_composite_type">Composite type descriptors</a></li>
32 <li><a href="#format_subrange">Subrange descriptors</a></li>
33 <li><a href="#format_enumeration">Enumerator descriptors</a></li>
35 <li><a href="#format_common_intrinsics">Debugger intrinsic functions</a>
37 <li><a href="#format_common_stoppoint">llvm.dbg.stoppoint</a></li>
38 <li><a href="#format_common_func_start">llvm.dbg.func.start</a></li>
39 <li><a href="#format_common_region_start">llvm.dbg.region.start</a></li>
40 <li><a href="#format_common_region_end">llvm.dbg.region.end</a></li>
41 <li><a href="#format_common_declare">llvm.dbg.declare</a></li>
43 <li><a href="#format_common_stoppoints">Representing stopping points in the
44 source program</a></li>
46 <li><a href="#ccxx_frontend">C/C++ front-end specific debug information</a>
48 <li><a href="#ccxx_compile_units">C/C++ source file information</a></li>
49 <li><a href="#ccxx_global_variable">C/C++ global variable information</a></li>
50 <li><a href="#ccxx_subprogram">C/C++ function information</a></li>
51 <li><a href="#ccxx_basic_types">C/C++ basic types</a></li>
52 <li><a href="#ccxx_derived_types">C/C++ derived types</a></li>
53 <li><a href="#ccxx_composite_types">C/C++ struct/union types</a></li>
54 <li><a href="#ccxx_enumeration_types">C/C++ enumeration types</a></li>
59 <img src="img/venusflytrap.jpg" alt="A leafy and green bug eater" width="247"
64 <div class="doc_author">
65 <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>
66 and <a href="mailto:jlaskey@apple.com">Jim Laskey</a></p>
70 <!-- *********************************************************************** -->
71 <div class="doc_section"><a name="introduction">Introduction</a></div>
72 <!-- *********************************************************************** -->
74 <div class="doc_text">
76 <p>This document is the central repository for all information pertaining to
77 debug information in LLVM. It describes the <a href="#format">actual format
78 that the LLVM debug information</a> takes, which is useful for those interested
79 in creating front-ends or dealing directly with the information. Further, this
80 document provides specifc examples of what debug information for C/C++.</p>
84 <!-- ======================================================================= -->
85 <div class="doc_subsection">
86 <a name="phil">Philosophy behind LLVM debugging information</a>
89 <div class="doc_text">
91 <p>The idea of the LLVM debugging information is to capture how the important
92 pieces of the source-language's Abstract Syntax Tree map onto LLVM code.
93 Several design aspects have shaped the solution that appears here. The
94 important ones are:</p>
97 <li>Debugging information should have very little impact on the rest of the
98 compiler. No transformations, analyses, or code generators should need to be
99 modified because of debugging information.</li>
101 <li>LLVM optimizations should interact in <a href="#debugopt">well-defined and
102 easily described ways</a> with the debugging information.</li>
104 <li>Because LLVM is designed to support arbitrary programming languages,
105 LLVM-to-LLVM tools should not need to know anything about the semantics of the
106 source-level-language.</li>
108 <li>Source-level languages are often <b>widely</b> different from one another.
109 LLVM should not put any restrictions of the flavor of the source-language, and
110 the debugging information should work with any language.</li>
112 <li>With code generator support, it should be possible to use an LLVM compiler
113 to compile a program to native machine code and standard debugging formats.
114 This allows compatibility with traditional machine-code level debuggers, like
119 <p>The approach used by the LLVM implementation is to use a small set of <a
120 href="#format_common_intrinsics">intrinsic functions</a> to define a mapping
121 between LLVM program objects and the source-level objects. The description of
122 the source-level program is maintained in LLVM global variables in an <a
123 href="#ccxx_frontend">implementation-defined format</a> (the C/C++ front-end
124 currently uses working draft 7 of the <a
125 href="http://www.eagercon.com/dwarf/dwarf3std.htm">Dwarf 3 standard</a>).</p>
127 <p>When a program is being debugged, a debugger interacts with the user and
128 turns the stored debug information into source-language specific information.
129 As such, the debugger must be aware of the source-language, and is thus tied to
130 a specific language of family of languages.</p>
134 <!-- ======================================================================= -->
135 <div class="doc_subsection">
136 <a name="debugopt">Debugging optimized code</a>
139 <div class="doc_text">
141 <p>An extremely high priority of LLVM debugging information is to make it
142 interact well with optimizations and analysis. In particular, the LLVM debug
143 information provides the following guarantees:</p>
147 <li>LLVM debug information <b>always provides information to accurately read the
148 source-level state of the program</b>, regardless of which LLVM optimizations
149 have been run, and without any modification to the optimizations themselves.
150 However, some optimizations may impact the ability to modify the current state
151 of the program with a debugger, such as setting program variables, or calling
152 function that have been deleted.</li>
154 <li>LLVM optimizations gracefully interact with debugging information. If they
155 are not aware of debug information, they are automatically disabled as necessary
156 in the cases that would invalidate the debug info. This retains the LLVM
157 features making it easy to write new transformations.</li>
159 <li>As desired, LLVM optimizations can be upgraded to be aware of the LLVM
160 debugging information, allowing them to update the debugging information as they
161 perform aggressive optimizations. This means that, with effort, the LLVM
162 optimizers could optimize debug code just as well as non-debug code.</li>
164 <li>LLVM debug information does not prevent many important optimizations from
165 happening (for example inlining, basic block reordering/merging/cleanup, tail
166 duplication, etc), further reducing the amount of the compiler that eventually
167 is "aware" of debugging information.</li>
169 <li>LLVM debug information is automatically optimized along with the rest of the
170 program, using existing facilities. For example, duplicate information is
171 automatically merged by the linker, and unused information is automatically
176 <p>Basically, the debug information allows you to compile a program with
177 "<tt>-O0 -g</tt>" and get full debug information, allowing you to arbitrarily
178 modify the program as it executes from the debugger. Compiling a program with
179 "<tt>-O3 -g</tt>" gives you full debug information that is always available and
180 accurate for reading (e.g., you get accurate stack traces despite tail call
181 elimination and inlining), but you might lose the ability to modify the program
182 and call functions where were optimized out of the program, or inlined away
187 <!-- *********************************************************************** -->
188 <div class="doc_section">
189 <a name="format">Debugging information format</a>
191 <!-- *********************************************************************** -->
193 <div class="doc_text">
195 <p>LLVM debugging information has been carefully designed to make it possible
196 for the optimizer to optimize the program and debugging information without
197 necessarily having to know anything about debugging information. In particular,
198 the global constant merging pass automatically eliminates duplicated debugging
199 information (often caused by header files), the global dead code elimination
200 pass automatically deletes debugging information for a function if it decides to
201 delete the function, and the linker eliminates debug information when it merges
202 <tt>linkonce</tt> functions.</p>
204 <p>To do this, most of the debugging information (descriptors for types,
205 variables, functions, source files, etc) is inserted by the language front-end
206 in the form of LLVM global variables. These LLVM global variables are no
207 different from any other global variables, except that they have a web of LLVM
208 intrinsic functions that point to them. If the last references to a particular
209 piece of debugging information are deleted (for example, by the
210 <tt>-globaldce</tt> pass), the extraneous debug information will automatically
211 become dead and be removed by the optimizer.</p>
213 <p>Debug information is designed to be agnostic about the target debugger and
214 debugging information representation (e.g. DWARF/Stabs/etc). It uses a generic
215 machine debug information pass to decode the information that represents
216 variables, types, functions, namespaces, etc: this allows for arbitrary
217 source-language semantics and type-systems to be used, as long as there is a
218 module written for the target debugger to interpret the information. In
219 addition, debug global variables are declared in the <tt>"llvm.metadata"</tt>
220 section. All values declared in this section are stripped away after target
221 debug information is constructed and before the program object is emitted.</p>
223 <p>To provide basic functionality, the LLVM debugger does have to make some
224 assumptions about the source-level language being debugged, though it keeps
225 these to a minimum. The only common features that the LLVM debugger assumes
226 exist are <a href="#format_compile_units">source files</a>, and <a
227 href="#format_global_variables">program objects</a>. These abstract objects are
228 used by the debugger to form stack traces, show information about local
231 <p>This section of the documentation first describes the representation aspects
232 common to any source-language. The <a href="#ccxx_frontend">next section</a>
233 describes the data layout conventions used by the C and C++ front-ends.</p>
237 <!-- ======================================================================= -->
238 <div class="doc_subsection">
239 <a name="debug_info_descriptors">Debug information descriptors</a>
242 <div class="doc_text">
243 <p>In consideration of the complexity and volume of debug information, LLVM
244 provides a specification for well formed debug global variables. The constant
245 value of each of these globals is one of a limited set of structures, known as
246 debug descriptors.</p>
248 <p>Consumers of LLVM debug information expect the descriptors for program
249 objects to start in a canonical format, but the descriptors can include
250 additional information appended at the end that is source-language specific.
251 All LLVM debugging information is versioned, allowing backwards compatibility in
252 the case that the core structures need to change in some way. Also, all
253 debugging information objects start with a tag to indicate what type of object
254 it is. The source-language is allowed to define its own objects, by using
255 unreserved tag numbers.</p>
257 <p>The fields of debug descriptors used internally by LLVM (MachineDebugInfo)
258 are restricted to only the simple data types <tt>int</tt>, <tt>uint</tt>,
259 <tt>bool</tt>, <tt>float</tt>, <tt>double</tt>, <tt>sbyte*</tt> and <tt> { }*
260 </tt>. References to arbitrary values are handled using a <tt> { }* </tt> and a
261 cast to <tt> { }* </tt> expression; typically references to other field
262 descriptors, arrays of descriptors or global variables.</p>
265 %llvm.dbg.object.type = type {
271 <p>The first field of a descriptor is always an <tt>uint</tt> containing a tag
272 value identifying the content of the descriptor. The remaining fields are
273 specific to the descriptor. The values of tags are loosely bound to the tag
274 values of Dwarf information entries. However, that does not restrict the use of
275 the information supplied to Dwarf targets.</p>
277 <p>The details of the various descriptors follow.</p>
281 <!-- ======================================================================= -->
282 <div class="doc_subsubsection">
283 <a name="format_anchors">Anchor descriptors</a>
286 <div class="doc_text">
289 %<a href="#format_anchors">llvm.dbg.anchor.type</a> = type {
291 uint ;; Tag of descriptors grouped by the anchor
295 <p>One important aspect of the LLVM debug representation is that it allows the
296 LLVM debugger to efficiently index all of the global objects without having the
297 scan the program. To do this, all of the global objects use "anchor"
298 descriptors with designated names. All of the global objects of a particular
299 type (e.g., compile units) contain a pointer to the anchor. This pointer allows
300 the debugger to use def-use chains to find all global objects of that type.</p>
302 <p>The following names are recognized as anchors by LLVM:</p>
305 %<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 } ;; DW_TAG_compile_unit
306 %<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 } ;; DW_TAG_variable
307 %<a href="#format_subprograms">llvm.dbg.subprograms</a> = linkonce constant %<a href="#format_anchors">llvm.dbg.anchor.type</a> { uint 0, uint 46 } ;; DW_TAG_subprogram
310 <p>Using anchors in this way (where the compile unit descriptor points to the
311 anchors, as opposed to having a list of compile unit descriptors) allows for the
312 standard dead global elimination and merging passes to automatically remove
313 unused debugging information. If the globals were kept track of through lists,
314 there would always be an object pointing to the descriptors, thus would never be
319 <!-- ======================================================================= -->
320 <div class="doc_subsubsection">
321 <a name="format_compile_units">Compile unit descriptors</a>
324 <div class="doc_text">
327 %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = type {
328 uint, ;; Tag = 17 (DW_TAG_compile_unit)
329 { }*, ;; Compile unit anchor = cast = (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_units</a> to { }*)
330 uint, ;; LLVM debug version number = 1
331 uint, ;; Dwarf language identifier (ex. DW_LANG_C89)
332 sbyte*, ;; Source file name
333 sbyte*, ;; Source file directory (includes trailing slash)
334 sbyte* ;; Producer (ex. "4.0.1 LLVM (LLVM research group)")
338 <p>These descriptors contain the version number for the debug info (currently
339 1), a source language ID for the file (we use the Dwarf 3.0 ID numbers, such as
340 <tt>DW_LANG_C89</tt>, <tt>DW_LANG_C_plus_plus</tt>, <tt>DW_LANG_Cobol74</tt>,
341 etc), three strings describing the filename, working directory of the compiler,
342 and an identifier string for the compiler that produced it.</p>
344 <p> Compile unit descriptors provide the root context for objects declared in a
345 specific source file. Global variables and top level functions would be defined
346 using this context. Compile unit descriptors also provide context for source
347 line correspondence.</p>
351 <!-- ======================================================================= -->
352 <div class="doc_subsubsection">
353 <a name="format_global_variables">Global variable descriptors</a>
356 <div class="doc_text">
359 %<a href="#format_global_variables">llvm.dbg.global_variable.type</a> = type {
360 uint, ;; Tag = 52 (DW_TAG_variable)
361 { }*, ;; Global variable anchor = cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_global_variables">llvm.dbg.global_variables</a> to { }*),
362 { }*, ;; Reference to compile unit
364 { }*, ;; Reference to type descriptor
365 bool, ;; True if the global is local to compile unit (static)
366 bool, ;; True if the global is defined in the compile unit (not extern)
367 { }*, ;; Reference to the global variable
368 uint ;; Line number in compile unit where variable is defined
372 <p>These descriptors provide debug information about globals variables. The
373 provide details such as name, type and where the variable is defined.</p>
377 <!-- ======================================================================= -->
378 <div class="doc_subsubsection">
379 <a name="format_subprograms">Subprogram descriptors</a>
382 <div class="doc_text">
385 %<a href="#format_subprograms">llvm.dbg.subprogram.type</a> = type {
386 uint, ;; Tag = 46 (DW_TAG_subprogram)
387 { }*, ;; Subprogram anchor = cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_subprograms">llvm.dbg.subprograms</a> to { }*),
388 { }*, ;; Reference to compile unit
390 { }*, ;; Reference to type descriptor
391 bool, ;; True if the global is local to compile unit (static)
392 bool ;; True if the global is defined in the compile unit (not extern)
398 <p>These descriptors provide debug information about functions, methods and
399 subprograms. The provide details such as name, return and argument types and
400 where the subprogram is defined.</p>
404 <!-- ======================================================================= -->
405 <div class="doc_subsubsection">
406 <a name="format_basic_type">Basic type descriptors</a>
409 <div class="doc_text">
412 %<a href="#format_basic_type">llvm.dbg.basictype.type</a> = type {
413 uint, ;; Tag = 36 (DW_TAG_base_type)
414 { }*, ;; Reference to context (typically a compile unit)
415 sbyte*, ;; Name (may be "" for anonymous types)
416 { }*, ;; Reference to compile unit where defined (may be NULL)
417 int, ;; Line number where defined (may be 0)
418 uint, ;; Size in bits
419 uint, ;; Alignment in bits
420 uint, ;; Offset in bits
421 uint ;; Dwarf type encoding
425 <p>These descriptors define primitive types used in the code. Example int, bool
426 and float. The context provides the scope of the type, which is usually the top
427 level. Since basic types are not usually user defined the compile unit and line
428 number can be left as NULL and 0. The size, alignment and offset are expressed
429 in bits and can be 64 bit values. The alignment is used to round the offset
430 when embedded in a <a href="#format_composite_type">composite type</a>
431 (example to keep float doubles on 64 bit boundaries.) The offset is the bit
432 offset if embedded in a <a href="#format_composite_type">composite
435 <p>The type encoding provides the details of the type. The values are typically
436 one of the following;</p>
443 DW_ATE_signed_char = 6
445 DW_ATE_unsigned_char = 8
450 <!-- ======================================================================= -->
451 <div class="doc_subsubsection">
452 <a name="format_derived_type">Derived type descriptors</a>
455 <div class="doc_text">
458 %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> = type {
459 uint, ;; Tag (see below)
460 { }*, ;; Reference to context
461 sbyte*, ;; Name (may be "" for anonymous types)
462 { }*, ;; Reference to compile unit where defined (may be NULL)
463 int, ;; Line number where defined (may be 0)
464 uint, ;; Size in bits
465 uint, ;; Alignment in bits
466 uint, ;; Offset in bits
467 { }* ;; Reference to type derived from
471 <p>These descriptors are used to define types derived from other types. The
472 value of the tag varies depending on the meaning. The following are possible
477 DW_TAG_pointer_type = 15
478 DW_TAG_reference_type = 16
480 DW_TAG_const_type = 38
481 DW_TAG_volatile_type = 53
482 DW_TAG_restrict_type = 55
485 <p> <tt>DW_TAG_member</tt> is used to define a member of a <a
486 href="#format_composite_type">composite type</a>. The type of the member is the
487 <a href="#format_derived_type">derived type</a>.</p>
489 <p><tt>DW_TAG_typedef</tt> is used to
490 provide a name for the derived type.</p>
492 <p><tt>DW_TAG_pointer_type</tt>,
493 <tt>DW_TAG_reference_type</tt>, <tt>DW_TAG_const_type</tt>,
494 <tt>DW_TAG_volatile_type</tt> and <tt>DW_TAG_restrict_type</tt> are used to
495 qualify the <a href="#format_derived_type">derived type</a>. </p>
497 <p><a href="#format_derived_type">Derived type</a> location can be determined
498 from the compile unit and line number. The size, alignment and offset are
499 expressed in bits and can be 64 bit values. The alignment is used to round the
500 offset when embedded in a <a href="#format_composite_type">composite type</a>
501 (example to keep float doubles on 64 bit boundaries.) The offset is the bit
502 offset if embedded in a <a href="#format_composite_type">composite
505 <p>Note that the <tt>void *</tt> type is expressed as a
506 <tt>llvm.dbg.derivedtype.type</tt> with tag of <tt>DW_TAG_pointer_type</tt> and
507 NULL derived type.</p>
511 <!-- ======================================================================= -->
512 <div class="doc_subsubsection">
513 <a name="format_composite_type">Composite type descriptors</a>
516 <div class="doc_text">
519 %<a href="#format_composite_type">llvm.dbg.compositetype.type</a> = type {
520 uint, ;; Tag (see below)
521 { }*, ;; Reference to context
522 sbyte*, ;; Name (may be "" for anonymous types)
523 { }*, ;; Reference to compile unit where defined (may be NULL)
524 int, ;; Line number where defined (may be 0)
525 uint, ;; Size in bits
526 uint, ;; Alignment in bits
527 uint, ;; Offset in bits
528 { }* ;; Reference to array of member descriptors
532 <p>These descriptors are used to define types that are composed of 0 or more
533 elements. The value of the tag varies depending on the meaning. The following
534 are possible tag values;</p>
537 DW_TAG_array_type = 1
538 DW_TAG_enumeration_type = 4
539 DW_TAG_structure_type = 19
540 DW_TAG_union_type = 23
543 <p>The members of array types (tag = <tt>DW_TAG_array_type</tt>) are <a
544 href="#format_subrange">subrange descriptors</a>, each representing the range of
545 subscripts at that level of indexing.</p>
547 <p>The members of enumeration types (tag = <tt>DW_TAG_enumeration_type</tt>) are
548 <a href="#format_enumeration">enumerator descriptors</a>, each representing the
549 definition of enumeration value
552 <p>The members of structure (tag = <tt>DW_TAG_structure_type</tt>) or union (tag
553 = <tt>DW_TAG_union_type</tt>) types are any one of the <a
554 href="#format_basic_type">basic</a>, <a href="#format_derived_type">derived</a>
555 or <a href="#format_composite_type">composite</a> type descriptors, each
556 representing a field member of the structure or union.</p>
558 <p><a href="#format_composite_type">Composite type</a> location can be
559 determined from the compile unit and line number. The size, alignment and
560 offset are expressed in bits and can be 64 bit values. The alignment is used to
561 round the offset when embedded in a <a href="#format_composite_type">composite
562 type</a> (as an example, to keep float doubles on 64 bit boundaries.) The offset
563 is the bit offset if embedded in a <a href="#format_composite_type">composite
568 <!-- ======================================================================= -->
569 <div class="doc_subsubsection">
570 <a name="format_subrange">Subrange descriptors</a>
573 <div class="doc_text">
576 %<a href="#format_subrange">llvm.dbg.subrange.type</a> = type {
577 uint, ;; Tag = 33 (DW_TAG_subrange_type)
583 <p>These descriptors are used to define ranges of array subscripts for an array
584 <a href="#format_composite_type">composite type</a>. The low value defines the
585 lower bounds typically zero for C/C++. The high value is the upper bounds.
586 Values are 64 bit. High - low + 1 is the size of the array. If
587 low == high the array will be unbounded.</p>
591 <!-- ======================================================================= -->
592 <div class="doc_subsubsection">
593 <a name="format_enumeration">Enumerator descriptors</a>
596 <div class="doc_text">
599 %<a href="#format_enumeration">llvm.dbg.enumerator.type</a> = type {
600 uint, ;; Tag = 40 (DW_TAG_enumerator)
606 <p>These descriptors are used to define members of an enumeration <a
607 href="#format_composite_type">composite type</a>, it associates the name to the
612 <!-- ======================================================================= -->
613 <div class="doc_subsection">
614 <a name="format_common_intrinsics">Debugger intrinsic functions</a>
617 <div class="doc_text">
619 <p>LLVM uses several intrinsic functions (name prefixed with "llvm.dbg") to
620 provide debug information at various points in generated code.</p>
624 <!-- ======================================================================= -->
625 <div class="doc_subsubsection">
626 <a name="format_common_stoppoint">llvm.dbg.stoppoint</a>
629 <div class="doc_text">
631 void %<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint, uint, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* )
634 <p>This intrinsic is used to provide correspondence between the source file and
635 the generated code. The first argument is the line number (base 1), second
636 argument si the column number (0 if unknown) and the third argument the source
637 compile unit. Code following a call to this intrinsic will have been defined in
638 close proximity of the line, column and file. This information holds until the
639 next call to <a href="#format_common_stoppoint">lvm.dbg.stoppoint</a>.</p>
643 <!-- ======================================================================= -->
644 <div class="doc_subsubsection">
645 <a name="format_common_func_start">llvm.dbg.func.start</a>
648 <div class="doc_text">
650 void %<a href="#format_common_func_start">llvm.dbg.func.start</a>( %<a href="#format_subprograms">llvm.dbg.subprogram.type</a>* )
653 <p>This intrinsic is used to link the debug information in <tt>%<a
654 href="#format_subprograms">llvm.dbg.subprogram</a></tt> to the function. It also
655 defines the beginning of the function's declarative region (scope.) The
656 intrinsic should be called early in the function after the all the alloca
661 <!-- ======================================================================= -->
662 <div class="doc_subsubsection">
663 <a name="format_common_region_start">llvm.dbg.region.start</a>
666 <div class="doc_text">
668 void %<a href="#format_common_region_start">llvm.dbg.region.start</a>()
671 <p>This intrinsic is used to define the beginning of a declarative scope (ex.
672 block) for local language elements. It should be paired off with a closing
673 <tt>%<a href="#format_common_region_end">llvm.dbg.region.end</a></tt>.</p>
677 <!-- ======================================================================= -->
678 <div class="doc_subsubsection">
679 <a name="format_common_region_end">llvm.dbg.region.end</a>
682 <div class="doc_text">
684 void %<a href="#format_common_region_end">llvm.dbg.region.end</a>()
687 <p>This intrinsic is used to define the end of a declarative scope (ex. block)
688 for local language elements. It should be paired off with an opening <tt>%<a
689 href="#format_common_region_start">llvm.dbg.region.start</a></tt> or <tt>%<a
690 href="#format_common_func_start">llvm.dbg.func.start</a></tt>.</p>
694 <!-- ======================================================================= -->
695 <div class="doc_subsubsection">
696 <a name="format_common_declare">llvm.dbg.declare</a>
699 <div class="doc_text">
701 void %<a href="#format_common_declare">llvm.dbg.declare</a>( {} *, ... )
704 <p>This intrinsic provides information about a local element (ex. variable.)
709 <!-- ======================================================================= -->
710 <div class="doc_subsection">
711 <a name="format_common_stoppoints">
712 Representing stopping points in the source program
716 <div class="doc_text">
718 <p>LLVM debugger "stop points" are a key part of the debugging representation
719 that allows the LLVM to maintain simple semantics for <a
720 href="#debugopt">debugging optimized code</a>. The basic idea is that the
721 front-end inserts calls to the <a
722 href="#format_common_stoppoint">%<tt>llvm.dbg.stoppoint</tt></a> intrinsic
723 function at every point in the program where the debugger should be able to
724 inspect the program (these correspond to places the debugger stops when you
725 "<tt>step</tt>" through it). The front-end can choose to place these as
726 fine-grained as it would like (for example, before every subexpression
727 evaluated), but it is recommended to only put them after every source statement
728 that includes executable code.</p>
730 <p>Using calls to this intrinsic function to demark legal points for the
731 debugger to inspect the program automatically disables any optimizations that
732 could potentially confuse debugging information. To non-debug-information-aware
733 transformations, these calls simply look like calls to an external function,
734 which they must assume to do anything (including reading or writing to any part
735 of reachable memory). On the other hand, it does not impact many optimizations,
736 such as code motion of non-trapping instructions, nor does it impact
737 optimization of subexpressions, code duplication transformations, or basic-block
738 reordering transformations.</p>
743 <!-- ======================================================================= -->
744 <div class="doc_subsection">
745 <a name="format_common_lifetime">Object lifetimes and scoping</a>
748 <div class="doc_text">
749 <p>In many languages, the local variables in functions can have their lifetime
750 or scope limited to a subset of a function. In the C family of languages, for
751 example, variables are only live (readable and writable) within the source block
752 that they are defined in. In functional languages, values are only readable
753 after they have been defined. Though this is a very obvious concept, it is also
754 non-trivial to model in LLVM, because it has no notion of scoping in this sense,
755 and does not want to be tied to a language's scoping rules.</p>
757 <p>In order to handle this, the LLVM debug format uses the notion of "regions"
758 of a function, delineated by calls to intrinsic functions. These intrinsic
759 functions define new regions of the program and indicate when the region
760 lifetime expires. Consider the following C fragment, for example:</p>
774 <p>Compiled to LLVM, this function would be represented like this:</p>
785 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 )
787 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 )
789 call void %<a href="#format_common_declare">llvm.dbg.declare</a>({}* %X, ...)
790 call void %<a href="#format_common_declare">llvm.dbg.declare</a>({}* %Y, ...)
792 <i>;; Evaluate expression on line 2, assigning to X.</i>
794 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 )
796 <i>;; Evaluate expression on line 3, assigning to Y.</i>
798 call void %<a href="#format_common_stoppoint">llvm.region.start</a>()
799 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 )
800 call void %<a href="#format_common_declare">llvm.dbg.declare</a>({}* %X, ...)
802 <i>;; Evaluate expression on line 5, assigning to Z.</i>
804 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 )
805 call void %<a href="#format_common_region_end">llvm.region.end</a>()
807 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 )
809 call void %<a href="#format_common_region_end">llvm.region.end</a>()
815 <p>This example illustrates a few important details about the LLVM debugging
816 information. In particular, it shows how the various intrinsics are applied
817 together to allow a debugger to analyze the relationship between statements,
818 variable definitions, and the code used to implement the function.</p>
820 <p>The first intrinsic <tt>%<a
821 href="#format_common_func_start">llvm.dbg.func.start</a></tt> provides
822 a link with the <a href="#format_subprograms">subprogram descriptor</a>
823 containing the details of this function. This call also defines the beginning
824 of the function region, bounded by the <tt>%<a
825 href="#format_common_region_end">llvm.region.end</a></tt> at the end of
826 the function. This region is used to bracket the lifetime of variables declared
827 within. For a function, this outer region defines a new stack frame whose
828 lifetime ends when the region is ended.</p>
830 <p>It is possible to define inner regions for short term variables by using the
831 %<a href="#format_common_stoppoint"><tt>llvm.region.start</tt></a> and <a
832 href="#format_common_region_end"><tt>%llvm.region.end</tt></a> to bound a
833 region. The inner region in this example would be for the block containing the
834 declaration of Z.</p>
836 <p>Using regions to represent the boundaries of source-level functions allow
837 LLVM interprocedural optimizations to arbitrarily modify LLVM functions without
838 having to worry about breaking mapping information between the LLVM code and the
839 and source-level program. In particular, the inliner requires no modification
840 to support inlining with debugging information: there is no explicit correlation
841 drawn between LLVM functions and their source-level counterparts (note however,
842 that if the inliner inlines all instances of a non-strong-linkage function into
843 its caller that it will not be possible for the user to manually invoke the
844 inlined function from the debugger).</p>
846 <p>Once the function has been defined, the <a
847 href="#format_common_stoppoint"><tt>stopping point</tt></a> corresponding to
848 line #2 (column #2) of the function is encountered. At this point in the
849 function, <b>no</b> local variables are live. As lines 2 and 3 of the example
850 are executed, their variable definitions are introduced into the program using
851 %<a href="#format_common_declare"><tt>llvm.dbg.declare</tt></a>, without the
852 need to specify a new region. These variables do not require new regions to be
853 introduced because they go out of scope at the same point in the program: line
856 <p>In contrast, the <tt>Z</tt> variable goes out of scope at a different time,
857 on line 7. For this reason, it is defined within the inner region, which kills
858 the availability of <tt>Z</tt> before the code for line 8 is executed. In this
859 way, regions can support arbitrary source-language scoping rules, as long as
860 they can only be nested (ie, one scope cannot partially overlap with a part of
863 <p>It is worth noting that this scoping mechanism is used to control scoping of
864 all declarations, not just variable declarations. For example, the scope of a
865 C++ using declaration is controlled with this couldchange how name lookup is
872 <!-- *********************************************************************** -->
873 <div class="doc_section">
874 <a name="ccxx_frontend">C/C++ front-end specific debug information</a>
876 <!-- *********************************************************************** -->
878 <div class="doc_text">
880 <p>The C and C++ front-ends represent information about the program in a format
881 that is effectively identical to <a
882 href="http://www.eagercon.com/dwarf/dwarf3std.htm">Dwarf 3.0</a> in terms of
883 information content. This allows code generators to trivially support native
884 debuggers by generating standard dwarf information, and contains enough
885 information for non-dwarf targets to translate it as needed.</p>
887 <p>This section describes the forms used to represent C and C++ programs. Other
888 languages could pattern themselves after this (which itself is tuned to
889 representing programs in the same way that Dwarf 3 does), or they could choose
890 to provide completely different forms if they don't fit into the Dwarf model.
891 As support for debugging information gets added to the various LLVM
892 source-language front-ends, the information used should be documented here.</p>
894 <p>The following sections provide examples of various C/C++ constructs and the
895 debug information that would best describe those constructs.</p>
899 <!-- ======================================================================= -->
900 <div class="doc_subsection">
901 <a name="ccxx_compile_units">C/C++ source file information</a>
904 <div class="doc_text">
906 <p>Given the source files "MySource.cpp" and "MyHeader.h" located in the
907 directory "/Users/mine/sources", the following code;</p>
910 #include "MyHeader.h"
912 int main(int argc, char *argv[]) {
917 <p>a C/C++ front-end would generate the following descriptors;</p>
922 ;; Define types used. In this case we need one for compile unit anchors and one
923 ;; for compile units.
925 %<a href="#format_anchors">llvm.dbg.anchor.type</a> = type { uint, uint }
926 %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = type { uint, { }*, uint, uint, sbyte*, sbyte*, sbyte* }
929 ;; Define the anchor for compile units. Note that the second field of the
930 ;; anchor is 17, which is the same as the tag for compile units
931 ;; (17 = DW_TAG_compile_unit.)
933 %<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"
936 ;; Define the compile unit for the source file "/Users/mine/sources/MySource.cpp".
938 %<a href="#format_compile_units">llvm.dbg.compile_unit1</a> = internal constant %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> {
940 { }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_units</a> to { }*),
943 sbyte* getelementptr ([13 x sbyte]* %str1, int 0, int 0),
944 sbyte* getelementptr ([21 x sbyte]* %str2, int 0, int 0),
945 sbyte* getelementptr ([33 x sbyte]* %str3, int 0, int 0) }, section "llvm.metadata"
948 ;; Define the compile unit for the header file "/Users/mine/sources/MyHeader.h".
950 %<a href="#format_compile_units">llvm.dbg.compile_unit2</a> = internal constant %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> {
952 { }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_units</a> to { }*),
955 sbyte* getelementptr ([11 x sbyte]* %str4, int 0, int 0),
956 sbyte* getelementptr ([21 x sbyte]* %str2, int 0, int 0),
957 sbyte* getelementptr ([33 x sbyte]* %str3, int 0, int 0) }, section "llvm.metadata"
960 ;; Define each of the strings used in the compile units.
962 %str1 = internal constant [13 x sbyte] c"MySource.cpp\00", section "llvm.metadata";
963 %str2 = internal constant [21 x sbyte] c"/Users/mine/sources/\00", section "llvm.metadata";
964 %str3 = internal constant [33 x sbyte] c"4.0.1 LLVM (LLVM research group)\00", section "llvm.metadata";
965 %str4 = internal constant [11 x sbyte] c"MyHeader.h\00", section "llvm.metadata";
971 <!-- ======================================================================= -->
972 <div class="doc_subsection">
973 <a name="ccxx_global_variable">C/C++ global variable information</a>
976 <div class="doc_text">
978 <p>Given an integer global variable declared as follows;</p>
984 <p>a C/C++ front-end would generate the following descriptors;</p>
988 ;; Define types used. One for global variable anchors, one for the global
989 ;; variable descriptor, one for the global's basic type and one for the global's
992 %<a href="#format_anchors">llvm.dbg.anchor.type</a> = type { uint, uint }
993 %<a href="#format_global_variables">llvm.dbg.global_variable.type</a> = type { uint, { }*, { }*, sbyte*, { }*, bool, bool, { }*, uint }
994 %<a href="#format_basic_type">llvm.dbg.basictype.type</a> = type { uint, { }*, sbyte*, { }*, int, uint, uint, uint, uint }
995 %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = ...
998 ;; Define the global itself.
1000 %MyGlobal = global int 100
1003 ;; Define the anchor for global variables. Note that the second field of the
1004 ;; anchor is 52, which is the same as the tag for global variables
1005 ;; (52 = DW_TAG_variable.)
1007 %<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"
1010 ;; Define the global variable descriptor. Note the reference to the global
1011 ;; variable anchor and the global variable itself.
1013 %<a href="#format_global_variables">llvm.dbg.global_variable</a> = internal constant %<a href="#format_global_variables">llvm.dbg.global_variable.type</a> {
1015 { }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_global_variables">llvm.dbg.global_variables</a> to { }*),
1016 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1017 sbyte* getelementptr ([9 x sbyte]* %str1, int 0, int 0),
1018 { }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to { }*),
1021 { }* cast (int* %MyGlobal to { }*),
1022 uint 1 }, section "llvm.metadata"
1025 ;; Define the basic type of 32 bit signed integer. Note that since int is an
1026 ;; intrinsic type the source file is NULL and line 0.
1028 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1030 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1031 sbyte* getelementptr ([4 x sbyte]* %str2, int 0, int 0),
1037 uint 5 }, section "llvm.metadata"
1040 ;; Define the names of the global variable and basic type.
1042 %str1 = internal constant [9 x sbyte] c"MyGlobal\00", section "llvm.metadata"
1043 %str2 = internal constant [4 x sbyte] c"int\00", section "llvm.metadata"
1048 <!-- ======================================================================= -->
1049 <div class="doc_subsection">
1050 <a name="ccxx_subprogram">C/C++ function information</a>
1053 <div class="doc_text">
1055 <p>Given a function declared as follows;</p>
1058 int main(int argc, char *argv[]) {
1063 <p>a C/C++ front-end would generate the following descriptors;</p>
1067 ;; Define types used. One for subprogram anchors, one for the subprogram
1068 ;; descriptor, one for the global's basic type and one for the subprogram's
1071 %<a href="#format_subprograms">llvm.dbg.subprogram.type</a> = type { uint, { }*, { }*, sbyte*, { }*, bool, bool }
1072 %<a href="#format_anchors">llvm.dbg.anchor.type</a> = type { uint, uint }
1073 %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = ...
1076 ;; Define the anchor for subprograms. Note that the second field of the
1077 ;; anchor is 46, which is the same as the tag for subprograms
1078 ;; (46 = DW_TAG_subprogram.)
1080 %<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"
1083 ;; Define the descriptor for the subprogram. TODO - more details.
1085 %<a href="#format_subprograms">llvm.dbg.subprogram</a> = internal constant %<a href="#format_subprograms">llvm.dbg.subprogram.type</a> {
1087 { }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_subprograms">llvm.dbg.subprograms</a> to { }*),
1088 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1089 sbyte* getelementptr ([5 x sbyte]* %str1, int 0, int 0),
1092 bool true }, section "llvm.metadata"
1095 ;; Define the name of the subprogram.
1097 %str1 = internal constant [5 x sbyte] c"main\00", section "llvm.metadata"
1100 ;; Define the subprogram itself.
1102 int %main(int %argc, sbyte** %argv) {
1109 <!-- ======================================================================= -->
1110 <div class="doc_subsection">
1111 <a name="ccxx_basic_types">C/C++ basic types</a>
1114 <div class="doc_text">
1116 <p>The following are the basic type descriptors for C/C++ core types;</p>
1120 <!-- ======================================================================= -->
1121 <div class="doc_subsubsection">
1122 <a name="ccxx_basic_type_bool">bool</a>
1125 <div class="doc_text">
1128 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1130 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1131 sbyte* getelementptr ([5 x sbyte]* %str1, int 0, int 0),
1137 uint 2 }, section "llvm.metadata"
1138 %str1 = internal constant [5 x sbyte] c"bool\00", section "llvm.metadata"
1143 <!-- ======================================================================= -->
1144 <div class="doc_subsubsection">
1145 <a name="ccxx_basic_char">char</a>
1148 <div class="doc_text">
1151 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1153 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1154 sbyte* getelementptr ([5 x sbyte]* %str1, int 0, int 0),
1160 uint 6 }, section "llvm.metadata"
1161 %str1 = internal constant [5 x sbyte] c"char\00", section "llvm.metadata"
1166 <!-- ======================================================================= -->
1167 <div class="doc_subsubsection">
1168 <a name="ccxx_basic_unsigned_char">unsigned char</a>
1171 <div class="doc_text">
1174 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1176 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1177 sbyte* getelementptr ([14 x sbyte]* %str1, int 0, int 0),
1183 uint 8 }, section "llvm.metadata"
1184 %str1 = internal constant [14 x sbyte] c"unsigned char\00", section "llvm.metadata"
1189 <!-- ======================================================================= -->
1190 <div class="doc_subsubsection">
1191 <a name="ccxx_basic_short">short</a>
1194 <div class="doc_text">
1197 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1199 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1200 sbyte* getelementptr ([10 x sbyte]* %str1, int 0, int 0),
1206 uint 5 }, section "llvm.metadata"
1207 %str1 = internal constant [10 x sbyte] c"short int\00", section "llvm.metadata"
1212 <!-- ======================================================================= -->
1213 <div class="doc_subsubsection">
1214 <a name="ccxx_basic_unsigned_short">unsigned short</a>
1217 <div class="doc_text">
1220 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1222 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1223 sbyte* getelementptr ([19 x sbyte]* %str1, int 0, int 0),
1229 uint 7 }, section "llvm.metadata"
1230 %str1 = internal constant [19 x sbyte] c"short unsigned int\00", section "llvm.metadata"
1235 <!-- ======================================================================= -->
1236 <div class="doc_subsubsection">
1237 <a name="ccxx_basic_int">int</a>
1240 <div class="doc_text">
1243 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1245 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1246 sbyte* getelementptr ([4 x sbyte]* %str1, int 0, int 0),
1252 uint 5 }, section "llvm.metadata"
1253 %str1 = internal constant [4 x sbyte] c"int\00", section "llvm.metadata"
1258 <!-- ======================================================================= -->
1259 <div class="doc_subsubsection">
1260 <a name="ccxx_basic_unsigned_int">unsigned int</a>
1263 <div class="doc_text">
1266 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1268 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1269 sbyte* getelementptr ([13 x sbyte]* %str1, int 0, int 0),
1275 uint 7 }, section "llvm.metadata"
1276 %str1 = internal constant [13 x sbyte] c"unsigned int\00", section "llvm.metadata"
1281 <!-- ======================================================================= -->
1282 <div class="doc_subsubsection">
1283 <a name="ccxx_basic_long_long">long long</a>
1286 <div class="doc_text">
1289 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1291 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1292 sbyte* getelementptr ([14 x sbyte]* %str1, int 0, int 0),
1298 uint 5 }, section "llvm.metadata"
1299 %str1 = internal constant [14 x sbyte] c"long long int\00", section "llvm.metadata"
1304 <!-- ======================================================================= -->
1305 <div class="doc_subsubsection">
1306 <a name="ccxx_basic_unsigned_long_long">unsigned long long</a>
1309 <div class="doc_text">
1312 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1314 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1315 sbyte* getelementptr ([23 x sbyte]* %str1, int 0, int 0),
1321 uint 7 }, section "llvm.metadata"
1322 %str1 = internal constant [23 x sbyte] c"long long unsigned int\00", section "llvm.metadata"
1327 <!-- ======================================================================= -->
1328 <div class="doc_subsubsection">
1329 <a name="ccxx_basic_float">float</a>
1332 <div class="doc_text">
1335 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1337 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1338 sbyte* getelementptr ([6 x sbyte]* %str1, int 0, int 0),
1344 uint 4 }, section "llvm.metadata"
1345 %str1 = internal constant [6 x sbyte] c"float\00", section "llvm.metadata"
1350 <!-- ======================================================================= -->
1351 <div class="doc_subsubsection">
1352 <a name="ccxx_basic_double">double</a>
1355 <div class="doc_text">
1358 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1360 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1361 sbyte* getelementptr ([7 x sbyte]* %str1, int 0, int 0),
1367 uint 4 }, section "llvm.metadata"
1368 %str1 = internal constant [7 x sbyte] c"double\00", section "llvm.metadata"
1373 <!-- ======================================================================= -->
1374 <div class="doc_subsection">
1375 <a name="ccxx_derived_types">C/C++ derived types</a>
1378 <div class="doc_text">
1380 <p>Given the following as an example of C/C++ derived type;</p>
1383 typedef const int *IntPtr;
1386 <p>a C/C++ front-end would generate the following descriptors;</p>
1390 ;; Define the typedef "IntPtr".
1392 %<a href="#format_derived_type">llvm.dbg.derivedtype1</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1394 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1395 sbyte* getelementptr ([7 x sbyte]* %str1, int 0, int 0),
1396 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1401 { }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype2</a> to { }*) }, section "llvm.metadata"
1402 %str1 = internal constant [7 x sbyte] c"IntPtr\00", section "llvm.metadata"
1405 ;; Define the pointer type.
1407 %<a href="#format_derived_type">llvm.dbg.derivedtype2</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1409 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1410 sbyte* getelementptr ([1 x sbyte]* %str2, int 0, int 0),
1416 { }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype3</a> to { }*) }, section "llvm.metadata"
1417 %str2 = internal constant [1 x sbyte] zeroinitializer, section "llvm.metadata"
1420 ;; Define the const type.
1422 %<a href="#format_derived_type">llvm.dbg.derivedtype3</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1424 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1425 sbyte* getelementptr ([1 x sbyte]* %str2, int 0, int 0),
1431 { }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype1</a> to { }*) }, section "llvm.metadata"
1434 ;; Define the int type.
1436 %<a href="#format_basic_type">llvm.dbg.basictype1</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1438 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1439 sbyte* getelementptr ([4 x sbyte]* %str4, int 0, int 0),
1445 uint 5 }, section "llvm.metadata"
1446 %str4 = internal constant [4 x sbyte] c"int\00", section "llvm.metadata"
1451 <!-- ======================================================================= -->
1452 <div class="doc_subsection">
1453 <a name="ccxx_composite_types">C/C++ struct/union types</a>
1456 <div class="doc_text">
1458 <p>Given the following as an example of C/C++ struct type;</p>
1468 <p>a C/C++ front-end would generate the following descriptors;</p>
1472 ;; Define basic type for unsigned int.
1474 %<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1476 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1477 sbyte* getelementptr ([13 x sbyte]* %str1, int 0, int 0),
1483 uint 7 }, section "llvm.metadata"
1484 %str1 = internal constant [13 x sbyte] c"unsigned int\00", section "llvm.metadata"
1487 ;; Define composite type for struct Color.
1489 %<a href="#format_composite_type">llvm.dbg.compositetype</a> = internal constant %<a href="#format_composite_type">llvm.dbg.compositetype.type</a> {
1491 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1492 sbyte* getelementptr ([6 x sbyte]* %str2, int 0, int 0),
1493 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1499 { }* cast ([3 x { }*]* %llvm.dbg.array to { }*) }, section "llvm.metadata"
1500 %str2 = internal constant [6 x sbyte] c"Color\00", section "llvm.metadata"
1503 ;; Define the Red field.
1505 %<a href="#format_derived_type">llvm.dbg.derivedtype1</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1508 sbyte* getelementptr ([4 x sbyte]* %str3, int 0, int 0),
1509 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1514 { }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to { }*) }, section "llvm.metadata"
1515 %str3 = internal constant [4 x sbyte] c"Red\00", section "llvm.metadata"
1518 ;; Define the Green field.
1520 %<a href="#format_derived_type">llvm.dbg.derivedtype2</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1523 sbyte* getelementptr ([6 x sbyte]* %str4, int 0, int 0),
1524 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1529 { }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to { }*) }, section "llvm.metadata"
1530 %str4 = internal constant [6 x sbyte] c"Green\00", section "llvm.metadata"
1533 ;; Define the Blue field.
1535 %<a href="#format_derived_type">llvm.dbg.derivedtype3</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1538 sbyte* getelementptr ([5 x sbyte]* %str5, int 0, int 0),
1539 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1544 { }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to { }*) }, section "llvm.metadata"
1545 %str5 = internal constant [5 x sbyte] c"Blue\00", section "llvm.metadata"
1548 ;; Define the array of fields used by the composite type Color.
1550 %llvm.dbg.array = internal constant [3 x { }*] [
1551 { }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype1</a> to { }*),
1552 { }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype2</a> to { }*),
1553 { }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype3</a> to { }*) ], section "llvm.metadata"
1558 <!-- ======================================================================= -->
1559 <div class="doc_subsection">
1560 <a name="ccxx_enumeration_types">C/C++ enumeration types</a>
1563 <div class="doc_text">
1565 <p>Given the following as an example of C/C++ enumeration type;</p>
1575 <p>a C/C++ front-end would generate the following descriptors;</p>
1579 ;; Define composite type for enum Trees
1581 %<a href="#format_composite_type">llvm.dbg.compositetype</a> = internal constant %<a href="#format_composite_type">llvm.dbg.compositetype.type</a> {
1583 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1584 sbyte* getelementptr ([6 x sbyte]* %str1, int 0, int 0),
1585 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1591 { }* cast ([3 x { }*]* %llvm.dbg.array to { }*) }, section "llvm.metadata"
1592 %str1 = internal constant [6 x sbyte] c"Trees\00", section "llvm.metadata"
1595 ;; Define Spruce enumerator.
1597 %<a href="#format_enumeration">llvm.dbg.enumerator1</a> = internal constant %<a href="#format_enumeration">llvm.dbg.enumerator.type</a> {
1599 sbyte* getelementptr ([7 x sbyte]* %str2, int 0, int 0),
1600 int 100 }, section "llvm.metadata"
1601 %str2 = internal constant [7 x sbyte] c"Spruce\00", section "llvm.metadata"
1604 ;; Define Oak enumerator.
1606 %<a href="#format_enumeration">llvm.dbg.enumerator2</a> = internal constant %<a href="#format_enumeration">llvm.dbg.enumerator.type</a> {
1608 sbyte* getelementptr ([4 x sbyte]* %str3, int 0, int 0),
1609 int 200 }, section "llvm.metadata"
1610 %str3 = internal constant [4 x sbyte] c"Oak\00", section "llvm.metadata"
1613 ;; Define Maple enumerator.
1615 %<a href="#format_enumeration">llvm.dbg.enumerator3</a> = internal constant %<a href="#format_enumeration">llvm.dbg.enumerator.type</a> {
1617 sbyte* getelementptr ([6 x sbyte]* %str4, int 0, int 0),
1618 int 300 }, section "llvm.metadata"
1619 %str4 = internal constant [6 x sbyte] c"Maple\00", section "llvm.metadata"
1622 ;; Define the array of enumerators used by composite type Trees.
1624 %llvm.dbg.array = internal constant [3 x { }*] [
1625 { }* cast (%<a href="#format_enumeration">llvm.dbg.enumerator.type</a>* %<a href="#format_enumeration">llvm.dbg.enumerator1</a> to { }*),
1626 { }* cast (%<a href="#format_enumeration">llvm.dbg.enumerator.type</a>* %<a href="#format_enumeration">llvm.dbg.enumerator2</a> to { }*),
1627 { }* cast (%<a href="#format_enumeration">llvm.dbg.enumerator.type</a>* %<a href="#format_enumeration">llvm.dbg.enumerator3</a> to { }*) ], section "llvm.metadata"
1632 <!-- *********************************************************************** -->
1636 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
1637 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
1638 <a href="http://validator.w3.org/check/referer"><img
1639 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
1641 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
1642 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
1643 Last modified: $Date$