- /* If the parameter is never assigned to, we may not need to
- create a new variable here at all. Instead, we may be able
- to just use the argument value. */
- if (TREE_READONLY (p)
- && !TREE_ADDRESSABLE (p)
- && value && !TREE_SIDE_EFFECTS (value))
- {
- /* Simplify the value, if possible. */
- value = fold (DECL_P (value) ? decl_constant_value (value) : value);
-
- /* We can't risk substituting complex expressions. They
- might contain variables that will be assigned to later.
- Theoretically, we could check the expression to see if
- all of the variables that determine its value are
- read-only, but we don't bother. */
- if (TREE_CONSTANT (value) || TREE_READONLY_DECL_P (value))
- {
- /* If this is a declaration, wrap it a NOP_EXPR so that
- we don't try to put the VALUE on the list of
- BLOCK_VARS. */
- if (DECL_P (value))
- value = build1 (NOP_EXPR, TREE_TYPE (value), value);
-
- /* If this is a constant, make sure it has the right type. */
- else if (TREE_TYPE (value) != TREE_TYPE (p))
- value = fold (build1 (NOP_EXPR, TREE_TYPE (p), value));
-
- splay_tree_insert (id->decl_map,
- (splay_tree_key) p,
- (splay_tree_value) value);
- continue;
- }
- }
-
- /* Make an equivalent VAR_DECL. */
- var = copy_decl_for_inlining (p, fn, VARRAY_TREE (id->fns, 0));
-
- /* See if the frontend wants to pass this by invisible reference. If
- so, our new VAR_DECL will have REFERENCE_TYPE, and we need to
- replace uses of the PARM_DECL with dereferences. */
- if (TREE_TYPE (var) != TREE_TYPE (p)
- && POINTER_TYPE_P (TREE_TYPE (var))
- && TREE_TYPE (TREE_TYPE (var)) == TREE_TYPE (p))
- var_sub = build1 (INDIRECT_REF, TREE_TYPE (p), var);
- else
- var_sub = var;
-
- /* Register the VAR_DECL as the equivalent for the PARM_DECL;
- that way, when the PARM_DECL is encountered, it will be
- automatically replaced by the VAR_DECL. */
- splay_tree_insert (id->decl_map,
- (splay_tree_key) p,
- (splay_tree_value) var_sub);
-
- /* Declare this new variable. */
-#ifndef INLINER_FOR_JAVA
- init_stmt = build_stmt (DECL_STMT, var);
- TREE_CHAIN (init_stmt) = init_stmts;
- init_stmts = init_stmt;
-#else /* INLINER_FOR_JAVA */
- TREE_CHAIN (var) = vars;
- vars = var;
-#endif /* INLINER_FOR_JAVA */
-
- /* Initialize this VAR_DECL from the equivalent argument. If
- the argument is an object, created via a constructor or copy,
- this will not result in an extra copy: the TARGET_EXPR
- representing the argument will be bound to VAR, and the
- object will be constructed in VAR. */
- if (! TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (p)))
-#ifndef INLINER_FOR_JAVA
- DECL_INITIAL (var) = value;
- else
- {
- /* Even if P was TREE_READONLY, the new VAR should not be.
- In the original code, we would have constructed a
- temporary, and then the function body would have never
- changed the value of P. However, now, we will be
- constructing VAR directly. The constructor body may
- change its value multiple times as it is being
- constructed. Therefore, it must not be TREE_READONLY;
- the back-end assumes that TREE_READONLY variable is
- assigned to only once. */
- TREE_READONLY (var) = 0;
-
- /* Build a run-time initialization. */
- init_stmt = build_stmt (EXPR_STMT,
- build (INIT_EXPR, TREE_TYPE (p),
- var, value));
- /* Add this initialization to the list. Note that we want the
- declaration *after* the initialization because we are going
- to reverse all the initialization statements below. */
- TREE_CHAIN (init_stmt) = init_stmts;
- init_stmts = init_stmt;
- }
-
- /* See if we need to clean up the declaration. */
- cleanup = (*lang_hooks.maybe_build_cleanup) (var);
- if (cleanup)
- {
- tree cleanup_stmt;
- /* Build the cleanup statement. */
- cleanup_stmt = build_stmt (CLEANUP_STMT, var, cleanup);
- /* Add it to the *front* of the list; the list will be
- reversed below. */
- TREE_CHAIN (cleanup_stmt) = init_stmts;
- init_stmts = cleanup_stmt;
- }
-#else /* INLINER_FOR_JAVA */
- {
- tree assignment = build (MODIFY_EXPR, TREE_TYPE (p), var, value);
- init_stmts = add_stmt_to_compound (init_stmts, TREE_TYPE (p),
- assignment);
- }
- else
- {
- /* Java objects don't ever need constructing when being
- passed as arguments because only call by reference is
- supported. */
- abort ();
- }
-#endif /* INLINER_FOR_JAVA */