[llvm-branch-commits] [llvm-gcc-branch] r93745 - in /llvm-gcc-4.2/branches/Apple/Zoidberg/gcc: config/i386/i386.c config/i386/llvm-i386.cpp cp/parser.c gimple-low.c llvm-convert.cpp llvm-debug.cpp llvm-debug.h llvm-internal.h omp-low.c testsuite/gcc.dg/ssp-1.c testsuite/gcc.dg/ssp-2.c tree-cfg.c

Stuart Hastings stuart at apple.com
Mon Jan 18 10:53:52 PST 2010


Author: stuart
Date: Mon Jan 18 12:53:52 2010
New Revision: 93745

URL: http://llvm.org/viewvc/llvm-project?rev=93745&view=rev
Log:
Copy Radar 7387470 patches into Zoidberg branch.

Modified:
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/config/i386/i386.c
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/config/i386/llvm-i386.cpp
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/cp/parser.c
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/gimple-low.c
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-internal.h
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/omp-low.c
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/testsuite/gcc.dg/ssp-1.c
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/testsuite/gcc.dg/ssp-2.c
    llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/tree-cfg.c

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/config/i386/i386.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/config/i386/i386.c?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/config/i386/i386.c (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/config/i386/i386.c Mon Jan 18 12:53:52 2010
@@ -3458,17 +3458,32 @@
 	    if (!num)
 	      return 0;
 
-	    /* The partial classes are now full classes.  */
-	    if (subclasses[0] == X86_64_SSESF_CLASS && bytes != 4)
-	      subclasses[0] = X86_64_SSE_CLASS;
-	    if (subclasses[0] == X86_64_INTEGERSI_CLASS && bytes != 4)
-	      subclasses[0] = X86_64_INTEGER_CLASS;
-
+	    /* LLVM LOCAL begin 7387470 */
 	    for (i = 0; i < words; i++)
 	      classes[i] = subclasses[i % num];
 
-	    break;
+	    /* If the first register has a 32-bit class, but there are
+	       more than 32-bits in the type, upgrade it to the
+	       corresponding 64-bit class.  */
+	    if ((bytes > 4) &&
+		((subclasses[0] == X86_64_SSESF_CLASS) ||
+		 (subclasses[0] == X86_64_INTEGERSI_CLASS))) {
+		classes[0] = (subclasses[0] == X86_64_SSESF_CLASS) ?
+		  X86_64_SSE_CLASS : X86_64_INTEGER_CLASS;
+		/* subclasses[1] is only valid if num == 2.  If it's
+		   invalid, or it's set to a 32-bit class, AND there
+		   are more than twelve bytes in the type, upgrade the
+		   second register to 64-bits.  (If we got here, the
+		   first register already has a 64-bit class.)  */
+		if (bytes > 12 &&
+		    (num == 1 ||
+		     subclasses[1] == X86_64_SSESF_CLASS ||
+		     subclasses[1] == X86_64_INTEGERSI_CLASS))
+		  classes[1] = classes[0];
+	    }
 	  }
+	  break;
+	  /* LLVM LOCAL end 7387470 */
 	case UNION_TYPE:
 	case QUAL_UNION_TYPE:
 	  /* Unions are similar to RECORD_TYPE but offset is always 0.

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/config/i386/llvm-i386.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/config/i386/llvm-i386.cpp?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/config/i386/llvm-i386.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/config/i386/llvm-i386.cpp Mon Jan 18 12:53:52 2010
@@ -842,10 +842,6 @@
   if (!NumClasses)
     return false;
 
-  if (NumClasses == 1 && Class[0] == X86_64_INTEGERSI_CLASS)
-    // This will fit in one i32 register.
-    return false;
-
   for (int i = 0; i < NumClasses; ++i) {
     switch (Class[i]) {
     case X86_64_INTEGER_CLASS:

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/cp/parser.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/cp/parser.c?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/cp/parser.c (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/cp/parser.c Mon Jan 18 12:53:52 2010
@@ -21724,7 +21724,17 @@
 
   /* Current scope must be that of the main function body. */
   /* FIXME gcc_assert (current_scope->function_body);*/
-  pushdecl (byref_decl);
+  /* LLVM LOCAL begin 7387470 */
+  /* Find the scope for function body (outer-most scope) and insert
+     this variable in that scope. This is to avoid duplicate
+     declaration of the save variable. */
+  {
+    struct cp_binding_level *b = current_binding_level;
+    while (b->level_chain->kind != sk_function_parms)
+      b = b->level_chain;
+    pushdecl_with_scope (byref_decl, b, /*is_friend=*/false);
+  }
+  /* LLVM LOCAL end 7387470 */
   mark_used (byref_decl);
   /* APPLE LOCAL begin radar 6083129 -  byref escapes (cp) */
   /* FIXME: finish this off, ensure the decl is scoped appropriately
@@ -22039,7 +22049,7 @@
  */
 static void
 declare_block_prologue_local_byref_vars (tree self_parm, tree component,
-				   tree stmt)
+					 tree stmt)
 {
   tree decl, block_component;
   tree_stmt_iterator i;

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/gimple-low.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/gimple-low.c?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/gimple-low.c (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/gimple-low.c Mon Jan 18 12:53:52 2010
@@ -246,7 +246,9 @@
     case GOTO_EXPR:
     case LABEL_EXPR:
     case SWITCH_EXPR:
-    case OMP_FOR:
+      /* LLVM LOCAL begin 7387470 */
+      /* LLVM LOCAL deletion; OMP_FOR case moved below. */
+      /* LLVM LOCAL end 7387470 */
     case OMP_SECTIONS:
     case OMP_SECTION:
     case OMP_SINGLE:
@@ -257,6 +259,16 @@
     case OMP_CONTINUE:
       break;
 
+      /* LLVM LOCAL begin 7387470 */
+    case OMP_FOR:
+      {
+	tree init = OMP_FOR_INIT(stmt);
+	gcc_assert(TREE_CODE(init) == MODIFY_EXPR && "expected simple assignment");
+	TREE_BLOCK(init) = data->block;
+      }
+      break;
+      /* LLVM LOCAL end 7387470 */
+
     case MODIFY_EXPR:
       if (TREE_CODE (TREE_OPERAND (stmt, 1)) == CALL_EXPR)
 	stmt = TREE_OPERAND (stmt, 1);

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-convert.cpp Mon Jan 18 12:53:52 2010
@@ -414,6 +414,32 @@
   return (Val = false);
 }
 
+// Walk the GCC BLOCK() tree.  Set BLOCK_NUMBER() to the depth of each
+// block; this is necessary for lexical block debug info.  Visit all
+// the BLOCK_VARS(), and add them to the set s.  Since the
+// unexpanded_var_list seems to be a superset of all the scoped
+// 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) {
+  tree bstep, step;
+  switch (TREE_CODE(t)) {
+  default:
+    abort();
+  case BLOCK:
+    for (bstep = t; bstep; bstep = TREE_CHAIN(bstep)) {
+      BLOCK_NUMBER(bstep) = level;
+      for (step = BLOCK_VARS(t); step; step = TREE_CHAIN(step))
+	s.insert(step);
+    }
+    for (bstep = BLOCK_SUBBLOCKS(t); bstep; bstep = TREE_CHAIN(bstep))
+      setLexicalBlockDepths(bstep, s, level+1);
+    return;
+  case FUNCTION_DECL:
+    return setLexicalBlockDepths(DECL_INITIAL(t), s, level);
+  }
+}
+
 void TreeToLLVM::StartFunctionBody() {
   const char *Name = "";
   // Get the name of the function.
@@ -565,6 +591,11 @@
   // Create a new basic block for the function.
   Builder.SetInsertPoint(BasicBlock::Create(Context, "entry", Fn));
 
+  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();
+
   if (TheDebugInfo)
     TheDebugInfo->EmitFunctionStart(FnDecl, Fn, Builder.GetInsertBlock());
 
@@ -657,10 +688,14 @@
   // 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 (!DECL_LLVM_SET_P(TREE_VALUE(t)))
+    if (!DECL_LLVM_SET_P(TREE_VALUE(t)) &&
+	block_declared_vars.find(TREE_VALUE(t)) == block_declared_vars.end())
       EmitAutomaticVariableDecl(TREE_VALUE(t));
   }
 
+  // Push the outermost lexical block onto the RegionStack.
+  switchLexicalBlock(DECL_INITIAL(FnDecl));
+
   // Create a new block for the return node, but don't insert it yet.
   ReturnBB = BasicBlock::Create(Context, "return");
 }
@@ -786,6 +821,96 @@
   return FinishFunctionBody();
 }
 
+// Given a GCC lexical context (BLOCK or FUNCTION_DECL), make it the
+// new current BLOCK/context/scope.  Emit any local variables found
+// 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) {
+  if (exp == NULL_TREE || TREE_CODE(exp) == FUNCTION_DECL) {
+    // assert(RegionStack empty);
+    if (TheDebugInfo)
+      TheDebugInfo->setCurrentLexicalBlock(exp);
+    return;
+  }
+
+  // Only EXPR_P nodes have a TREE_BLOCK() field.
+  if (!EXPR_P(exp) && (TREE_CODE(exp) != BLOCK))
+    return;
+
+  tree new_block = EXPR_P(exp) ? TREE_BLOCK(exp) : exp;
+
+  if (!new_block)
+    return;
+
+  // Have we seen this BLOCK before?
+  bool previously_visited = (seen_blocks.find(new_block) != seen_blocks.end());
+
+  // If new_block is nested inside another block, and we haven't
+  // processed either block, insure the outer block(s) get processed
+  // first.
+  if (!previously_visited)
+    switchLexicalBlock(BLOCK_SUPERCONTEXT(new_block));
+
+  if (TheDebugInfo) {
+    tree current_block = TheDebugInfo->getCurrentLexicalBlock();
+    if (new_block && current_block && new_block != current_block) {
+      tree new_climber = new_block, current_climber = current_block;
+      unsigned new_climber_depth, current_climber_depth;
+      // Climb the GCC BLOCK hierarchy, looking for a common parent
+      // BLOCK or FUNCTION_DECL.  Assume BLOCK_NUMBER() fields set to
+      // depth by setLexicalBlockDepths().  If the climber depths are
+      // equal, but the climbers differ, they are siblings: both
+      // climbers rise to the next level.
+      while (new_climber != current_climber) {
+	current_climber_depth = DECL_P(current_climber) ? 0 : BLOCK_NUMBER(current_climber);
+	new_climber_depth = DECL_P(new_climber) ? 0 : BLOCK_NUMBER(new_climber);
+	if (new_climber_depth <= current_climber_depth)
+	  current_climber = BLOCK_SUPERCONTEXT(current_climber);
+	if (new_climber_depth >= current_climber_depth)
+	  new_climber = BLOCK_SUPERCONTEXT(new_climber);
+      }
+      assert(new_climber == current_climber && "missed common TREE_BLOCK parent");
+      // Pop and push lexical blocks to arrive at the new context.
+      TheDebugInfo->change_regions(new_block, new_climber);
+    }
+  }
+
+  // If we've seen this lexical BLOCK before, we're done.
+  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))
+    switch (TREE_CODE_CLASS(TREE_CODE(step))) {
+    default:
+      assert(0 && "non-var, non-type node hanging from a GCC BLOCK?");
+      break;
+    case tcc_type:
+      // GCC has recorded a lexical block scope for this type, but
+      // ConvertType() doesn't currently handle scopes for types.
+      break;
+    case tcc_declaration:
+      if (!DECL_LLVM_SET_P(step))
+	EmitAutomaticVariableDecl(step);
+      break;
+    }
+
+  // Kludge! The Objective-C++ front-end doesn't always point to the
+  // right BLOCK. :-( Test case g++.apple/block-assigncglobal.C has a
+  // block (closure) where the first statement (a MODIFY_EXPR) points
+  // to a lexical BLOCK that has no BLOCK_VARS, but it has a subblock
+  // with the decl for the target of the MODIFY.  Ergo, if we
+  // encounter a BLOCK that allocates no variables, check for a
+  // subblock.  A better fix would be in the front-end.
+  if (!BLOCK_VARS(new_block) && BLOCK_SUBBLOCKS(new_block))
+    switchLexicalBlock(BLOCK_SUBBLOCKS(new_block));
+}
+
 Value *TreeToLLVM::Emit(tree exp, const MemRef *DestLoc) {
   assert((isAggregateTreeType(TREE_TYPE(exp)) == (DestLoc != 0) ||
           TREE_CODE(exp) == MODIFY_EXPR || TREE_CODE(exp) == INIT_EXPR) &&
@@ -793,6 +918,10 @@
 
   Value *Result = 0;
 
+  // If we've just changed lexical blocks, emit any local variables
+  // declared in the new block.
+  TreeToLLVM::switchLexicalBlock(exp);
+
   if (TheDebugInfo) {
     if (EXPR_HAS_LOCATION(exp)) {
       // Set new location on the way up the tree.

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.cpp Mon Jan 18 12:53:52 2010
@@ -228,10 +228,46 @@
     return false;
 }
 
+// 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
+// FUNCTION_DECL.
+void DebugInfo::push_regions(tree desired, tree grand) {
+  assert (grand && "'grand' BLOCK is NULL?");
+  assert (desired &&
+          "'desired' BLOCK is NULL; is grand BLOCK really a parent of desired BLOCK?");
+  assert ((TREE_CODE(desired) == BLOCK || TREE_CODE(desired) == FUNCTION_DECL) &&
+          "expected 'desired' to be a GCC BLOCK or FUNCTION_DECL");
+  assert ((TREE_CODE(grand) == BLOCK || TREE_CODE(grand) == FUNCTION_DECL) &&
+          "expected 'grand' to be a GCC BLOCK or FUNCTION_DECL");
+  if (grand != desired)
+    push_regions(BLOCK_SUPERCONTEXT(desired), grand);
+  llvm::DIDescriptor D = findRegion(desired);
+  RegionStack.push_back(D.getNode());
+}
+
+// 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 DebugInfo::change_regions(tree desired, tree grand) {
+  tree current_lexical_block = getCurrentLexicalBlock();
+  while (current_lexical_block != grand) {
+    assert(BLOCK_SUPERCONTEXT(getCurrentLexicalBlock()) &&
+           "lost BLOCK context!");
+    current_lexical_block = BLOCK_SUPERCONTEXT(current_lexical_block);
+    RegionStack.pop_back();
+  }
+  DebugInfo::push_regions(desired, grand);
+  setCurrentLexicalBlock(desired);
+}
+
 /// EmitFunctionStart - Constructs the debug code for entering a function -
 /// "llvm.dbg.func.start."
 void DebugInfo::EmitFunctionStart(tree FnDecl, Function *Fn,
                                   BasicBlock *CurBB) {
+  setCurrentLexicalBlock(FnDecl);
 
   DIType FNType = getOrCreateType(TREE_TYPE(FnDecl));
 
@@ -329,6 +365,13 @@
       return DIDescriptor(NS.getNode());
     }
     return findRegion (DECL_CONTEXT (Node));
+  } else if (TREE_CODE(Node) == BLOCK) {
+    // TREE_BLOCK is GCC's lexical block.
+    // Recursively create all necessary contexts:
+    DIDescriptor context = findRegion(BLOCK_SUPERCONTEXT(Node));
+    DILexicalBlock lexical_block = DebugFactory.CreateLexicalBlock(context);
+    RegionMap[Node] = WeakVH(lexical_block.getNode());
+    return DIDescriptor(lexical_block);
   }
 
   // Otherwise main compile unit covers everything.
@@ -347,6 +390,7 @@
     PrevLineNo = 0;
     PrevFullPath = NULL;
   }
+  setCurrentLexicalBlock(NULL_TREE);
 }
 
 /// EmitDeclare - Constructs the debug code for allocation of a new variable.

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-debug.h Mon Jan 18 12:53:52 2010
@@ -61,6 +61,7 @@
   const char *PrevFullPath;             // Previous location file encountered.
   int PrevLineNo;                       // Previous location line# encountered.
   BasicBlock *PrevBB;                   // Last basic block encountered.
+  tree_node *CurrentGCCLexicalBlock;	// Current GCC lexical block (or enclosing FUNCTION_DECL).
   std::map<std::string, WeakVH > CUCache;
   std::map<tree_node *, WeakVH > TypeCache;
                                         // Cache of previously constructed 
@@ -75,6 +76,9 @@
                                         // Stack to track declarative scopes.
   
   std::map<tree_node *, WeakVH> RegionMap;
+
+  void push_regions(tree_node *desired, tree_node *grand);
+
 public:
   DebugInfo(Module *m);
 
@@ -87,6 +91,11 @@
   void setLocationFile(const char *FullPath) { CurFullPath = FullPath; }
   void setLocationLine(int LineNo)           { CurLineNo = LineNo; }
   
+  tree_node *getCurrentLexicalBlock() { return CurrentGCCLexicalBlock; }
+  void setCurrentLexicalBlock(tree_node *lb) { CurrentGCCLexicalBlock = lb; }
+
+  void change_regions(tree_node *desired, tree_node *grand);
+
   /// EmitFunctionStart - Constructs the debug code for entering a function -
   /// "llvm.dbg.func.start."
   void EmitFunctionStart(tree_node *FnDecl, Function *Fn, BasicBlock *CurBB);

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-internal.h?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/llvm-internal.h Mon Jan 18 12:53:52 2010
@@ -68,6 +68,7 @@
 using namespace llvm;
 
 typedef IRBuilder<true, TargetFolder> LLVMBuilder;
+typedef std::set<union tree_node *> treeset;
 
 /// TheModule - This is the current global module that we are compiling into.
 ///
@@ -278,6 +279,7 @@
   BasicBlock *ReturnBB;
   BasicBlock *UnwindBB;
   unsigned ReturnOffset;
+  std::set<tree_node*> seen_blocks;
 
   // State that changes as the function is emitted.
 
@@ -380,8 +382,26 @@
   /// GCC type specified by GCCType to know which elements to copy.
   void EmitAggregateCopy(MemRef DestLoc, MemRef SrcLoc, tree_node *GCCType);
 
+  // 'desired' and 'grand' are GCC BLOCK nodes, representing lexical
+  // blocks.  Assumes we're in the 'grand' context; push contexts
+  // until we reach the 'desired' context.
+  void push_regions(tree_node *desired, tree_node *grand);
+
+  // Given a GCC lexical context (BLOCK or FUNCTION_DECL), make it the
+  // new current BLOCK/context/scope.  Emit any local variables found
+  // 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 switchLexicalBlock(tree_node *exp);
+
 private: // Helper functions.
 
+  // Walk over the lexical BLOCK() tree of the given FUNCTION_DECL;
+  // set the BLOCK_NUMBER() fields to the depth of each block, and
+  // add every var or type encountered in the BLOCK_VARS() lists to
+  // the given set.
+  void setLexicalBlockDepths(tree_node *t, treeset &s, unsigned level);
+
   /// StartFunctionBody - Start the emission of 'fndecl', outputing all
   /// declarations for parameters and setting things up.
   void StartFunctionBody();

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/omp-low.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/omp-low.c?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/omp-low.c (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/omp-low.c Mon Jan 18 12:53:52 2010
@@ -2870,6 +2870,15 @@
   t = build2 (MULT_EXPR, type, t, fd->step);
   t = build2 (PLUS_EXPR, type, t, fd->n1);
   t = build2 (MODIFY_EXPR, void_type_node, fd->v, t);
+  /* LLVM LOCAL begin 7387470 */
+  /* Decorate this MODIFY_EXPR with the correct lexical block.  */
+  {
+    extern tree debug_find_var_in_block_tree (tree, tree);
+    TREE_BLOCK(t) = 
+      debug_find_var_in_block_tree(fd->v,
+				   DECL_INITIAL(current_function_decl));
+  }
+  /* LLVM LOCAL end 7387470 */
   gimplify_and_add (t, &list);
 
   t = fold_convert (type, e0);

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/testsuite/gcc.dg/ssp-1.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/testsuite/gcc.dg/ssp-1.c?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/testsuite/gcc.dg/ssp-1.c (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/testsuite/gcc.dg/ssp-1.c Mon Jan 18 12:53:52 2010
@@ -11,7 +11,7 @@
 
 int main ()
 {
-  int i;
+  static int i;		/* Can't allocate this on the stack.  */
   char foo[255];
 
   // smash stack

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/testsuite/gcc.dg/ssp-2.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/testsuite/gcc.dg/ssp-2.c?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/testsuite/gcc.dg/ssp-2.c (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/testsuite/gcc.dg/ssp-2.c Mon Jan 18 12:53:52 2010
@@ -12,7 +12,7 @@
 void
 overflow()
 {
-  int i = 0;
+  static int i = 0;	/* Can't allocate this on the stack.  */
   char foo[30];
 
   /* Overflow buffer.  */

Modified: llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/tree-cfg.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/tree-cfg.c?rev=93745&r1=93744&r2=93745&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/tree-cfg.c (original)
+++ llvm-gcc-4.2/branches/Apple/Zoidberg/gcc/tree-cfg.c Mon Jan 18 12:53:52 2010
@@ -316,6 +316,19 @@
 	  /* Copy the original computed goto's destination into VAR.  */
 	  assignment = build2 (MODIFY_EXPR, ptr_type_node,
 			       var, GOTO_DESTINATION (last));
+	  /* LLVM LOCAL begin 7387470 */
+	  if (TREE_CODE_CLASS(TREE_CODE(GOTO_DESTINATION(last))) ==
+			      tcc_declaration)
+	  {
+	    extern tree debug_find_var_in_block_tree (tree, tree);
+	    tree block =
+	      debug_find_var_in_block_tree(GOTO_DESTINATION(last),
+					   DECL_INITIAL(current_function_decl));
+	    /* This could be a compiler-created temporary variable
+	       where block == NULL_TREE.  That's O.K.  */
+	    TREE_BLOCK(assignment) = block;
+	  }
+	  /* LLVM LOCAL end 7387470 */
 	  bsi_insert_before (&bsi, assignment, BSI_SAME_STMT);
 
 	  /* And re-vector the computed goto to the new destination.  */





More information about the llvm-branch-commits mailing list