[llvm-commits] CVS: llvm/docs/FAQ.html

Chris Lattner lattner at cs.uiuc.edu
Mon Mar 29 13:45:25 PST 2004


Changes in directory llvm/docs:

FAQ.html updated: 1.19 -> 1.20

---
Log message:

Add a faq entry


---
Diffs of the changes:  (+40 -1)

Index: llvm/docs/FAQ.html
diff -u llvm/docs/FAQ.html:1.19 llvm/docs/FAQ.html:1.20
--- llvm/docs/FAQ.html:1.19	Fri Mar 12 12:20:15 2004
+++ llvm/docs/FAQ.html	Mon Mar 29 13:14:35 2004
@@ -71,6 +71,9 @@
      <li>What is this <tt>__main()</tt> call that gets inserted into
          <tt>main()</tt>?</li>
      <li>Where did all of my code go??</li>
+     <li>What is this <tt>llvm.global_ctors</tt> and
+          <tt>_GLOBAL__I__tmp_webcompile...</tt> stuff that happens when I
+          #include <iostream>?</li>
   </ol>
   </li>
 </ol>
@@ -449,6 +452,42 @@
 </p>
 </div>
 
+<!--=========================================================================-->
+
+<div class="question"><p>
+What is this <tt>llvm.global_ctors</tt> and <tt>_GLOBAL__I__tmp_webcompile...</tt> stuff that happens when I #include <iostream>?
+</p></div>
+
+<div class="answer">
+<p>
+If you #include the <iostream> header into a C++ translation unit, the
+file will probably use the <tt>std::cin</tt>/<tt>std::cout</tt>/... global
+objects.  However, C++ does not guarantee an order of initialization between
+static objects in different translation units, so if a static ctor/dtor in your
+.cpp file used <tt>std::cout</tt>, for example, the object would not necessarily
+be automatically initialized before your use.
+</p>
+
+<p>
+To make <tt>std::cout</tt> and friends work correctly in these scenarios, the
+STL that we use declares a static object that gets created in every translation
+unit that includes <iostream>.  This object has a static constructor and
+destructor that initializes and destroys the global iostream objects before they
+could possibly be used in the file.  The code that you see in the .ll file
+corresponds to the constructor and destructor registration code.
+</p>
+
+<p>
+If you would like to make it easier to <b>understand</b> the LLVM code generated
+by the compiler in the demo page, consider using printf instead of iostreams to
+print values.
+</p>
+</div>
+
+
+     <li>
+
+
 <!-- *********************************************************************** -->
 <!-- *********************************************************************** -->
 
@@ -456,7 +495,7 @@
 <div class="doc_footer">
   <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a>
   <br>
-  Last modified: $Date: 2004/03/12 18:20:15 $
+  Last modified: $Date: 2004/03/29 19:14:35 $
 </div>
 
 </body>





More information about the llvm-commits mailing list