blob: 69cb1af32aee7cd452ef0f197238caa1575df122 [file] [log] [blame]
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4<head>
Bill Wendling48839d92009-05-17 05:52:39 +00005 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Chris Lattnerbdfb3392004-01-05 05:06:33 +00006 <title>Source Level Debugging with LLVM</title>
7 <link rel="stylesheet" href="llvm.css" type="text/css">
8</head>
9<body>
10
11<div class="doc_title">Source Level Debugging with LLVM</div>
12
Reid Spencerd3f876c2004-11-01 08:19:36 +000013<table class="layout" style="width:100%">
14 <tr class="layout">
15 <td class="left">
Chris Lattnerbdfb3392004-01-05 05:06:33 +000016<ul>
Misha Brukman82873732004-05-12 19:21:57 +000017 <li><a href="#introduction">Introduction</a>
Chris Lattnerbdfb3392004-01-05 05:06:33 +000018 <ol>
19 <li><a href="#phil">Philosophy behind LLVM debugging information</a></li>
Jim Laskey383e0092006-03-23 17:54:33 +000020 <li><a href="#consumers">Debug information consumers</a></li>
Chris Lattnerbdfb3392004-01-05 05:06:33 +000021 <li><a href="#debugopt">Debugging optimized code</a></li>
Misha Brukman82873732004-05-12 19:21:57 +000022 </ol></li>
Misha Brukman82873732004-05-12 19:21:57 +000023 <li><a href="#format">Debugging information format</a>
Chris Lattnerbdfb3392004-01-05 05:06:33 +000024 <ol>
Jim Laskeycec12a52006-03-14 18:08:46 +000025 <li><a href="#debug_info_descriptors">Debug information descriptors</a>
Chris Lattnerbdfb3392004-01-05 05:06:33 +000026 <ul>
Jim Laskeycec12a52006-03-14 18:08:46 +000027 <li><a href="#format_compile_units">Compile unit descriptors</a></li>
28 <li><a href="#format_global_variables">Global variable descriptors</a></li>
29 <li><a href="#format_subprograms">Subprogram descriptors</a></li>
Jim Laskey3d11bee2006-03-15 19:10:52 +000030 <li><a href="#format_blocks">Block descriptors</a></li>
Jim Laskeycec12a52006-03-14 18:08:46 +000031 <li><a href="#format_basic_type">Basic type descriptors</a></li>
32 <li><a href="#format_derived_type">Derived type descriptors</a></li>
33 <li><a href="#format_composite_type">Composite type descriptors</a></li>
34 <li><a href="#format_subrange">Subrange descriptors</a></li>
35 <li><a href="#format_enumeration">Enumerator descriptors</a></li>
Jim Laskey383e0092006-03-23 17:54:33 +000036 <li><a href="#format_variables">Local variables</a></li>
Misha Brukman82873732004-05-12 19:21:57 +000037 </ul></li>
Jim Laskeycec12a52006-03-14 18:08:46 +000038 <li><a href="#format_common_intrinsics">Debugger intrinsic functions</a>
39 <ul>
40 <li><a href="#format_common_stoppoint">llvm.dbg.stoppoint</a></li>
41 <li><a href="#format_common_func_start">llvm.dbg.func.start</a></li>
42 <li><a href="#format_common_region_start">llvm.dbg.region.start</a></li>
43 <li><a href="#format_common_region_end">llvm.dbg.region.end</a></li>
44 <li><a href="#format_common_declare">llvm.dbg.declare</a></li>
45 </ul></li>
46 <li><a href="#format_common_stoppoints">Representing stopping points in the
47 source program</a></li>
Misha Brukman82873732004-05-12 19:21:57 +000048 </ol></li>
49 <li><a href="#ccxx_frontend">C/C++ front-end specific debug information</a>
Chris Lattnerbdfb3392004-01-05 05:06:33 +000050 <ol>
Jim Laskeycec12a52006-03-14 18:08:46 +000051 <li><a href="#ccxx_compile_units">C/C++ source file information</a></li>
52 <li><a href="#ccxx_global_variable">C/C++ global variable information</a></li>
53 <li><a href="#ccxx_subprogram">C/C++ function information</a></li>
54 <li><a href="#ccxx_basic_types">C/C++ basic types</a></li>
55 <li><a href="#ccxx_derived_types">C/C++ derived types</a></li>
56 <li><a href="#ccxx_composite_types">C/C++ struct/union types</a></li>
57 <li><a href="#ccxx_enumeration_types">C/C++ enumeration types</a></li>
Misha Brukman82873732004-05-12 19:21:57 +000058 </ol></li>
Chris Lattnerbdfb3392004-01-05 05:06:33 +000059</ul>
Misha Brukman82873732004-05-12 19:21:57 +000060</td>
Reid Spencerd3f876c2004-11-01 08:19:36 +000061<td class="right">
Misha Brukmane849a1a2004-05-12 21:26:16 +000062<img src="img/venusflytrap.jpg" alt="A leafy and green bug eater" width="247"
Misha Brukman82873732004-05-12 19:21:57 +000063height="369">
64</td>
Reid Spencerd3f876c2004-11-01 08:19:36 +000065</tr></table>
Misha Brukman82873732004-05-12 19:21:57 +000066
Chris Lattner7911ce22004-05-23 21:07:27 +000067<div class="doc_author">
Jim Laskeycec12a52006-03-14 18:08:46 +000068 <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>
Jim Laskeyc760a922007-03-14 19:32:21 +000069 and <a href="mailto:jlaskey@mac.com">Jim Laskey</a></p>
Chris Lattner7911ce22004-05-23 21:07:27 +000070</div>
71
Chris Lattnerbdfb3392004-01-05 05:06:33 +000072
73<!-- *********************************************************************** -->
Misha Brukman94218a72004-12-09 20:27:37 +000074<div class="doc_section"><a name="introduction">Introduction</a></div>
75<!-- *********************************************************************** -->
Chris Lattnerbdfb3392004-01-05 05:06:33 +000076
77<div class="doc_text">
78
79<p>This document is the central repository for all information pertaining to
Bill Wendling48839d92009-05-17 05:52:39 +000080 debug information in LLVM. It describes the <a href="#format">actual format
81 that the LLVM debug information</a> takes, which is useful for those
82 interested in creating front-ends or dealing directly with the information.
Chris Lattner8ad2f982009-07-18 21:47:15 +000083 Further, this document provides specific examples of what debug information
Bill Wendling48839d92009-05-17 05:52:39 +000084 for C/C++.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +000085
86</div>
87
88<!-- ======================================================================= -->
89<div class="doc_subsection">
90 <a name="phil">Philosophy behind LLVM debugging information</a>
91</div>
92
93<div class="doc_text">
94
Misha Brukman82873732004-05-12 19:21:57 +000095<p>The idea of the LLVM debugging information is to capture how the important
Bill Wendling48839d92009-05-17 05:52:39 +000096 pieces of the source-language's Abstract Syntax Tree map onto LLVM code.
97 Several design aspects have shaped the solution that appears here. The
98 important ones are:</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +000099
Misha Brukman82873732004-05-12 19:21:57 +0000100<ul>
Bill Wendling48839d92009-05-17 05:52:39 +0000101 <li>Debugging information should have very little impact on the rest of the
102 compiler. No transformations, analyses, or code generators should need to
103 be modified because of debugging information.</li>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000104
Bill Wendling48839d92009-05-17 05:52:39 +0000105 <li>LLVM optimizations should interact in <a href="#debugopt">well-defined and
106 easily described ways</a> with the debugging information.</li>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000107
Bill Wendling48839d92009-05-17 05:52:39 +0000108 <li>Because LLVM is designed to support arbitrary programming languages,
109 LLVM-to-LLVM tools should not need to know anything about the semantics of
110 the source-level-language.</li>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000111
Bill Wendling48839d92009-05-17 05:52:39 +0000112 <li>Source-level languages are often <b>widely</b> different from one another.
113 LLVM should not put any restrictions of the flavor of the source-language,
114 and the debugging information should work with any language.</li>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000115
Bill Wendling48839d92009-05-17 05:52:39 +0000116 <li>With code generator support, it should be possible to use an LLVM compiler
117 to compile a program to native machine code and standard debugging
118 formats. This allows compatibility with traditional machine-code level
119 debuggers, like GDB or DBX.</li>
Misha Brukman82873732004-05-12 19:21:57 +0000120</ul>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000121
Bill Wendling48839d92009-05-17 05:52:39 +0000122<p>The approach used by the LLVM implementation is to use a small set
123 of <a href="#format_common_intrinsics">intrinsic functions</a> to define a
124 mapping between LLVM program objects and the source-level objects. The
Devang Patele4b27562009-08-28 23:24:31 +0000125 description of the source-level program is maintained in LLVM metadata
126 in an <a href="#ccxx_frontend">implementation-defined format</a>
Bill Wendling48839d92009-05-17 05:52:39 +0000127 (the C/C++ front-end currently uses working draft 7 of
128 the <a href="http://www.eagercon.com/dwarf/dwarf3std.htm">DWARF 3
129 standard</a>).</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000130
Jim Laskeycec12a52006-03-14 18:08:46 +0000131<p>When a program is being debugged, a debugger interacts with the user and
Bill Wendling48839d92009-05-17 05:52:39 +0000132 turns the stored debug information into source-language specific information.
133 As such, a debugger must be aware of the source-language, and is thus tied to
134 a specific language or family of languages.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000135
136</div>
137
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000138<!-- ======================================================================= -->
139<div class="doc_subsection">
Jim Laskey383e0092006-03-23 17:54:33 +0000140 <a name="consumers">Debug information consumers</a>
141</div>
142
143<div class="doc_text">
Bill Wendling48839d92009-05-17 05:52:39 +0000144
Jim Laskey383e0092006-03-23 17:54:33 +0000145<p>The role of debug information is to provide meta information normally
Bill Wendling48839d92009-05-17 05:52:39 +0000146 stripped away during the compilation process. This meta information provides
147 an LLVM user a relationship between generated code and the original program
148 source code.</p>
Jim Laskey383e0092006-03-23 17:54:33 +0000149
150<p>Currently, debug information is consumed by the DwarfWriter to produce dwarf
Bill Wendling48839d92009-05-17 05:52:39 +0000151 information used by the gdb debugger. Other targets could use the same
152 information to produce stabs or other debug forms.</p>
Jim Laskey383e0092006-03-23 17:54:33 +0000153
154<p>It would also be reasonable to use debug information to feed profiling tools
Bill Wendling48839d92009-05-17 05:52:39 +0000155 for analysis of generated code, or, tools for reconstructing the original
156 source from generated code.</p>
Jim Laskey383e0092006-03-23 17:54:33 +0000157
158<p>TODO - expound a bit more.</p>
159
160</div>
161
162<!-- ======================================================================= -->
163<div class="doc_subsection">
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000164 <a name="debugopt">Debugging optimized code</a>
165</div>
166
167<div class="doc_text">
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000168
Misha Brukman82873732004-05-12 19:21:57 +0000169<p>An extremely high priority of LLVM debugging information is to make it
Bill Wendling48839d92009-05-17 05:52:39 +0000170 interact well with optimizations and analysis. In particular, the LLVM debug
171 information provides the following guarantees:</p>
Misha Brukman82873732004-05-12 19:21:57 +0000172
173<ul>
Bill Wendling48839d92009-05-17 05:52:39 +0000174 <li>LLVM debug information <b>always provides information to accurately read
175 the source-level state of the program</b>, regardless of which LLVM
176 optimizations have been run, and without any modification to the
177 optimizations themselves. However, some optimizations may impact the
178 ability to modify the current state of the program with a debugger, such
179 as setting program variables, or calling functions that have been
180 deleted.</li>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000181
Bill Wendling48839d92009-05-17 05:52:39 +0000182 <li>LLVM optimizations gracefully interact with debugging information. If
183 they are not aware of debug information, they are automatically disabled
184 as necessary in the cases that would invalidate the debug info. This
185 retains the LLVM features, making it easy to write new
186 transformations.</li>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000187
Bill Wendling48839d92009-05-17 05:52:39 +0000188 <li>As desired, LLVM optimizations can be upgraded to be aware of the LLVM
189 debugging information, allowing them to update the debugging information
190 as they perform aggressive optimizations. This means that, with effort,
191 the LLVM optimizers could optimize debug code just as well as non-debug
192 code.</li>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000193
Bill Wendling48839d92009-05-17 05:52:39 +0000194 <li>LLVM debug information does not prevent many important optimizations from
195 happening (for example inlining, basic block reordering/merging/cleanup,
196 tail duplication, etc), further reducing the amount of the compiler that
197 eventually is "aware" of debugging information.</li>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000198
Bill Wendling48839d92009-05-17 05:52:39 +0000199 <li>LLVM debug information is automatically optimized along with the rest of
200 the program, using existing facilities. For example, duplicate
201 information is automatically merged by the linker, and unused information
202 is automatically removed.</li>
Misha Brukman82873732004-05-12 19:21:57 +0000203</ul>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000204
Misha Brukman82873732004-05-12 19:21:57 +0000205<p>Basically, the debug information allows you to compile a program with
Bill Wendling48839d92009-05-17 05:52:39 +0000206 "<tt>-O0 -g</tt>" and get full debug information, allowing you to arbitrarily
207 modify the program as it executes from a debugger. Compiling a program with
208 "<tt>-O3 -g</tt>" gives you full debug information that is always available
209 and accurate for reading (e.g., you get accurate stack traces despite tail
210 call elimination and inlining), but you might lose the ability to modify the
211 program and call functions where were optimized out of the program, or
212 inlined away completely.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000213
Misha Brukman96e00812008-12-16 02:54:22 +0000214<p><a href="TestingGuide.html#quicktestsuite">LLVM test suite</a> provides a
Bill Wendling48839d92009-05-17 05:52:39 +0000215 framework to test optimizer's handling of debugging information. It can be
216 run like this:</p>
Devang Patela5c05aa2008-11-21 19:35:57 +0000217
218<div class="doc_code">
219<pre>
220% cd llvm/projects/test-suite/MultiSource/Benchmarks # or some other level
221% make TEST=dbgopt
222</pre>
223</div>
224
Bill Wendling48839d92009-05-17 05:52:39 +0000225<p>This will test impact of debugging information on optimization passes. If
226 debugging information influences optimization passes then it will be reported
227 as a failure. See <a href="TestingGuide.html">TestingGuide</a> for more
228 information on LLVM test infrastructure and how to run various tests.</p>
Devang Patela5c05aa2008-11-21 19:35:57 +0000229
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000230</div>
231
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000232<!-- *********************************************************************** -->
233<div class="doc_section">
Chris Lattner8ff75902004-01-06 05:31:32 +0000234 <a name="format">Debugging information format</a>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000235</div>
236<!-- *********************************************************************** -->
237
238<div class="doc_text">
239
240<p>LLVM debugging information has been carefully designed to make it possible
Bill Wendling48839d92009-05-17 05:52:39 +0000241 for the optimizer to optimize the program and debugging information without
242 necessarily having to know anything about debugging information. In
Devang Patele4b27562009-08-28 23:24:31 +0000243 particular, te use of metadadta avoids duplicated dubgging information from
244 the beginning, and the global dead code elimination pass automatically
245 deletes debugging information for a function if it decides to delete the
246 function. </p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000247
248<p>To do this, most of the debugging information (descriptors for types,
Bill Wendling48839d92009-05-17 05:52:39 +0000249 variables, functions, source files, etc) is inserted by the language
Devang Patele4b27562009-08-28 23:24:31 +0000250 front-end in the form of LLVM metadata. </p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000251
Jim Laskeycec12a52006-03-14 18:08:46 +0000252<p>Debug information is designed to be agnostic about the target debugger and
Bill Wendling48839d92009-05-17 05:52:39 +0000253 debugging information representation (e.g. DWARF/Stabs/etc). It uses a
Devang Patele4b27562009-08-28 23:24:31 +0000254 generic pass to decode the information that represents variables, types,
255 functions, namespaces, etc: this allows for arbitrary source-language
256 semantics and type-systems to be used, as long as there is a module
257 written for the target debugger to interpret the information. </p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000258
Misha Brukman82873732004-05-12 19:21:57 +0000259<p>To provide basic functionality, the LLVM debugger does have to make some
Bill Wendling48839d92009-05-17 05:52:39 +0000260 assumptions about the source-level language being debugged, though it keeps
261 these to a minimum. The only common features that the LLVM debugger assumes
262 exist are <a href="#format_compile_units">source files</a>,
263 and <a href="#format_global_variables">program objects</a>. These abstract
264 objects are used by a debugger to form stack traces, show information about
265 local variables, etc.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000266
267<p>This section of the documentation first describes the representation aspects
Bill Wendling48839d92009-05-17 05:52:39 +0000268 common to any source-language. The <a href="#ccxx_frontend">next section</a>
269 describes the data layout conventions used by the C and C++ front-ends.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000270
271</div>
272
273<!-- ======================================================================= -->
274<div class="doc_subsection">
Jim Laskeycec12a52006-03-14 18:08:46 +0000275 <a name="debug_info_descriptors">Debug information descriptors</a>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000276</div>
277
278<div class="doc_text">
Bill Wendling48839d92009-05-17 05:52:39 +0000279
Jim Laskeycec12a52006-03-14 18:08:46 +0000280<p>In consideration of the complexity and volume of debug information, LLVM
Devang Patele4b27562009-08-28 23:24:31 +0000281 provides a specification for well formed debug descriptors. </p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000282
Jim Laskeycec12a52006-03-14 18:08:46 +0000283<p>Consumers of LLVM debug information expect the descriptors for program
Bill Wendling48839d92009-05-17 05:52:39 +0000284 objects to start in a canonical format, but the descriptors can include
285 additional information appended at the end that is source-language
286 specific. All LLVM debugging information is versioned, allowing backwards
287 compatibility in the case that the core structures need to change in some
288 way. Also, all debugging information objects start with a tag to indicate
289 what type of object it is. The source-language is allowed to define its own
290 objects, by using unreserved tag numbers. We recommend using with tags in
Benjamin Kramer8040cd32009-10-12 14:46:08 +0000291 the range 0x1000 through 0x2000 (there is a defined enum DW_TAG_user_base =
Bill Wendling48839d92009-05-17 05:52:39 +0000292 0x1000.)</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000293
Devang Patele4b27562009-08-28 23:24:31 +0000294<p>The fields of debug descriptors used internally by LLVM
Bill Wendling48839d92009-05-17 05:52:39 +0000295 are restricted to only the simple data types <tt>int</tt>, <tt>uint</tt>,
Devang Patele4b27562009-08-28 23:24:31 +0000296 <tt>bool</tt>, <tt>float</tt>, <tt>double</tt>, <tt>mdstring</tt> and
297 <tt>mdnode</tt>. </p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000298
Bill Wendling48839d92009-05-17 05:52:39 +0000299<div class="doc_code">
Misha Brukman82873732004-05-12 19:21:57 +0000300<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000301!1 = metadata !{
Bill Wendling48839d92009-05-17 05:52:39 +0000302 uint, ;; A tag
303 ...
304}
Misha Brukman82873732004-05-12 19:21:57 +0000305</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000306</div>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000307
Jim Laskey7089f452006-06-16 13:14:03 +0000308<p><a name="LLVMDebugVersion">The first field of a descriptor is always an
Bill Wendling48839d92009-05-17 05:52:39 +0000309 <tt>uint</tt> containing a tag value identifying the content of the
310 descriptor. The remaining fields are specific to the descriptor. The values
311 of tags are loosely bound to the tag values of DWARF information entries.
312 However, that does not restrict the use of the information supplied to DWARF
313 targets. To facilitate versioning of debug information, the tag is augmented
Devang Patele4b27562009-08-28 23:24:31 +0000314 with the current debug version (LLVMDebugVersion = 7 << 16 or 0x70000 or
315 458752.)</a></p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000316
Jim Laskey7089f452006-06-16 13:14:03 +0000317<p>The details of the various descriptors follow.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000318
319</div>
320
321<!-- ======================================================================= -->
322<div class="doc_subsubsection">
Jim Laskeycec12a52006-03-14 18:08:46 +0000323 <a name="format_compile_units">Compile unit descriptors</a>
324</div>
325
326<div class="doc_text">
327
Bill Wendling48839d92009-05-17 05:52:39 +0000328<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000329<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000330!0 = metadata !{
331 i32, ;; Tag = 17 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a>
332 ;; (DW_TAG_compile_unit)
333 i32, ;; Unused field.
334 i32, ;; DWARF language identifier (ex. DW_LANG_C89)
335 metadata, ;; Source file name
336 metadata, ;; Source file directory (includes trailing slash)
337 metadata ;; Producer (ex. "4.0.1 LLVM (LLVM research group)")
338 i1, ;; True if this is a main compile unit.
339 i1, ;; True if this is optimized.
340 metadata, ;; Flags
341 i32 ;; Runtime version
Bill Wendling48839d92009-05-17 05:52:39 +0000342}
Jim Laskeycec12a52006-03-14 18:08:46 +0000343</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000344</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000345
Bill Wendling48839d92009-05-17 05:52:39 +0000346<p>These descriptors contain a source language ID for the file (we use the DWARF
347 3.0 ID numbers, such as <tt>DW_LANG_C89</tt>, <tt>DW_LANG_C_plus_plus</tt>,
348 <tt>DW_LANG_Cobol74</tt>, etc), three strings describing the filename,
349 working directory of the compiler, and an identifier string for the compiler
350 that produced it.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000351
Bill Wendling48839d92009-05-17 05:52:39 +0000352<p>Compile unit descriptors provide the root context for objects declared in a
353 specific source file. Global variables and top level functions would be
354 defined using this context. Compile unit descriptors also provide context
355 for source line correspondence.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000356
Bill Wendling48839d92009-05-17 05:52:39 +0000357<p>Each input file is encoded as a separate compile unit in LLVM debugging
358 information output. However, many target specific tool chains prefer to
359 encode only one compile unit in an object file. In this situation, the LLVM
360 code generator will include debugging information entities in the compile
361 unit that is marked as main compile unit. The code generator accepts maximum
362 one main compile unit per module. If a module does not contain any main
363 compile unit then the code generator will emit multiple compile units in the
364 output object file.</p>
365
Jim Laskeycec12a52006-03-14 18:08:46 +0000366</div>
367
368<!-- ======================================================================= -->
369<div class="doc_subsubsection">
370 <a name="format_global_variables">Global variable descriptors</a>
371</div>
372
373<div class="doc_text">
374
Bill Wendling48839d92009-05-17 05:52:39 +0000375<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000376<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000377!1 = metadata !{
378 i32, ;; Tag = 52 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a>
379 ;; (DW_TAG_variable)
380 i32, ;; Unused field.
381 metadata, ;; Reference to context descriptor
382 metadata, ;; Name
383 metadata, ;; Display name (fully qualified C++ name)
384 metadata, ;; MIPS linkage name (for C++)
385 metadata, ;; Reference to compile unit where defined
386 i32, ;; Line number where defined
387 metadata, ;; Reference to type descriptor
388 i1, ;; True if the global is local to compile unit (static)
389 i1, ;; True if the global is defined in the compile unit (not extern)
390 { }* ;; Reference to the global variable
Bill Wendling48839d92009-05-17 05:52:39 +0000391}
Jim Laskeycec12a52006-03-14 18:08:46 +0000392</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000393</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000394
395<p>These descriptors provide debug information about globals variables. The
396provide details such as name, type and where the variable is defined.</p>
397
398</div>
399
400<!-- ======================================================================= -->
401<div class="doc_subsubsection">
402 <a name="format_subprograms">Subprogram descriptors</a>
403</div>
404
405<div class="doc_text">
406
Bill Wendling48839d92009-05-17 05:52:39 +0000407<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000408<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000409!2 = metadata !{
410 i32, ;; Tag = 46 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a>
411 ;; (DW_TAG_subprogram)
412 i32, ;; Unused field.
413 metadata, ;; Reference to context descriptor
414 metadata, ;; Name
415 metadata, ;; Display name (fully qualified C++ name)
416 metadata, ;; MIPS linkage name (for C++)
417 metadata, ;; Reference to compile unit where defined
418 i32, ;; Line number where defined
419 metadata, ;; Reference to type descriptor
420 i1, ;; True if the global is local to compile unit (static)
421 i1 ;; True if the global is defined in the compile unit (not extern)
Bill Wendling48839d92009-05-17 05:52:39 +0000422}
Jim Laskeycec12a52006-03-14 18:08:46 +0000423</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000424</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000425
426<p>These descriptors provide debug information about functions, methods and
Bill Wendling48839d92009-05-17 05:52:39 +0000427 subprograms. They provide details such as name, return types and the source
428 location where the subprogram is defined.</p>
Jim Laskey3d11bee2006-03-15 19:10:52 +0000429
430</div>
Bill Wendling48839d92009-05-17 05:52:39 +0000431
Jim Laskey3d11bee2006-03-15 19:10:52 +0000432<!-- ======================================================================= -->
433<div class="doc_subsubsection">
434 <a name="format_blocks">Block descriptors</a>
435</div>
436
437<div class="doc_text">
438
Bill Wendling48839d92009-05-17 05:52:39 +0000439<div class="doc_code">
Jim Laskey3d11bee2006-03-15 19:10:52 +0000440<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000441!3 = metadata !{
442 i32, ;; Tag = 13 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_lexical_block)
443 metadata ;; Reference to context descriptor
Bill Wendling48839d92009-05-17 05:52:39 +0000444}
Jim Laskey3d11bee2006-03-15 19:10:52 +0000445</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000446</div>
Jim Laskey3d11bee2006-03-15 19:10:52 +0000447
448<p>These descriptors provide debug information about nested blocks within a
Bill Wendling48839d92009-05-17 05:52:39 +0000449 subprogram. The array of member descriptors is used to define local
450 variables and deeper nested blocks.</p>
Jim Laskey3d11bee2006-03-15 19:10:52 +0000451
Jim Laskeycec12a52006-03-14 18:08:46 +0000452</div>
453
454<!-- ======================================================================= -->
455<div class="doc_subsubsection">
456 <a name="format_basic_type">Basic type descriptors</a>
457</div>
458
459<div class="doc_text">
460
Bill Wendling48839d92009-05-17 05:52:39 +0000461<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000462<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000463!4 = metadata !{
464 i32, ;; Tag = 36 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a>
465 ;; (DW_TAG_base_type)
466 metadata, ;; Reference to context (typically a compile unit)
467 metadata, ;; Name (may be "" for anonymous types)
468 metadata, ;; Reference to compile unit where defined (may be NULL)
469 i32, ;; Line number where defined (may be 0)
470 i64, ;; Size in bits
471 i64, ;; Alignment in bits
472 i64, ;; Offset in bits
473 i32, ;; Flags
474 i32 ;; DWARF type encoding
Bill Wendling48839d92009-05-17 05:52:39 +0000475}
Jim Laskeycec12a52006-03-14 18:08:46 +0000476</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000477</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000478
479<p>These descriptors define primitive types used in the code. Example int, bool
Bill Wendling48839d92009-05-17 05:52:39 +0000480 and float. The context provides the scope of the type, which is usually the
481 top level. Since basic types are not usually user defined the compile unit
482 and line number can be left as NULL and 0. The size, alignment and offset
483 are expressed in bits and can be 64 bit values. The alignment is used to
484 round the offset when embedded in a
485 <a href="#format_composite_type">composite type</a> (example to keep float
486 doubles on 64 bit boundaries.) The offset is the bit offset if embedded in
487 a <a href="#format_composite_type">composite type</a>.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000488
489<p>The type encoding provides the details of the type. The values are typically
Bill Wendling48839d92009-05-17 05:52:39 +0000490 one of the following:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000491
Bill Wendling48839d92009-05-17 05:52:39 +0000492<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000493<pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000494DW_ATE_address = 1
495DW_ATE_boolean = 2
496DW_ATE_float = 4
497DW_ATE_signed = 5
498DW_ATE_signed_char = 6
499DW_ATE_unsigned = 7
500DW_ATE_unsigned_char = 8
Jim Laskeycec12a52006-03-14 18:08:46 +0000501</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000502</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000503
504</div>
505
506<!-- ======================================================================= -->
507<div class="doc_subsubsection">
508 <a name="format_derived_type">Derived type descriptors</a>
509</div>
510
511<div class="doc_text">
512
Bill Wendling48839d92009-05-17 05:52:39 +0000513<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000514<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000515!5 = metadata !{
516 i32, ;; Tag (see below)
517 metadata, ;; Reference to context
518 metadata, ;; Name (may be "" for anonymous types)
519 metadata, ;; Reference to compile unit where defined (may be NULL)
520 i32, ;; Line number where defined (may be 0)
521 i32, ;; Size in bits
522 i32, ;; Alignment in bits
523 i32, ;; Offset in bits
524 metadata ;; Reference to type derived from
Bill Wendling48839d92009-05-17 05:52:39 +0000525}
Jim Laskeycec12a52006-03-14 18:08:46 +0000526</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000527</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000528
529<p>These descriptors are used to define types derived from other types. The
530value of the tag varies depending on the meaning. The following are possible
Misha Brukman96e00812008-12-16 02:54:22 +0000531tag values:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000532
Bill Wendling48839d92009-05-17 05:52:39 +0000533<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000534<pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000535DW_TAG_formal_parameter = 5
536DW_TAG_member = 13
537DW_TAG_pointer_type = 15
538DW_TAG_reference_type = 16
539DW_TAG_typedef = 22
540DW_TAG_const_type = 38
541DW_TAG_volatile_type = 53
542DW_TAG_restrict_type = 55
Jim Laskeycec12a52006-03-14 18:08:46 +0000543</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000544</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000545
Bill Wendling48839d92009-05-17 05:52:39 +0000546<p><tt>DW_TAG_member</tt> is used to define a member of
547 a <a href="#format_composite_type">composite type</a>
548 or <a href="#format_subprograms">subprogram</a>. The type of the member is
549 the <a href="#format_derived_type">derived
550 type</a>. <tt>DW_TAG_formal_parameter</tt> is used to define a member which
551 is a formal argument of a subprogram.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000552
Bill Wendling48839d92009-05-17 05:52:39 +0000553<p><tt>DW_TAG_typedef</tt> is used to provide a name for the derived type.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000554
Bill Wendling48839d92009-05-17 05:52:39 +0000555<p><tt>DW_TAG_pointer_type</tt>,<tt>DW_TAG_reference_type</tt>,
556 <tt>DW_TAG_const_type</tt>, <tt>DW_TAG_volatile_type</tt>
557 and <tt>DW_TAG_restrict_type</tt> are used to qualify
558 the <a href="#format_derived_type">derived type</a>. </p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000559
560<p><a href="#format_derived_type">Derived type</a> location can be determined
Bill Wendling48839d92009-05-17 05:52:39 +0000561 from the compile unit and line number. The size, alignment and offset are
562 expressed in bits and can be 64 bit values. The alignment is used to round
563 the offset when embedded in a <a href="#format_composite_type">composite
564 type</a> (example to keep float doubles on 64 bit boundaries.) The offset is
565 the bit offset if embedded in a <a href="#format_composite_type">composite
566 type</a>.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000567
568<p>Note that the <tt>void *</tt> type is expressed as a
Bill Wendling48839d92009-05-17 05:52:39 +0000569 <tt>llvm.dbg.derivedtype.type</tt> with tag of <tt>DW_TAG_pointer_type</tt>
570 and <tt>NULL</tt> derived type.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000571
572</div>
573
574<!-- ======================================================================= -->
575<div class="doc_subsubsection">
576 <a name="format_composite_type">Composite type descriptors</a>
577</div>
578
579<div class="doc_text">
580
Bill Wendling48839d92009-05-17 05:52:39 +0000581<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000582<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000583!6 = metadata !{
584 i32, ;; Tag (see below)
585 metadata, ;; Reference to context
586 metadata, ;; Name (may be "" for anonymous types)
587 metadata, ;; Reference to compile unit where defined (may be NULL)
588 i32, ;; Line number where defined (may be 0)
589 i64, ;; Size in bits
590 i64, ;; Alignment in bits
591 i64, ;; Offset in bits
592 i32, ;; Flags
593 metadata, ;; Reference to type derived from
594 metadata, ;; Reference to array of member descriptors
595 i32 ;; Runtime languages
Bill Wendling48839d92009-05-17 05:52:39 +0000596}
Jim Laskeycec12a52006-03-14 18:08:46 +0000597</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000598</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000599
600<p>These descriptors are used to define types that are composed of 0 or more
601elements. The value of the tag varies depending on the meaning. The following
Misha Brukman96e00812008-12-16 02:54:22 +0000602are possible tag values:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000603
Bill Wendling48839d92009-05-17 05:52:39 +0000604<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000605<pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000606DW_TAG_array_type = 1
607DW_TAG_enumeration_type = 4
608DW_TAG_structure_type = 19
609DW_TAG_union_type = 23
610DW_TAG_vector_type = 259
Bruno Cardoso Lopesd80ddc02009-05-29 17:08:57 +0000611DW_TAG_subroutine_type = 21
612DW_TAG_inheritance = 28
Jim Laskeycec12a52006-03-14 18:08:46 +0000613</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000614</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000615
Jim Laskeyf8a01a92006-06-15 20:51:43 +0000616<p>The vector flag indicates that an array type is a native packed vector.</p>
617
Jim Laskey7089f452006-06-16 13:14:03 +0000618<p>The members of array types (tag = <tt>DW_TAG_array_type</tt>) or vector types
Bill Wendling48839d92009-05-17 05:52:39 +0000619 (tag = <tt>DW_TAG_vector_type</tt>) are <a href="#format_subrange">subrange
620 descriptors</a>, each representing the range of subscripts at that level of
621 indexing.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000622
623<p>The members of enumeration types (tag = <tt>DW_TAG_enumeration_type</tt>) are
Bill Wendling48839d92009-05-17 05:52:39 +0000624 <a href="#format_enumeration">enumerator descriptors</a>, each representing
625 the definition of enumeration value for the set.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000626
627<p>The members of structure (tag = <tt>DW_TAG_structure_type</tt>) or union (tag
Bill Wendling48839d92009-05-17 05:52:39 +0000628 = <tt>DW_TAG_union_type</tt>) types are any one of
629 the <a href="#format_basic_type">basic</a>,
630 <a href="#format_derived_type">derived</a>
631 or <a href="#format_composite_type">composite</a> type descriptors, each
632 representing a field member of the structure or union.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000633
Jim Laskey4a9df242006-08-21 21:21:06 +0000634<p>For C++ classes (tag = <tt>DW_TAG_structure_type</tt>), member descriptors
Bill Wendling48839d92009-05-17 05:52:39 +0000635 provide information about base classes, static members and member
636 functions. If a member is a <a href="#format_derived_type">derived type
637 descriptor</a> and has a tag of <tt>DW_TAG_inheritance</tt>, then the type
638 represents a base class. If the member of is
639 a <a href="#format_global_variables">global variable descriptor</a> then it
640 represents a static member. And, if the member is
641 a <a href="#format_subprograms">subprogram descriptor</a> then it represents
642 a member function. For static members and member
643 functions, <tt>getName()</tt> returns the members link or the C++ mangled
644 name. <tt>getDisplayName()</tt> the simplied version of the name.</p>
Jim Laskey4a9df242006-08-21 21:21:06 +0000645
Bill Wendling48839d92009-05-17 05:52:39 +0000646<p>The first member of subroutine (tag = <tt>DW_TAG_subroutine_type</tt>) type
647 elements is the return type for the subroutine. The remaining elements are
648 the formal arguments to the subroutine.</p>
Jim Laskey094ee722006-06-20 21:13:20 +0000649
Jim Laskeycec12a52006-03-14 18:08:46 +0000650<p><a href="#format_composite_type">Composite type</a> location can be
Bill Wendling48839d92009-05-17 05:52:39 +0000651 determined from the compile unit and line number. The size, alignment and
652 offset are expressed in bits and can be 64 bit values. The alignment is used
653 to round the offset when embedded in
654 a <a href="#format_composite_type">composite type</a> (as an example, to keep
655 float doubles on 64 bit boundaries.) The offset is the bit offset if embedded
656 in a <a href="#format_composite_type">composite type</a>.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000657
658</div>
659
660<!-- ======================================================================= -->
661<div class="doc_subsubsection">
662 <a name="format_subrange">Subrange descriptors</a>
663</div>
664
665<div class="doc_text">
666
Bill Wendling48839d92009-05-17 05:52:39 +0000667<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000668<pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000669%<a href="#format_subrange">llvm.dbg.subrange.type</a> = type {
670 i32, ;; Tag = 33 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_subrange_type)
671 i64, ;; Low value
672 i64 ;; High value
673}
Jim Laskeycec12a52006-03-14 18:08:46 +0000674</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000675</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000676
677<p>These descriptors are used to define ranges of array subscripts for an array
Bill Wendling48839d92009-05-17 05:52:39 +0000678 <a href="#format_composite_type">composite type</a>. The low value defines
679 the lower bounds typically zero for C/C++. The high value is the upper
680 bounds. Values are 64 bit. High - low + 1 is the size of the array. If low
681 == high the array will be unbounded.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000682
683</div>
684
685<!-- ======================================================================= -->
686<div class="doc_subsubsection">
687 <a name="format_enumeration">Enumerator descriptors</a>
688</div>
689
690<div class="doc_text">
691
Bill Wendling48839d92009-05-17 05:52:39 +0000692<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +0000693<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000694!6 = metadata !{
695 i32, ;; Tag = 40 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a>
696 ;; (DW_TAG_enumerator)
697 metadata, ;; Name
698 i64 ;; Value
Bill Wendling48839d92009-05-17 05:52:39 +0000699}
Jim Laskeycec12a52006-03-14 18:08:46 +0000700</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000701</div>
Jim Laskeycec12a52006-03-14 18:08:46 +0000702
Bill Wendling48839d92009-05-17 05:52:39 +0000703<p>These descriptors are used to define members of an
704 enumeration <a href="#format_composite_type">composite type</a>, it
705 associates the name to the value.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000706
707</div>
708
709<!-- ======================================================================= -->
Jim Laskey383e0092006-03-23 17:54:33 +0000710<div class="doc_subsubsection">
711 <a name="format_variables">Local variables</a>
712</div>
713
714<div class="doc_text">
Bill Wendling48839d92009-05-17 05:52:39 +0000715
716<div class="doc_code">
Jim Laskey383e0092006-03-23 17:54:33 +0000717<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000718!7 = metadata !{
719 i32, ;; Tag (see below)
720 metadata, ;; Context
721 metadata, ;; Name
722 metadata, ;; Reference to compile unit where defined
723 i32, ;; Line number where defined
724 metadata ;; Type descriptor
Bill Wendling48839d92009-05-17 05:52:39 +0000725}
Jim Laskey383e0092006-03-23 17:54:33 +0000726</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000727</div>
Jim Laskey383e0092006-03-23 17:54:33 +0000728
729<p>These descriptors are used to define variables local to a sub program. The
Bill Wendling48839d92009-05-17 05:52:39 +0000730 value of the tag depends on the usage of the variable:</p>
Jim Laskey383e0092006-03-23 17:54:33 +0000731
Bill Wendling48839d92009-05-17 05:52:39 +0000732<div class="doc_code">
Jim Laskey383e0092006-03-23 17:54:33 +0000733<pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000734DW_TAG_auto_variable = 256
735DW_TAG_arg_variable = 257
736DW_TAG_return_variable = 258
Jim Laskey383e0092006-03-23 17:54:33 +0000737</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000738</div>
Jim Laskey383e0092006-03-23 17:54:33 +0000739
740<p>An auto variable is any variable declared in the body of the function. An
Bill Wendling48839d92009-05-17 05:52:39 +0000741 argument variable is any variable that appears as a formal argument to the
742 function. A return variable is used to track the result of a function and
743 has no source correspondent.</p>
Jim Laskey383e0092006-03-23 17:54:33 +0000744
Jim Laskey2d395d92006-03-24 09:20:27 +0000745<p>The context is either the subprogram or block where the variable is defined.
Bill Wendling48839d92009-05-17 05:52:39 +0000746 Name the source variable name. Compile unit and line indicate where the
747 variable was defined. Type descriptor defines the declared type of the
748 variable.</p>
Jim Laskey383e0092006-03-23 17:54:33 +0000749
750</div>
751
752<!-- ======================================================================= -->
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000753<div class="doc_subsection">
Jim Laskeycec12a52006-03-14 18:08:46 +0000754 <a name="format_common_intrinsics">Debugger intrinsic functions</a>
755</div>
756
757<div class="doc_text">
758
759<p>LLVM uses several intrinsic functions (name prefixed with "llvm.dbg") to
Bill Wendling48839d92009-05-17 05:52:39 +0000760 provide debug information at various points in generated code.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000761
762</div>
763
764<!-- ======================================================================= -->
765<div class="doc_subsubsection">
766 <a name="format_common_stoppoint">llvm.dbg.stoppoint</a>
767</div>
768
769<div class="doc_text">
770<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000771 void %<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint, uint, metadata)
Jim Laskeycec12a52006-03-14 18:08:46 +0000772</pre>
773
774<p>This intrinsic is used to provide correspondence between the source file and
Bill Wendling48839d92009-05-17 05:52:39 +0000775 the generated code. The first argument is the line number (base 1), second
776 argument is the column number (0 if unknown) and the third argument the
Devang Patele4b27562009-08-28 23:24:31 +0000777 source <tt>%<a href="#format_compile_units">llvm.dbg.compile_unit</a>.
778 Code following a call to this intrinsic will
Bill Wendling48839d92009-05-17 05:52:39 +0000779 have been defined in close proximity of the line, column and file. This
780 information holds until the next call
781 to <tt>%<a href="#format_common_stoppoint">lvm.dbg.stoppoint</a></tt>.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000782
783</div>
784
785<!-- ======================================================================= -->
786<div class="doc_subsubsection">
787 <a name="format_common_func_start">llvm.dbg.func.start</a>
788</div>
789
790<div class="doc_text">
791<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000792 void %<a href="#format_common_func_start">llvm.dbg.func.start</a>( metadata )
Jim Laskeycec12a52006-03-14 18:08:46 +0000793</pre>
794
Bill Wendling48839d92009-05-17 05:52:39 +0000795<p>This intrinsic is used to link the debug information
796 in <tt>%<a href="#format_subprograms">llvm.dbg.subprogram</a></tt> to the
797 function. It defines the beginning of the function's declarative region
798 (scope). It also implies a call to
799 %<tt><a href="#format_common_stoppoint">llvm.dbg.stoppoint</a></tt> which
800 defines a source line "stop point". The intrinsic should be called early in
801 the function after the all the alloca instructions. It should be paired off
802 with a closing
803 <tt>%<a href="#format_common_region_end">llvm.dbg.region.end</a></tt>.
804 The function's single argument is
805 the <tt>%<a href="#format_subprograms">llvm.dbg.subprogram.type</a></tt>.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000806
807</div>
808
809<!-- ======================================================================= -->
810<div class="doc_subsubsection">
811 <a name="format_common_region_start">llvm.dbg.region.start</a>
812</div>
813
814<div class="doc_text">
815<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000816 void %<a href="#format_common_region_start">llvm.dbg.region.start</a>( metadata )
Jim Laskeycec12a52006-03-14 18:08:46 +0000817</pre>
818
819<p>This intrinsic is used to define the beginning of a declarative scope (ex.
Bill Wendling48839d92009-05-17 05:52:39 +0000820 block) for local language elements. It should be paired off with a closing
821 <tt>%<a href="#format_common_region_end">llvm.dbg.region.end</a></tt>. The
822 function's single argument is
823 the <tt>%<a href="#format_blocks">llvm.dbg.block</a></tt> which is
824 starting.</p>
Jim Laskey383e0092006-03-23 17:54:33 +0000825
Jim Laskeycec12a52006-03-14 18:08:46 +0000826
827</div>
828
829<!-- ======================================================================= -->
830<div class="doc_subsubsection">
831 <a name="format_common_region_end">llvm.dbg.region.end</a>
832</div>
833
834<div class="doc_text">
835<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000836 void %<a href="#format_common_region_end">llvm.dbg.region.end</a>( metadata )
Jim Laskeycec12a52006-03-14 18:08:46 +0000837</pre>
838
839<p>This intrinsic is used to define the end of a declarative scope (ex. block)
Bill Wendling48839d92009-05-17 05:52:39 +0000840 for local language elements. It should be paired off with an
841 opening <tt>%<a href="#format_common_region_start">llvm.dbg.region.start</a></tt>
842 or <tt>%<a href="#format_common_func_start">llvm.dbg.func.start</a></tt>.
843 The function's single argument is either
844 the <tt>%<a href="#format_blocks">llvm.dbg.block</a></tt> or
845 the <tt>%<a href="#format_subprograms">llvm.dbg.subprogram.type</a></tt>
846 which is ending.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000847
848</div>
849
850<!-- ======================================================================= -->
851<div class="doc_subsubsection">
852 <a name="format_common_declare">llvm.dbg.declare</a>
853</div>
854
855<div class="doc_text">
856<pre>
Devang Patele4b27562009-08-28 23:24:31 +0000857 void %<a href="#format_common_declare">llvm.dbg.declare</a>( { } *, metadata )
Jim Laskeycec12a52006-03-14 18:08:46 +0000858</pre>
859
Jim Laskey2d395d92006-03-24 09:20:27 +0000860<p>This intrinsic provides information about a local element (ex. variable.) The
Bill Wendling48839d92009-05-17 05:52:39 +0000861 first argument is the alloca for the variable, cast to a <tt>{ }*</tt>. The
862 second argument is
863 the <tt>%<a href="#format_variables">llvm.dbg.variable</a></tt> containing
Devang Patele4b27562009-08-28 23:24:31 +0000864 the description of the variable. </p>
Jim Laskeycec12a52006-03-14 18:08:46 +0000865
866</div>
867
868<!-- ======================================================================= -->
869<div class="doc_subsection">
870 <a name="format_common_stoppoints">
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000871 Representing stopping points in the source program
872 </a>
873</div>
874
875<div class="doc_text">
876
877<p>LLVM debugger "stop points" are a key part of the debugging representation
Bill Wendling48839d92009-05-17 05:52:39 +0000878 that allows the LLVM to maintain simple semantics
879 for <a href="#debugopt">debugging optimized code</a>. The basic idea is that
880 the front-end inserts calls to
881 the <a href="#format_common_stoppoint">%<tt>llvm.dbg.stoppoint</tt></a>
882 intrinsic function at every point in the program where a debugger should be
883 able to inspect the program (these correspond to places a debugger stops when
884 you "<tt>step</tt>" through it). The front-end can choose to place these as
885 fine-grained as it would like (for example, before every subexpression
886 evaluated), but it is recommended to only put them after every source
887 statement that includes executable code.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000888
Misha Brukman82873732004-05-12 19:21:57 +0000889<p>Using calls to this intrinsic function to demark legal points for the
Bill Wendling48839d92009-05-17 05:52:39 +0000890 debugger to inspect the program automatically disables any optimizations that
891 could potentially confuse debugging information. To
892 non-debug-information-aware transformations, these calls simply look like
893 calls to an external function, which they must assume to do anything
894 (including reading or writing to any part of reachable memory). On the other
895 hand, it does not impact many optimizations, such as code motion of
896 non-trapping instructions, nor does it impact optimization of subexpressions,
897 code duplication transformations, or basic-block reordering
898 transformations.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000899
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000900</div>
901
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000902<!-- ======================================================================= -->
903<div class="doc_subsection">
Chris Lattner8ff75902004-01-06 05:31:32 +0000904 <a name="format_common_lifetime">Object lifetimes and scoping</a>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000905</div>
906
907<div class="doc_text">
Misha Brukman82873732004-05-12 19:21:57 +0000908<p>In many languages, the local variables in functions can have their lifetime
Bill Wendling48839d92009-05-17 05:52:39 +0000909 or scope limited to a subset of a function. In the C family of languages,
910 for example, variables are only live (readable and writable) within the
911 source block that they are defined in. In functional languages, values are
912 only readable after they have been defined. Though this is a very obvious
913 concept, it is also non-trivial to model in LLVM, because it has no notion of
914 scoping in this sense, and does not want to be tied to a language's scoping
915 rules.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000916
Misha Brukman82873732004-05-12 19:21:57 +0000917<p>In order to handle this, the LLVM debug format uses the notion of "regions"
Bill Wendling48839d92009-05-17 05:52:39 +0000918 of a function, delineated by calls to intrinsic functions. These intrinsic
919 functions define new regions of the program and indicate when the region
920 lifetime expires. Consider the following C fragment, for example:</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000921
Bill Wendling48839d92009-05-17 05:52:39 +0000922<div class="doc_code">
Misha Brukman82873732004-05-12 19:21:57 +0000923<pre>
Chris Lattnerbdfb3392004-01-05 05:06:33 +00009241. void foo() {
9252. int X = ...;
9263. int Y = ...;
9274. {
9285. int Z = ...;
9296. ...
9307. }
9318. ...
9329. }
Misha Brukman82873732004-05-12 19:21:57 +0000933</pre>
Bill Wendling48839d92009-05-17 05:52:39 +0000934</div>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000935
Jim Laskeycec12a52006-03-14 18:08:46 +0000936<p>Compiled to LLVM, this function would be represented like this:</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000937
Bill Wendling48839d92009-05-17 05:52:39 +0000938<div class="doc_code">
Misha Brukman82873732004-05-12 19:21:57 +0000939<pre>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000940void %foo() {
Jim Laskeycec12a52006-03-14 18:08:46 +0000941entry:
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000942 %X = alloca int
943 %Y = alloca int
944 %Z = alloca int
Jim Laskeycec12a52006-03-14 18:08:46 +0000945
946 ...
947
Devang Patele4b27562009-08-28 23:24:31 +0000948 call void @<a href="#format_common_func_start">llvm.dbg.func.start</a>( metadata !0)
Jim Laskeycec12a52006-03-14 18:08:46 +0000949
Devang Patele4b27562009-08-28 23:24:31 +0000950 call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 2, uint 2, metadata !1)
Jim Laskeycec12a52006-03-14 18:08:46 +0000951
Bill Wendling48839d92009-05-17 05:52:39 +0000952 call void @<a href="#format_common_declare">llvm.dbg.declare</a>({}* %X, ...)
953 call void @<a href="#format_common_declare">llvm.dbg.declare</a>({}* %Y, ...)
Jim Laskeycec12a52006-03-14 18:08:46 +0000954
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000955 <i>;; Evaluate expression on line 2, assigning to X.</i>
Jim Laskeycec12a52006-03-14 18:08:46 +0000956
Devang Patele4b27562009-08-28 23:24:31 +0000957 call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 3, uint 2, metadata !1)
Jim Laskeycec12a52006-03-14 18:08:46 +0000958
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000959 <i>;; Evaluate expression on line 3, assigning to Y.</i>
Jim Laskeycec12a52006-03-14 18:08:46 +0000960
Bill Wendling48839d92009-05-17 05:52:39 +0000961 call void @<a href="#format_common_stoppoint">llvm.region.start</a>()
Devang Patele4b27562009-08-28 23:24:31 +0000962 call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 5, uint 4, metadata !1)
Bill Wendling48839d92009-05-17 05:52:39 +0000963 call void @<a href="#format_common_declare">llvm.dbg.declare</a>({}* %X, ...)
Jim Laskeycec12a52006-03-14 18:08:46 +0000964
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000965 <i>;; Evaluate expression on line 5, assigning to Z.</i>
Jim Laskeycec12a52006-03-14 18:08:46 +0000966
Devang Patele4b27562009-08-28 23:24:31 +0000967 call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 7, uint 2, metadata !1)
Bill Wendling48839d92009-05-17 05:52:39 +0000968 call void @<a href="#format_common_region_end">llvm.region.end</a>()
Jim Laskeycec12a52006-03-14 18:08:46 +0000969
Devang Patele4b27562009-08-28 23:24:31 +0000970 call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 9, uint 2, metadata !1)
Jim Laskeycec12a52006-03-14 18:08:46 +0000971
Bill Wendling48839d92009-05-17 05:52:39 +0000972 call void @<a href="#format_common_region_end">llvm.region.end</a>()
Jim Laskeycec12a52006-03-14 18:08:46 +0000973
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000974 ret void
975}
Misha Brukman82873732004-05-12 19:21:57 +0000976</pre>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000977</div>
978
Bill Wendling48839d92009-05-17 05:52:39 +0000979<p>This example illustrates a few important details about the LLVM debugging
980 information. In particular, it shows how the various intrinsics are applied
981 together to allow a debugger to analyze the relationship between statements,
982 variable definitions, and the code used to implement the function.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +0000983
Bill Wendling48839d92009-05-17 05:52:39 +0000984<p>The first
985 intrinsic <tt>%<a href="#format_common_func_start">llvm.dbg.func.start</a></tt>
986 provides a link with the <a href="#format_subprograms">subprogram
987 descriptor</a> containing the details of this function. This call also
988 defines the beginning of the function region, bounded by
989 the <tt>%<a href="#format_common_region_end">llvm.region.end</a></tt> at the
990 end of the function. This region is used to bracket the lifetime of
991 variables declared within. For a function, this outer region defines a new
992 stack frame whose lifetime ends when the region is ended.</p>
993
994<p>It is possible to define inner regions for short term variables by using the
995 %<a href="#format_common_stoppoint"><tt>llvm.region.start</tt></a>
996 and <a href="#format_common_region_end"><tt>%llvm.region.end</tt></a> to
997 bound a region. The inner region in this example would be for the block
998 containing the declaration of Z.</p>
999
1000<p>Using regions to represent the boundaries of source-level functions allow
1001 LLVM interprocedural optimizations to arbitrarily modify LLVM functions
1002 without having to worry about breaking mapping information between the LLVM
1003 code and the and source-level program. In particular, the inliner requires
1004 no modification to support inlining with debugging information: there is no
1005 explicit correlation drawn between LLVM functions and their source-level
1006 counterparts (note however, that if the inliner inlines all instances of a
1007 non-strong-linkage function into its caller that it will not be possible for
1008 the user to manually invoke the inlined function from a debugger).</p>
1009
1010<p>Once the function has been defined,
1011 the <a href="#format_common_stoppoint"><tt>stopping point</tt></a>
1012 corresponding to line #2 (column #2) of the function is encountered. At this
1013 point in the function, <b>no</b> local variables are live. As lines 2 and 3
1014 of the example are executed, their variable definitions are introduced into
1015 the program using
1016 %<a href="#format_common_declare"><tt>llvm.dbg.declare</tt></a>, without the
1017 need to specify a new region. These variables do not require new regions to
1018 be introduced because they go out of scope at the same point in the program:
1019 line 9.</p>
1020
1021<p>In contrast, the <tt>Z</tt> variable goes out of scope at a different time,
1022 on line 7. For this reason, it is defined within the inner region, which
1023 kills the availability of <tt>Z</tt> before the code for line 8 is executed.
1024 In this way, regions can support arbitrary source-language scoping rules, as
1025 long as they can only be nested (ie, one scope cannot partially overlap with
1026 a part of another scope).</p>
1027
1028<p>It is worth noting that this scoping mechanism is used to control scoping of
1029 all declarations, not just variable declarations. For example, the scope of
1030 a C++ using declaration is controlled with this and could change how name
1031 lookup is performed.</p>
1032
1033</div>
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001034
1035<!-- *********************************************************************** -->
1036<div class="doc_section">
Chris Lattner8ff75902004-01-06 05:31:32 +00001037 <a name="ccxx_frontend">C/C++ front-end specific debug information</a>
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001038</div>
Misha Brukman94218a72004-12-09 20:27:37 +00001039<!-- *********************************************************************** -->
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001040
1041<div class="doc_text">
1042
Misha Brukman82873732004-05-12 19:21:57 +00001043<p>The C and C++ front-ends represent information about the program in a format
Bill Wendling48839d92009-05-17 05:52:39 +00001044 that is effectively identical
1045 to <a href="http://www.eagercon.com/dwarf/dwarf3std.htm">DWARF 3.0</a> in
1046 terms of information content. This allows code generators to trivially
1047 support native debuggers by generating standard dwarf information, and
1048 contains enough information for non-dwarf targets to translate it as
1049 needed.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001050
Jim Laskeycec12a52006-03-14 18:08:46 +00001051<p>This section describes the forms used to represent C and C++ programs. Other
Bill Wendling48839d92009-05-17 05:52:39 +00001052 languages could pattern themselves after this (which itself is tuned to
1053 representing programs in the same way that DWARF 3 does), or they could
1054 choose to provide completely different forms if they don't fit into the DWARF
1055 model. As support for debugging information gets added to the various LLVM
1056 source-language front-ends, the information used should be documented
1057 here.</p>
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001058
Jim Laskeycec12a52006-03-14 18:08:46 +00001059<p>The following sections provide examples of various C/C++ constructs and the
Bill Wendling48839d92009-05-17 05:52:39 +00001060 debug information that would best describe those constructs.</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001061
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001062</div>
1063
1064<!-- ======================================================================= -->
1065<div class="doc_subsection">
Jim Laskeycec12a52006-03-14 18:08:46 +00001066 <a name="ccxx_compile_units">C/C++ source file information</a>
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001067</div>
1068
1069<div class="doc_text">
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001070
Bill Wendling48839d92009-05-17 05:52:39 +00001071<p>Given the source files <tt>MySource.cpp</tt> and <tt>MyHeader.h</tt> located
1072 in the directory <tt>/Users/mine/sources</tt>, the following code:</p>
Chris Lattner8ff75902004-01-06 05:31:32 +00001073
Bill Wendling48839d92009-05-17 05:52:39 +00001074<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001075<pre>
1076#include "MyHeader.h"
Chris Lattner8ff75902004-01-06 05:31:32 +00001077
Jim Laskeycec12a52006-03-14 18:08:46 +00001078int main(int argc, char *argv[]) {
1079 return 0;
1080}
1081</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001082</div>
Chris Lattner8ff75902004-01-06 05:31:32 +00001083
Misha Brukman96e00812008-12-16 02:54:22 +00001084<p>a C/C++ front-end would generate the following descriptors:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001085
Bill Wendling48839d92009-05-17 05:52:39 +00001086<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001087<pre>
1088...
1089;;
Jim Laskeycec12a52006-03-14 18:08:46 +00001090;; Define the compile unit for the source file "/Users/mine/sources/MySource.cpp".
1091;;
Devang Patele4b27562009-08-28 23:24:31 +00001092!3 = metadata !{
1093 i32 458769, ;; Tag
1094 i32 0, ;; Unused
1095 i32 4, ;; Language Id
1096 metadata !"MySource.cpp",
1097 metadata !"/Users/mine/sources",
1098 metadata !"4.2.1 (Based on Apple Inc. build 5649) (LLVM build 00)",
1099 i1 true, ;; Main Compile Unit
1100 i1 false, ;; Optimized compile unit
1101 metadata !"", ;; Compiler flags
1102 i32 0} ;; Runtime version
1103
Jim Laskeycec12a52006-03-14 18:08:46 +00001104;;
1105;; Define the compile unit for the header file "/Users/mine/sources/MyHeader.h".
1106;;
Devang Patele4b27562009-08-28 23:24:31 +00001107!1 = metadata !{
1108 i32 458769, ;; Tag
1109 i32 0, ;; Unused
1110 i32 4, ;; Language Id
1111 metadata !"MyHeader.h",
1112 metadata !"/Users/mine/sources",
1113 metadata !"4.2.1 (Based on Apple Inc. build 5649) (LLVM build 00)",
1114 i1 false, ;; Main Compile Unit
1115 i1 false, ;; Optimized compile unit
1116 metadata !"", ;; Compiler flags
1117 i32 0} ;; Runtime version
Jim Laskeycec12a52006-03-14 18:08:46 +00001118
Jim Laskeycec12a52006-03-14 18:08:46 +00001119...
1120</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001121</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001122
Chris Lattner8ff75902004-01-06 05:31:32 +00001123</div>
1124
1125<!-- ======================================================================= -->
1126<div class="doc_subsection">
Jim Laskeycec12a52006-03-14 18:08:46 +00001127 <a name="ccxx_global_variable">C/C++ global variable information</a>
Chris Lattner8ff75902004-01-06 05:31:32 +00001128</div>
1129
1130<div class="doc_text">
Jim Laskeycec12a52006-03-14 18:08:46 +00001131
Misha Brukman96e00812008-12-16 02:54:22 +00001132<p>Given an integer global variable declared as follows:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001133
Bill Wendling48839d92009-05-17 05:52:39 +00001134<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001135<pre>
1136int MyGlobal = 100;
1137</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001138</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001139
Misha Brukman96e00812008-12-16 02:54:22 +00001140<p>a C/C++ front-end would generate the following descriptors:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001141
Bill Wendling48839d92009-05-17 05:52:39 +00001142<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001143<pre>
1144;;
Jim Laskeycec12a52006-03-14 18:08:46 +00001145;; Define the global itself.
1146;;
1147%MyGlobal = global int 100
1148...
1149;;
Devang Patele4b27562009-08-28 23:24:31 +00001150;; List of debug info of globals
Jim Laskeycec12a52006-03-14 18:08:46 +00001151;;
Devang Patele4b27562009-08-28 23:24:31 +00001152!llvm.dbg.gv = !{!0}
Jim Laskeycec12a52006-03-14 18:08:46 +00001153
1154;;
1155;; Define the global variable descriptor. Note the reference to the global
1156;; variable anchor and the global variable itself.
1157;;
Devang Patele4b27562009-08-28 23:24:31 +00001158!0 = metadata !{
1159 i32 458804, ;; Tag
1160 i32 0, ;; Unused
1161 metadata !1, ;; Context
1162 metadata !"MyGlobal", ;; Name
1163 metadata !"MyGlobal", ;; Display Name
1164 metadata !"MyGlobal", ;; Linkage Name
1165 metadata !1, ;; Compile Unit
1166 i32 1, ;; Line Number
1167 metadata !2, ;; Type
1168 i1 false, ;; Is a local variable
1169 i1 true, ;; Is this a definition
1170 i32* @MyGlobal ;; The global variable
1171}
1172
Jim Laskeycec12a52006-03-14 18:08:46 +00001173;;
1174;; Define the basic type of 32 bit signed integer. Note that since int is an
1175;; intrinsic type the source file is NULL and line 0.
1176;;
Devang Patele4b27562009-08-28 23:24:31 +00001177!2 = metadata !{
1178 i32 458788, ;; Tag
1179 metadata !1, ;; Context
1180 metadata !"int", ;; Name
1181 metadata !1, ;; Compile Unit
1182 i32 0, ;; Line number
1183 i64 32, ;; Size in Bits
1184 i64 32, ;; Align in Bits
1185 i64 0, ;; Offset in Bits
1186 i32 0, ;; Flags
1187 i32 5 ;; Encoding
1188}
Jim Laskeycec12a52006-03-14 18:08:46 +00001189
Jim Laskeycec12a52006-03-14 18:08:46 +00001190</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001191</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001192
Chris Lattner8ff75902004-01-06 05:31:32 +00001193</div>
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001194
Jim Laskeycec12a52006-03-14 18:08:46 +00001195<!-- ======================================================================= -->
1196<div class="doc_subsection">
1197 <a name="ccxx_subprogram">C/C++ function information</a>
1198</div>
1199
1200<div class="doc_text">
1201
Misha Brukman96e00812008-12-16 02:54:22 +00001202<p>Given a function declared as follows:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001203
Bill Wendling48839d92009-05-17 05:52:39 +00001204<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001205<pre>
1206int main(int argc, char *argv[]) {
1207 return 0;
1208}
1209</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001210</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001211
Misha Brukman96e00812008-12-16 02:54:22 +00001212<p>a C/C++ front-end would generate the following descriptors:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001213
Bill Wendling48839d92009-05-17 05:52:39 +00001214<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001215<pre>
1216;;
Jim Laskeycec12a52006-03-14 18:08:46 +00001217;; Define the anchor for subprograms. Note that the second field of the
1218;; anchor is 46, which is the same as the tag for subprograms
1219;; (46 = DW_TAG_subprogram.)
1220;;
Devang Patele4b27562009-08-28 23:24:31 +00001221!0 = metadata !{
1222 i32 458798, ;; Tag
1223 i32 0, ;; Unused
1224 metadata !1, ;; Context
1225 metadata !"main", ;; Name
1226 metadata !"main", ;; Display name
1227 metadata !"main", ;; Linkage name
1228 metadata !1, ;; Compile unit
1229 i32 1, ;; Line number
1230 metadata !2, ;; Type
1231 i1 false, ;; Is local
1232 i1 true ;; Is definition
1233}
Jim Laskeycec12a52006-03-14 18:08:46 +00001234;;
1235;; Define the subprogram itself.
1236;;
Devang Patele4b27562009-08-28 23:24:31 +00001237define i32 @main(i32 %argc, i8** %argv) {
Jim Laskeycec12a52006-03-14 18:08:46 +00001238...
1239}
1240</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001241</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001242
1243</div>
1244
1245<!-- ======================================================================= -->
1246<div class="doc_subsection">
1247 <a name="ccxx_basic_types">C/C++ basic types</a>
1248</div>
1249
1250<div class="doc_text">
1251
Misha Brukman96e00812008-12-16 02:54:22 +00001252<p>The following are the basic type descriptors for C/C++ core types:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001253
1254</div>
1255
1256<!-- ======================================================================= -->
1257<div class="doc_subsubsection">
1258 <a name="ccxx_basic_type_bool">bool</a>
1259</div>
1260
1261<div class="doc_text">
1262
Bill Wendling48839d92009-05-17 05:52:39 +00001263<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001264<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001265!2 = metadata !{
1266 i32 458788, ;; Tag
1267 metadata !1, ;; Context
1268 metadata !"bool", ;; Name
1269 metadata !1, ;; Compile Unit
1270 i32 0, ;; Line number
1271 i64 8, ;; Size in Bits
1272 i64 8, ;; Align in Bits
1273 i64 0, ;; Offset in Bits
1274 i32 0, ;; Flags
1275 i32 2 ;; Encoding
1276}
Jim Laskeycec12a52006-03-14 18:08:46 +00001277</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001278</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001279
1280</div>
1281
1282<!-- ======================================================================= -->
1283<div class="doc_subsubsection">
1284 <a name="ccxx_basic_char">char</a>
1285</div>
1286
1287<div class="doc_text">
1288
Bill Wendling48839d92009-05-17 05:52:39 +00001289<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001290<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001291!2 = metadata !{
1292 i32 458788, ;; Tag
1293 metadata !1, ;; Context
1294 metadata !"char", ;; Name
1295 metadata !1, ;; Compile Unit
1296 i32 0, ;; Line number
1297 i64 8, ;; Size in Bits
1298 i64 8, ;; Align in Bits
1299 i64 0, ;; Offset in Bits
1300 i32 0, ;; Flags
1301 i32 6 ;; Encoding
1302}
Jim Laskeycec12a52006-03-14 18:08:46 +00001303</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001304</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001305
1306</div>
1307
1308<!-- ======================================================================= -->
1309<div class="doc_subsubsection">
1310 <a name="ccxx_basic_unsigned_char">unsigned char</a>
1311</div>
1312
1313<div class="doc_text">
1314
Bill Wendling48839d92009-05-17 05:52:39 +00001315<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001316<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001317!2 = metadata !{
1318 i32 458788, ;; Tag
1319 metadata !1, ;; Context
1320 metadata !"unsigned char",
1321 metadata !1, ;; Compile Unit
1322 i32 0, ;; Line number
1323 i64 8, ;; Size in Bits
1324 i64 8, ;; Align in Bits
1325 i64 0, ;; Offset in Bits
1326 i32 0, ;; Flags
1327 i32 8 ;; Encoding
1328}
Jim Laskeycec12a52006-03-14 18:08:46 +00001329</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001330</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001331
1332</div>
1333
1334<!-- ======================================================================= -->
1335<div class="doc_subsubsection">
1336 <a name="ccxx_basic_short">short</a>
1337</div>
1338
1339<div class="doc_text">
1340
Bill Wendling48839d92009-05-17 05:52:39 +00001341<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001342<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001343!2 = metadata !{
1344 i32 458788, ;; Tag
1345 metadata !1, ;; Context
1346 metadata !"short int",
1347 metadata !1, ;; Compile Unit
1348 i32 0, ;; Line number
1349 i64 16, ;; Size in Bits
1350 i64 16, ;; Align in Bits
1351 i64 0, ;; Offset in Bits
1352 i32 0, ;; Flags
1353 i32 5 ;; Encoding
1354}
Jim Laskeycec12a52006-03-14 18:08:46 +00001355</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001356</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001357
1358</div>
1359
1360<!-- ======================================================================= -->
1361<div class="doc_subsubsection">
1362 <a name="ccxx_basic_unsigned_short">unsigned short</a>
1363</div>
1364
1365<div class="doc_text">
1366
Bill Wendling48839d92009-05-17 05:52:39 +00001367<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001368<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001369!2 = metadata !{
1370 i32 458788, ;; Tag
1371 metadata !1, ;; Context
1372 metadata !"short unsigned int",
1373 metadata !1, ;; Compile Unit
1374 i32 0, ;; Line number
1375 i64 16, ;; Size in Bits
1376 i64 16, ;; Align in Bits
1377 i64 0, ;; Offset in Bits
1378 i32 0, ;; Flags
1379 i32 7 ;; Encoding
1380}
Jim Laskeycec12a52006-03-14 18:08:46 +00001381</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001382</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001383
1384</div>
1385
1386<!-- ======================================================================= -->
1387<div class="doc_subsubsection">
1388 <a name="ccxx_basic_int">int</a>
1389</div>
1390
1391<div class="doc_text">
1392
Bill Wendling48839d92009-05-17 05:52:39 +00001393<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001394<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001395!2 = metadata !{
1396 i32 458788, ;; Tag
1397 metadata !1, ;; Context
1398 metadata !"int", ;; Name
1399 metadata !1, ;; Compile Unit
1400 i32 0, ;; Line number
1401 i64 32, ;; Size in Bits
1402 i64 32, ;; Align in Bits
1403 i64 0, ;; Offset in Bits
1404 i32 0, ;; Flags
1405 i32 5 ;; Encoding
1406}
Bill Wendling48839d92009-05-17 05:52:39 +00001407</pre></div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001408
1409</div>
1410
1411<!-- ======================================================================= -->
1412<div class="doc_subsubsection">
1413 <a name="ccxx_basic_unsigned_int">unsigned int</a>
1414</div>
1415
1416<div class="doc_text">
1417
Bill Wendling48839d92009-05-17 05:52:39 +00001418<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001419<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001420!2 = metadata !{
1421 i32 458788, ;; Tag
1422 metadata !1, ;; Context
1423 metadata !"unsigned int",
1424 metadata !1, ;; Compile Unit
1425 i32 0, ;; Line number
1426 i64 32, ;; Size in Bits
1427 i64 32, ;; Align in Bits
1428 i64 0, ;; Offset in Bits
1429 i32 0, ;; Flags
1430 i32 7 ;; Encoding
1431}
Jim Laskeycec12a52006-03-14 18:08:46 +00001432</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001433</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001434
1435</div>
1436
1437<!-- ======================================================================= -->
1438<div class="doc_subsubsection">
1439 <a name="ccxx_basic_long_long">long long</a>
1440</div>
1441
1442<div class="doc_text">
1443
Bill Wendling48839d92009-05-17 05:52:39 +00001444<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001445<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001446!2 = metadata !{
1447 i32 458788, ;; Tag
1448 metadata !1, ;; Context
1449 metadata !"long long int",
1450 metadata !1, ;; Compile Unit
1451 i32 0, ;; Line number
1452 i64 64, ;; Size in Bits
1453 i64 64, ;; Align in Bits
1454 i64 0, ;; Offset in Bits
1455 i32 0, ;; Flags
1456 i32 5 ;; Encoding
1457}
Jim Laskeycec12a52006-03-14 18:08:46 +00001458</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001459</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001460
1461</div>
1462
1463<!-- ======================================================================= -->
1464<div class="doc_subsubsection">
1465 <a name="ccxx_basic_unsigned_long_long">unsigned long long</a>
1466</div>
1467
1468<div class="doc_text">
1469
Bill Wendling48839d92009-05-17 05:52:39 +00001470<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001471<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001472!2 = metadata !{
1473 i32 458788, ;; Tag
1474 metadata !1, ;; Context
1475 metadata !"long long unsigned int",
1476 metadata !1, ;; Compile Unit
1477 i32 0, ;; Line number
1478 i64 64, ;; Size in Bits
1479 i64 64, ;; Align in Bits
1480 i64 0, ;; Offset in Bits
1481 i32 0, ;; Flags
1482 i32 7 ;; Encoding
1483}
Jim Laskeycec12a52006-03-14 18:08:46 +00001484</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001485</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001486
1487</div>
1488
1489<!-- ======================================================================= -->
1490<div class="doc_subsubsection">
1491 <a name="ccxx_basic_float">float</a>
1492</div>
1493
1494<div class="doc_text">
1495
Bill Wendling48839d92009-05-17 05:52:39 +00001496<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001497<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001498!2 = metadata !{
1499 i32 458788, ;; Tag
1500 metadata !1, ;; Context
1501 metadata !"float",
1502 metadata !1, ;; Compile Unit
1503 i32 0, ;; Line number
1504 i64 32, ;; Size in Bits
1505 i64 32, ;; Align in Bits
1506 i64 0, ;; Offset in Bits
1507 i32 0, ;; Flags
1508 i32 4 ;; Encoding
1509}
Jim Laskeycec12a52006-03-14 18:08:46 +00001510</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001511</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001512
1513</div>
1514
1515<!-- ======================================================================= -->
1516<div class="doc_subsubsection">
1517 <a name="ccxx_basic_double">double</a>
1518</div>
1519
1520<div class="doc_text">
1521
Bill Wendling48839d92009-05-17 05:52:39 +00001522<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001523<pre>
Devang Patele4b27562009-08-28 23:24:31 +00001524!2 = metadata !{
1525 i32 458788, ;; Tag
1526 metadata !1, ;; Context
1527 metadata !"double",;; Name
1528 metadata !1, ;; Compile Unit
1529 i32 0, ;; Line number
1530 i64 64, ;; Size in Bits
1531 i64 64, ;; Align in Bits
1532 i64 0, ;; Offset in Bits
1533 i32 0, ;; Flags
1534 i32 4 ;; Encoding
1535}
Jim Laskeycec12a52006-03-14 18:08:46 +00001536</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001537</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001538
1539</div>
1540
1541<!-- ======================================================================= -->
1542<div class="doc_subsection">
1543 <a name="ccxx_derived_types">C/C++ derived types</a>
1544</div>
1545
1546<div class="doc_text">
1547
Misha Brukman96e00812008-12-16 02:54:22 +00001548<p>Given the following as an example of C/C++ derived type:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001549
Bill Wendling48839d92009-05-17 05:52:39 +00001550<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001551<pre>
1552typedef const int *IntPtr;
1553</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001554</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001555
Misha Brukman96e00812008-12-16 02:54:22 +00001556<p>a C/C++ front-end would generate the following descriptors:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001557
Bill Wendling48839d92009-05-17 05:52:39 +00001558<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001559<pre>
1560;;
1561;; Define the typedef "IntPtr".
1562;;
Devang Patele4b27562009-08-28 23:24:31 +00001563!2 = metadata !{
1564 i32 458774, ;; Tag
1565 metadata !1, ;; Context
1566 metadata !"IntPtr", ;; Name
1567 metadata !3, ;; Compile unit
1568 i32 0, ;; Line number
1569 i64 0, ;; Size in bits
1570 i64 0, ;; Align in bits
1571 i64 0, ;; Offset in bits
1572 i32 0, ;; Flags
1573 metadata !4 ;; Derived From type
1574}
Jim Laskeycec12a52006-03-14 18:08:46 +00001575
1576;;
1577;; Define the pointer type.
1578;;
Devang Patele4b27562009-08-28 23:24:31 +00001579!4 = metadata !{
1580 i32 458767, ;; Tag
1581 metadata !1, ;; Context
1582 metadata !"", ;; Name
1583 metadata !1, ;; Compile unit
1584 i32 0, ;; Line number
1585 i64 64, ;; Size in bits
1586 i64 64, ;; Align in bits
1587 i64 0, ;; Offset in bits
1588 i32 0, ;; Flags
1589 metadata !5 ;; Derived From type
1590}
Jim Laskeycec12a52006-03-14 18:08:46 +00001591;;
1592;; Define the const type.
1593;;
Devang Patele4b27562009-08-28 23:24:31 +00001594!5 = metadata !{
1595 i32 458790, ;; Tag
1596 metadata !1, ;; Context
1597 metadata !"", ;; Name
1598 metadata !1, ;; Compile unit
1599 i32 0, ;; Line number
1600 i64 32, ;; Size in bits
1601 i64 32, ;; Align in bits
1602 i64 0, ;; Offset in bits
1603 i32 0, ;; Flags
1604 metadata !6 ;; Derived From type
1605}
Jim Laskeycec12a52006-03-14 18:08:46 +00001606;;
1607;; Define the int type.
1608;;
Devang Patele4b27562009-08-28 23:24:31 +00001609!6 = metadata !{
1610 i32 458788, ;; Tag
1611 metadata !1, ;; Context
1612 metadata !"int", ;; Name
1613 metadata !1, ;; Compile unit
1614 i32 0, ;; Line number
1615 i64 32, ;; Size in bits
1616 i64 32, ;; Align in bits
1617 i64 0, ;; Offset in bits
1618 i32 0, ;; Flags
1619 5 ;; Encoding
1620}
Jim Laskeycec12a52006-03-14 18:08:46 +00001621</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001622</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001623
1624</div>
1625
1626<!-- ======================================================================= -->
1627<div class="doc_subsection">
1628 <a name="ccxx_composite_types">C/C++ struct/union types</a>
1629</div>
1630
1631<div class="doc_text">
1632
Misha Brukman96e00812008-12-16 02:54:22 +00001633<p>Given the following as an example of C/C++ struct type:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001634
Bill Wendling48839d92009-05-17 05:52:39 +00001635<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001636<pre>
1637struct Color {
1638 unsigned Red;
1639 unsigned Green;
1640 unsigned Blue;
1641};
1642</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001643</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001644
Misha Brukman96e00812008-12-16 02:54:22 +00001645<p>a C/C++ front-end would generate the following descriptors:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001646
Bill Wendling48839d92009-05-17 05:52:39 +00001647<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001648<pre>
1649;;
1650;; Define basic type for unsigned int.
1651;;
Devang Patele4b27562009-08-28 23:24:31 +00001652!5 = metadata !{
1653 i32 458788, ;; Tag
1654 metadata !1, ;; Context
1655 metadata !"unsigned int",
1656 metadata !1, ;; Compile Unit
1657 i32 0, ;; Line number
1658 i64 32, ;; Size in Bits
1659 i64 32, ;; Align in Bits
1660 i64 0, ;; Offset in Bits
1661 i32 0, ;; Flags
1662 i32 7 ;; Encoding
1663}
Jim Laskeycec12a52006-03-14 18:08:46 +00001664;;
1665;; Define composite type for struct Color.
1666;;
Devang Patele4b27562009-08-28 23:24:31 +00001667!2 = metadata !{
1668 i32 458771, ;; Tag
1669 metadata !1, ;; Context
1670 metadata !"Color", ;; Name
1671 metadata !1, ;; Compile unit
1672 i32 1, ;; Line number
1673 i64 96, ;; Size in bits
1674 i64 32, ;; Align in bits
1675 i64 0, ;; Offset in bits
1676 i32 0, ;; Flags
1677 null, ;; Derived From
1678 metadata !3, ;; Elements
1679 i32 0 ;; Runtime Language
1680}
Jim Laskeycec12a52006-03-14 18:08:46 +00001681
1682;;
1683;; Define the Red field.
1684;;
Devang Patele4b27562009-08-28 23:24:31 +00001685!4 = metadata !{
1686 i32 458765, ;; Tag
1687 metadata !1, ;; Context
1688 metadata !"Red", ;; Name
1689 metadata !1, ;; Compile Unit
1690 i32 2, ;; Line number
1691 i64 32, ;; Size in bits
1692 i64 32, ;; Align in bits
1693 i64 0, ;; Offset in bits
1694 i32 0, ;; Flags
1695 metadata !5 ;; Derived From type
1696}
Jim Laskeycec12a52006-03-14 18:08:46 +00001697
1698;;
1699;; Define the Green field.
1700;;
Devang Patele4b27562009-08-28 23:24:31 +00001701!6 = metadata !{
1702 i32 458765, ;; Tag
1703 metadata !1, ;; Context
1704 metadata !"Green", ;; Name
1705 metadata !1, ;; Compile Unit
1706 i32 3, ;; Line number
1707 i64 32, ;; Size in bits
1708 i64 32, ;; Align in bits
1709 i64 32, ;; Offset in bits
1710 i32 0, ;; Flags
1711 metadata !5 ;; Derived From type
1712}
Jim Laskeycec12a52006-03-14 18:08:46 +00001713
1714;;
1715;; Define the Blue field.
1716;;
Devang Patele4b27562009-08-28 23:24:31 +00001717!7 = metadata !{
1718 i32 458765, ;; Tag
1719 metadata !1, ;; Context
1720 metadata !"Blue", ;; Name
1721 metadata !1, ;; Compile Unit
1722 i32 4, ;; Line number
1723 i64 32, ;; Size in bits
1724 i64 32, ;; Align in bits
1725 i64 64, ;; Offset in bits
1726 i32 0, ;; Flags
1727 metadata !5 ;; Derived From type
1728}
Jim Laskeycec12a52006-03-14 18:08:46 +00001729
1730;;
1731;; Define the array of fields used by the composite type Color.
1732;;
Devang Patele4b27562009-08-28 23:24:31 +00001733!3 = metadata !{metadata !4, metadata !6, metadata !7}
Jim Laskeycec12a52006-03-14 18:08:46 +00001734</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001735</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001736
1737</div>
1738
1739<!-- ======================================================================= -->
1740<div class="doc_subsection">
1741 <a name="ccxx_enumeration_types">C/C++ enumeration types</a>
1742</div>
1743
1744<div class="doc_text">
1745
Misha Brukman96e00812008-12-16 02:54:22 +00001746<p>Given the following as an example of C/C++ enumeration type:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001747
Bill Wendling48839d92009-05-17 05:52:39 +00001748<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001749<pre>
1750enum Trees {
1751 Spruce = 100,
1752 Oak = 200,
1753 Maple = 300
1754};
1755</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001756</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001757
Misha Brukman96e00812008-12-16 02:54:22 +00001758<p>a C/C++ front-end would generate the following descriptors:</p>
Jim Laskeycec12a52006-03-14 18:08:46 +00001759
Bill Wendling48839d92009-05-17 05:52:39 +00001760<div class="doc_code">
Jim Laskeycec12a52006-03-14 18:08:46 +00001761<pre>
1762;;
1763;; Define composite type for enum Trees
1764;;
Devang Patele4b27562009-08-28 23:24:31 +00001765!2 = metadata !{
1766 i32 458756, ;; Tag
1767 metadata !1, ;; Context
1768 metadata !"Trees", ;; Name
1769 metadata !1, ;; Compile unit
1770 i32 1, ;; Line number
1771 i64 32, ;; Size in bits
1772 i64 32, ;; Align in bits
1773 i64 0, ;; Offset in bits
1774 i32 0, ;; Flags
1775 null, ;; Derived From type
1776 metadata !3, ;; Elements
1777 i32 0 ;; Runtime language
1778}
Devang Patel2a610c72009-08-25 05:24:07 +00001779
Devang Patel82459882009-08-26 05:01:18 +00001780;;
1781;; Define the array of enumerators used by composite type Trees.
1782;;
Devang Patele4b27562009-08-28 23:24:31 +00001783!3 = metadata !{metadata !4, metadata !5, metadata !6}
1784
1785;;
1786;; Define Spruce enumerator.
1787;;
1788!4 = metadata !{i32 458792, metadata !"Spruce", i64 100}
1789
1790;;
1791;; Define Oak enumerator.
1792;;
1793!5 = metadata !{i32 458792, metadata !"Oak", i64 200}
1794
1795;;
1796;; Define Maple enumerator.
1797;;
1798!6 = metadata !{i32 458792, metadata !"Maple", i64 300}
1799
Jim Laskeycec12a52006-03-14 18:08:46 +00001800</pre>
Bill Wendling48839d92009-05-17 05:52:39 +00001801</div>
Jim Laskeycec12a52006-03-14 18:08:46 +00001802
1803</div>
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001804
1805<!-- *********************************************************************** -->
Misha Brukman82873732004-05-12 19:21:57 +00001806
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001807<hr>
Misha Brukman82873732004-05-12 19:21:57 +00001808<address>
1809 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +00001810 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
Misha Brukman82873732004-05-12 19:21:57 +00001811 <a href="http://validator.w3.org/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +00001812 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
Misha Brukman82873732004-05-12 19:21:57 +00001813
1814 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
Reid Spencer05fe4b02006-03-14 05:39:39 +00001815 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001816 Last modified: $Date$
Misha Brukman82873732004-05-12 19:21:57 +00001817</address>
Chris Lattnerbdfb3392004-01-05 05:06:33 +00001818
1819</body>
1820</html>