[llvm-commits] [llvm-gcc-4.0] r41842 - in /llvm-gcc-4.0/trunk/gcc: builtins.c builtins.def llvm-convert.cpp llvm-internal.h tree-nested.c tree.c

Duncan Sands baldrick at free.fr
Tue Sep 11 07:18:58 PDT 2007


Author: baldrick
Date: Tue Sep 11 09:18:58 2007
New Revision: 41842

URL: http://llvm.org/viewvc/llvm-project?rev=41842&view=rev
Log:
Fold adjust_trampoline into init_trampoline.  Store
the function pointer for the trampoline in the frame
struct rather than the trampoline itself.

Modified:
    llvm-gcc-4.0/trunk/gcc/builtins.c
    llvm-gcc-4.0/trunk/gcc/builtins.def
    llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
    llvm-gcc-4.0/trunk/gcc/llvm-internal.h
    llvm-gcc-4.0/trunk/gcc/tree-nested.c
    llvm-gcc-4.0/trunk/gcc/tree.c

Modified: llvm-gcc-4.0/trunk/gcc/builtins.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/builtins.c?rev=41842&r1=41841&r2=41842&view=diff

==============================================================================
--- llvm-gcc-4.0/trunk/gcc/builtins.c (original)
+++ llvm-gcc-4.0/trunk/gcc/builtins.c Tue Sep 11 09:18:58 2007
@@ -4986,25 +4986,13 @@
   trampolines_created = 1;
   INITIALIZE_TRAMPOLINE (r_tramp, r_func, r_chain);
 
-  return const0_rtx;
-}
-
-static rtx
-expand_builtin_adjust_trampoline (tree arglist)
-{
-  rtx tramp;
-
-  if (!validate_arglist (arglist, POINTER_TYPE, VOID_TYPE))
-    return NULL_RTX;
-
-  tramp = expand_expr (TREE_VALUE (arglist), NULL_RTX, VOIDmode, 0);
-  tramp = round_trampoline_addr (tramp);
 #ifdef TRAMPOLINE_ADJUST_ADDRESS
-  TRAMPOLINE_ADJUST_ADDRESS (tramp);
+  TRAMPOLINE_ADJUST_ADDRESS (r_tramp);
 #endif
 
-  return tramp;
+  return r_tramp;
 }
+/* LLVM local end */
 
 /* Expand a call to the built-in signbit, signbitf or signbitl function.
    Return NULL_RTX if a normal call should be emitted rather than expanding
@@ -5784,8 +5772,7 @@
 
     case BUILT_IN_INIT_TRAMPOLINE:
       return expand_builtin_init_trampoline (arglist);
-    case BUILT_IN_ADJUST_TRAMPOLINE:
-      return expand_builtin_adjust_trampoline (arglist);
+    /* LLVM local deleted 2 lines */
 
     case BUILT_IN_FORK:
     case BUILT_IN_EXECL:

Modified: llvm-gcc-4.0/trunk/gcc/builtins.def
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/builtins.def?rev=41842&r1=41841&r2=41842&view=diff

==============================================================================
--- llvm-gcc-4.0/trunk/gcc/builtins.def (original)
+++ llvm-gcc-4.0/trunk/gcc/builtins.def Tue Sep 11 09:18:58 2007
@@ -635,7 +635,7 @@
 
 /* Implementing nested functions.  */
 DEF_BUILTIN_STUB (BUILT_IN_INIT_TRAMPOLINE, "__builtin_init_trampoline")
-DEF_BUILTIN_STUB (BUILT_IN_ADJUST_TRAMPOLINE, "__builtin_adjust_trampoline")
+/* LLVM local deleted 1 line */
 DEF_BUILTIN_STUB (BUILT_IN_NONLOCAL_GOTO, "__builtin_nonlocal_goto")
 
 /* Implementing variable sized local variables.  */

Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=41842&r1=41841&r2=41842&view=diff

==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Tue Sep 11 09:18:58 2007
@@ -4274,9 +4274,7 @@
   case BUILT_IN_FROB_RETURN_ADDR:
    return EmitBuiltinFrobReturnAddr(exp, Result);
   case BUILT_IN_INIT_TRAMPOLINE:
-    return EmitBuiltinInitTrampoline(exp);
-  case BUILT_IN_ADJUST_TRAMPOLINE:
-    return EmitBuiltinAdjustTrampoline(exp, Result);
+    return EmitBuiltinInitTrampoline(exp, Result);
 
   // Builtins used by the exception handling runtime.
   case BUILT_IN_DWARF_CFA:
@@ -4936,7 +4934,7 @@
   return true;
 }
 
-bool TreeToLLVM::EmitBuiltinInitTrampoline(tree exp) {
+bool TreeToLLVM::EmitBuiltinInitTrampoline(tree exp, Value *&Result) {
   tree arglist = TREE_OPERAND(exp, 1);
   if (!validate_arglist (arglist, POINTER_TYPE, POINTER_TYPE, POINTER_TYPE,
                          VOID_TYPE))
@@ -4957,22 +4955,7 @@
 
   Function *Intr = Intrinsic::getDeclaration(TheModule,
                                              Intrinsic::init_trampoline);
-  Builder.CreateCall(Intr, Ops, Ops+3);
-  return true;
-}
-
-bool TreeToLLVM::EmitBuiltinAdjustTrampoline(tree exp, Value *&Result) {
-  tree arglist = TREE_OPERAND(exp, 1);
-  if (!validate_arglist(arglist, POINTER_TYPE, VOID_TYPE))
-    return false;
-
-  Value *Tramp = Emit(TREE_VALUE(arglist), 0);
-  Tramp = CastToType(Instruction::BitCast, Tramp,
-                     PointerType::get(Type::Int8Ty));
-
-  Function *Intr = Intrinsic::getDeclaration(TheModule,
-                                             Intrinsic::adjust_trampoline);
-  Result = Builder.CreateCall(Intr, Tramp, "adj");
+  Result = Builder.CreateCall(Intr, Ops, Ops+3, "tramp");
   return true;
 }
 

Modified: llvm-gcc-4.0/trunk/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-internal.h?rev=41842&r1=41841&r2=41842&view=diff

==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-internal.h Tue Sep 11 09:18:58 2007
@@ -583,8 +583,7 @@
   bool EmitBuiltinEHReturn(tree_node *exp, Value *&Result);
   bool EmitBuiltinInitDwarfRegSizes(tree_node *exp, Value *&Result);
   bool EmitBuiltinUnwindInit(tree_node *exp, Value *&Result);
-  bool EmitBuiltinInitTrampoline(tree_node *exp);
-  bool EmitBuiltinAdjustTrampoline(tree_node *exp, Value *&Result);
+  bool EmitBuiltinInitTrampoline(tree_node *exp, Value *&Result);
 
   // Complex Math Expressions.
   void EmitLoadFromComplex(Value *&Real, Value *&Imag, Value *SrcComplex,

Modified: llvm-gcc-4.0/trunk/gcc/tree-nested.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/tree-nested.c?rev=41842&r1=41841&r2=41842&view=diff

==============================================================================
--- llvm-gcc-4.0/trunk/gcc/tree-nested.c (original)
+++ llvm-gcc-4.0/trunk/gcc/tree-nested.c Tue Sep 11 09:18:58 2007
@@ -395,16 +395,20 @@
 
 /* Build or return the type used to represent a nested function trampoline.  */
 
-static GTY(()) tree trampoline_type;
+/* LLVM local */
+static GTY(()) tree trampoline_storage_type;
 
 static tree
-get_trampoline_type (void)
+/* LLVM local */
+get_trampoline_storage_type (void)
 {
   tree record, t;
   unsigned align, size;
 
-  if (trampoline_type)
-    return trampoline_type;
+  /* LLVM local begin */
+  if (trampoline_storage_type)
+    return trampoline_storage_type;
+  /* LLVM local end */
 
   align = TRAMPOLINE_ALIGNMENT;
   size = TRAMPOLINE_SIZE;
@@ -460,8 +464,9 @@
     {
       field = make_node (FIELD_DECL);
       DECL_NAME (field) = DECL_NAME (decl);
-      TREE_TYPE (field) = get_trampoline_type ();
-      TREE_ADDRESSABLE (field) = 1;
+      /* LLVM local begin */
+      TREE_TYPE (field) = TYPE_POINTER_TO (TREE_TYPE (decl));
+      /* LLVM local end */
 
       insert_field_into_struct (get_frame_type (info), field);
 
@@ -1190,17 +1195,14 @@
 {
   struct walk_stmt_info *wi = data;
   struct nesting_info *info = wi->info, *i;
-  tree t = *tp, decl, target_context, x, arg;
+  /* LLVM local */
+  tree t = *tp, decl, target_context, x;
 
   *walk_subtrees = 0;
   switch (TREE_CODE (t))
     {
     case ADDR_EXPR:
-      /* Build
-	   T.1 = &CHAIN->tramp;
-	   T.2 = __builtin_adjust_trampoline (T.1);
-	   T.3 = (func_type)T.2;
-      */
+      /* LLVM local deleted 5 lines */
 
       decl = TREE_OPERAND (t, 0);
       if (TREE_CODE (decl) != FUNCTION_DECL)
@@ -1220,22 +1222,12 @@
 	 we need to insert the trampoline.  */
       for (i = info; i->context != target_context; i = i->outer)
 	continue;
-      x = lookup_tramp_for_decl (i, decl, INSERT);
+      /* LLVM local begin */
 
-      /* Compute the address of the field holding the trampoline.  */
+      /* Lookup the trampoline.  */
+      x = lookup_tramp_for_decl (i, decl, INSERT);
       x = get_frame_field (info, target_context, x, &wi->tsi);
-      x = build_addr (x);
-      x = tsi_gimplify_val (info, x, &wi->tsi);
-      arg = tree_cons (NULL, x, NULL);
-
-      /* Do machine-specific ugliness.  Normally this will involve
-	 computing extra alignment, but it can really be anything.  */
-      x = implicit_built_in_decls[BUILT_IN_ADJUST_TRAMPOLINE];
-      x = build_function_call_expr (x, arg);
-      x = init_tmp_var (info, x, &wi->tsi);
-
-      /* Cast back to the proper function type.  */
-      x = build1 (NOP_EXPR, TREE_TYPE (t), x);
+      /* LLVM local end */
       x = init_tmp_var (info, x, &wi->tsi);
 
       *tp = x;
@@ -1390,7 +1382,8 @@
       struct nesting_info *i;
       for (i = root->inner; i ; i = i->next)
 	{
-	  tree arg, x, field;
+	  /* LLVM local */
+	  tree arg, x, y, field;
 
 	  field = lookup_tramp_for_decl (root, i->context, NO_INSERT);
 	  if (!field)
@@ -1405,13 +1398,27 @@
 	  x = build_addr (i->context);
 	  arg = tree_cons (NULL, x, arg);
 
-	  x = build (COMPONENT_REF, TREE_TYPE (field),
-		     root->frame_decl, field, NULL_TREE);
-	  x = build_addr (x);
+	  /* LLVM local begin */
+	  /* Create a local variable to hold the trampoline code.  */
+	  y = create_tmp_var_for (root, get_trampoline_storage_type(),
+				  "TRAMP");
+	  x = build_addr (y);
 	  arg = tree_cons (NULL, x, arg);
 
 	  x = implicit_built_in_decls[BUILT_IN_INIT_TRAMPOLINE];
 	  x = build_function_call_expr (x, arg);
+	  y = create_tmp_var_for (root, TREE_TYPE(x), NULL);
+	  x = build2 (MODIFY_EXPR, TREE_TYPE (x), y, x);
+	  append_to_statement_list (x, &stmt_list);
+
+	  /* Cast back to the proper function type.  */
+	  y = build1 (NOP_EXPR, TREE_TYPE (field), y);
+
+	  /* Initialize the trampoline.  */
+	  x = build3 (COMPONENT_REF, TREE_TYPE (field),
+		      root->frame_decl, field, NULL_TREE);
+	  x = build2 (MODIFY_EXPR, TREE_TYPE (field), x, y);
+	  /* LLVM local end */
 
 	  append_to_statement_list (x, &stmt_list);
 	}

Modified: llvm-gcc-4.0/trunk/gcc/tree.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/tree.c?rev=41842&r1=41841&r2=41842&view=diff

==============================================================================
--- llvm-gcc-4.0/trunk/gcc/tree.c (original)
+++ llvm-gcc-4.0/trunk/gcc/tree.c Tue Sep 11 09:18:58 2007
@@ -6001,17 +6001,12 @@
   tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
   tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
   tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
-  ftype = build_function_type (void_type_node, tmp);
+  /* LLVM local begin */
+  ftype = build_function_type (ptr_type_node, tmp);
   local_define_builtin ("__builtin_init_trampoline", ftype,
 			BUILT_IN_INIT_TRAMPOLINE,
 			"__builtin_init_trampoline", ECF_NOTHROW);
-
-  tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
-  ftype = build_function_type (ptr_type_node, tmp);
-  local_define_builtin ("__builtin_adjust_trampoline", ftype,
-			BUILT_IN_ADJUST_TRAMPOLINE,
-			"__builtin_adjust_trampoline",
-			ECF_CONST | ECF_NOTHROW);
+  /* LLVM local end */
 
   tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
   tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);





More information about the llvm-commits mailing list