[llvm-commits] [llvm-gcc-4.2] r93821 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-debug.cpp llvm-debug.h llvm-internal.h

Stuart Hastings stuart at apple.com
Mon Jan 18 16:22:51 PST 2010


Author: stuart
Date: Mon Jan 18 18:22:51 2010
New Revision: 93821

URL: http://llvm.org/viewvc/llvm-project?rev=93821&view=rev
Log:
Fixes for most of the issues raised by Chris and Duncan in r93727.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-debug.h
    llvm-gcc-4.2/trunk/gcc/llvm-internal.h

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=93821&r1=93820&r2=93821&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Jan 18 18:22:51 2010
@@ -421,7 +421,7 @@
 // variables in every lexical BLOCK(), this facilitates allocating the
 // scoped variables in their blocks, and the rest at the outermost
 // scope of the function.
-void TreeToLLVM::setLexicalBlockDepths(tree_node *t, treeset &s, unsigned level) {
+void TreeToLLVM::setLexicalBlockDepths(tree t, treeset &s, unsigned level) {
   tree bstep, step;
   switch (TREE_CODE(t)) {
   default:
@@ -594,7 +594,8 @@
   treeset block_declared_vars;
   // Set the BLOCK_NUMBER()s to the depth of each lexical block.
   setLexicalBlockDepths(FnDecl, block_declared_vars, 1);
-  seen_blocks.clear();
+
+  SeenBlocks.clear();
 
   if (TheDebugInfo)
     TheDebugInfo->EmitFunctionStart(FnDecl, Fn, Builder.GetInsertBlock());
@@ -688,8 +689,10 @@
   // As it turns out, not all temporaries are associated with blocks.  For those
   // that aren't, emit them now.
   for (tree t = cfun->unexpanded_var_list; t; t = TREE_CHAIN(t)) {
+    // If this variable hasn't been emitted into LLVM yet, AND it is
+    // not part of any BLOCK, emit it now.
     if (!DECL_LLVM_SET_P(TREE_VALUE(t)) &&
-	block_declared_vars.find(TREE_VALUE(t)) == block_declared_vars.end())
+	block_declared_vars.count(TREE_VALUE(t)) == 0)
       EmitAutomaticVariableDecl(TREE_VALUE(t));
   }
 
@@ -826,7 +829,7 @@
 // in the new context.  Note that the variable emission order must be
 // consistent with and without debug info; otherwise, the register
 // allocation would change with -g, and users dislike that.
-void TreeToLLVM::switchLexicalBlock(tree_node *exp) {
+void TreeToLLVM::switchLexicalBlock(tree exp) {
   if (exp == NULL_TREE || TREE_CODE(exp) == FUNCTION_DECL) {
     // assert(RegionStack empty);
     if (TheDebugInfo)
@@ -844,7 +847,7 @@
     return;
 
   // Have we seen this BLOCK before?
-  bool previously_visited = (seen_blocks.find(new_block) != seen_blocks.end());
+  bool previously_visited = !SeenBlocks.insert(new_block);
 
   // If new_block is nested inside another block, and we haven't
   // processed either block, insure the outer block(s) get processed
@@ -880,9 +883,6 @@
   if (previously_visited)
     return;
 
-  // O.K., this lexical BLOCK is new to us; remember it for next time.
-  seen_blocks.insert(new_block);
-
   // Finally, allocate any BLOCK_VARS we find.
   tree step;
   for (step = BLOCK_VARS(new_block); step; step = TREE_CHAIN(step))

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=93821&r1=93820&r2=93821&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Mon Jan 18 18:22:51 2010
@@ -230,9 +230,8 @@
 
 // Starting at the 'desired' BLOCK, recursively walk back to the
 // 'grand' context, and return pushing regions to make 'desired' the
-// current context.  Assumes 'grand' is a
-// parent/grandparent/great-grandparent of 'desired'.  'desired'
-// should be a GCC lexical BLOCK, and 'grand' may be a BLOCK or a
+// current context.  'desired' should be a GCC lexical BLOCK, and
+// 'grand' should be an ancestor; it may be a BLOCK or a
 // FUNCTION_DECL.
 void DebugInfo::push_regions(tree desired, tree grand) {
   assert (grand && "'grand' BLOCK is NULL?");
@@ -244,6 +243,9 @@
           "expected 'grand' to be a GCC BLOCK or FUNCTION_DECL");
   if (grand != desired)
     push_regions(BLOCK_SUPERCONTEXT(desired), grand);
+  // FIXME: push_regions is currently never called with desired ==
+  // grand, but it should be fixed so nothing weird happens if they're
+  // equal.
   llvm::DIDescriptor D = findRegion(desired);
   RegionStack.push_back(D.getNode());
 }
@@ -253,6 +255,9 @@
 // by GCC's cfglayout.c:change_scope().
 void DebugInfo::change_regions(tree desired, tree grand) {
   tree current_lexical_block = getCurrentLexicalBlock();
+  // FIXME: change_regions is currently never called with desired ==
+  // grand, but it should be fixed so nothing weird happens if they're
+  // equal.
   while (current_lexical_block != grand) {
     assert(BLOCK_SUPERCONTEXT(getCurrentLexicalBlock()) &&
            "lost BLOCK context!");

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=93821&r1=93820&r2=93821&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Mon Jan 18 18:22:51 2010
@@ -77,6 +77,11 @@
   
   std::map<tree_node *, WeakVH> RegionMap;
 
+  // Starting at the 'desired' BLOCK, recursively walk back to the
+  // 'grand' context, and return pushing regions to make 'desired' the
+  // current context.  'desired' should be a GCC lexical BLOCK.
+  // 'grand' may be a BLOCK or a FUNCTION_DECL, and it's presumed to
+  // be an ancestor of 'desired'.
   void push_regions(tree_node *desired, tree_node *grand);
 
 public:
@@ -94,6 +99,9 @@
   tree_node *getCurrentLexicalBlock() { return CurrentGCCLexicalBlock; }
   void setCurrentLexicalBlock(tree_node *lb) { CurrentGCCLexicalBlock = lb; }
 
+  // Pop the current region/lexical-block back to 'grand', then push
+  // regions to arrive at 'desired'.  This was inspired (cribbed from)
+  // by GCC's cfglayout.c:change_scope().
   void change_regions(tree_node *desired, tree_node *grand);
 
   /// EmitFunctionStart - Constructs the debug code for entering a function -

Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=93821&r1=93820&r2=93821&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Mon Jan 18 18:22:51 2010
@@ -68,7 +68,7 @@
 using namespace llvm;
 
 typedef IRBuilder<true, TargetFolder> LLVMBuilder;
-typedef std::set<union tree_node *> treeset;
+typedef SmallPtrSet<union tree_node *, 16> treeset;
 
 /// TheModule - This is the current global module that we are compiling into.
 ///
@@ -279,7 +279,8 @@
   BasicBlock *ReturnBB;
   BasicBlock *UnwindBB;
   unsigned ReturnOffset;
-  std::set<tree_node*> seen_blocks;
+  // Lexical BLOCKS that we have previously seen and processed.
+  treeset SeenBlocks;
 
   // State that changes as the function is emitted.
 





More information about the llvm-commits mailing list