A few testcases for separate shrink-wrapping: test whether it works in a
trivial case; whether it creates more than one prologue where that is
useful; whether it puts prologues inside a loop if that is cheaper.
gcc/testsuite/
* gcc.target/powerpc/shrink-wrap-separate-0.c: New testcase.
* gcc.target/powerpc/shrink-wrap-separate-1.c: New testcase.
* gcc.target/powerpc/shrink-wrap-separate-2.c: New testcase.
From-SVN: r241066
This implements the hooks for separate shrink-wrapping for rs6000.
It handles GPRs and LR. The GPRs get a component number corresponding
to their register number; LR gets component number 0.
* config/rs6000/rs6000.c (machine_function): Add new fields
gpr_is_wrapped_separately and lr_is_wrapped_separately.
(TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS,
TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB,
TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS,
TARGET_SHRINK_WRAP_EMIT_PROLOGUE_COMPONENTS,
TARGET_SHRINK_WRAP_EMIT_EPILOGUE_COMPONENTS,
TARGET_SHRINK_WRAP_SET_HANDLED_COMPONENTS): Define.
(rs6000_get_separate_components): New function.
(rs6000_components_for_bb): New function.
(rs6000_disqualify_components): New function.
(rs6000_emit_prologue_components): New function.
(rs6000_emit_epilogue_components): New function.
(rs6000_set_handled_components): New function.
(rs6000_emit_prologue): Don't emit LR save if lr_is_wrapped_separately.
Don't emit GPR saves if gpr_is_wrapped_separately for that register.
(restore_saved_lr): Don't restore LR if lr_is_wrapped_separately.
(rs6000_emit_epilogue): Don't emit GPR restores if
gpr_is_wrapped_separately for that register. Don't make a
REG_CFA_RESTORE note for registers we did not restore, either.
From-SVN: r241065
This is the main substance of this patch series.
Instead of doing all of the prologue and epilogue in one spot, it often
is better to do components of it at different places, so that they are
executed less frequently.
What exactly is a component is completely up to the target; this code
treats it all abstractly, and uses hooks for the target to handle the
more concrete things. Commonly there is one component for each callee-
saved register, for example.
Components can be executed more than once per function execution. This
pass makes sure that a component's epilogue is not called more often
than the corresponding prologue has been, at any point in time; that the
prologue is called more often, wherever the prologue's effect is needed;
and that the epilogue is called as often as the prologue has been, when
the function exits. It does this by first deciding which blocks need
which components active, and then placing prologue and epilogue
components to make that exactly true.
Deciding what blocks should run with a certain component active so that
the total cost of executing the prologues (and epilogues) is optimal, is
not a computationally feasible problem. Instead, for each basic block,
we estimate the cost of putting a prologue right before the block, and
if that is cheaper than the total cost of putting prologues optimally
(according to the estimated cost) in the dominator subtrees strictly
dominated by this first block, place it at the first block instead.
This simple procedure places the components optimally for any dominator
sub tree where the root node's cost does not depend on anything outside
its subtree.
The cost is the execution frequency of all edges into the block coming
from blocks that do not have this component active. The estimated cost
is the execution frequency of the block, minus the execution frequency
of any backedges (which by definition are coming from subtrees, so if
the "head" block gets a prologue, the source block of any backedge has
that component active as well).
Currently, the epilogues are placed as late as possible, given the
constraints. This does not matter for execution cost, but we could
save a little bit of code size by placing the epilogues in a smarter
way. This is a possible future optimisation.
Now all that is left is inserting prologues and epilogues on all edges
that jump into resp. out of the "active" set of blocks. Often we need
to insert some components' prologues (or epilogues) on all edges into
(or out of) a block. In theory cross-jumping can unify all such, but
in practice that often fails; besides, that is a lot of work. So in
this case we insert the prologue and epilogue components at the "head"
or "tail" of a block, instead.
As a final optimisation, if a block needs a prologue and its immediate
dominator has the block as a post-dominator, that immediate dominator
gets the prologue as well.
* function.c (thread_prologue_and_epilogue_insns): Call
try_shrink_wrapping_separate. Compute the prologue_seq afterwards,
if it has possibly changed. Compute the split_prologue_seq and
epilogue_seq later, too.
* shrink-wrap.c: #include cfgbuild.h and insn-config.h.
(dump_components): New function.
(struct sw): New struct.
(SW): New function.
(init_separate_shrink_wrap): New function.
(fini_separate_shrink_wrap): New function.
(place_prologue_for_one_component): New function.
(spread_components): New function.
(disqualify_problematic_components): New function.
(emit_common_heads_for_components): New function.
(emit_common_tails_for_components): New function.
(insert_prologue_epilogue_for_components): New function.
(try_shrink_wrapping_separate): New function.
* shrink-wrap.h: Declare try_shrink_wrapping_separate.
From-SVN: r241063
A restore is supposed to restore some certain register. Restoring it
into some other register will not work. Don't.
* regrename.c (build_def_use): Invalidate chains that have a
REG_CFA_RESTORE on some instruction.
From-SVN: r241061
If there is a separately wrapped register restore on some path that
is dead (say, control goes into an endless loop after it), then we
cannot delete that restore because that would confuse the DWARF CFI
(if there is another path joining).
This happens with gcc.dg/torture/pr53168.c, for example.
* dce.c (delete_unmarked_insns): Don't delete instructions with
a REG_CFA_RESTORE note.
From-SVN: r241060
This patch adds a new command-line flag "-fshrink-wrap-separate", a status
flag "shrink_wrapped_separate", hooks for abstracting the target components,
and documentation for all those.
* common.opt (-fshrink-wrap-separate): New flag.
* doc/invoke.texi: Document it.
* doc/tm.texi.in (Shrink-wrapping separate components): New subsection.
* doc/tm.texi: Regenerate.
* emit-rtl.h (struct rtl_data): New field shrink_wrapped_separate.
* target.def (shrink_wrap): New hook vector.
(get_separate_components, components_for_bb, disqualify_components,
emit_prologue_components, emit_epilogue_components,
set_handled_components): New hooks.
From-SVN: r241059
* config/rs6000/rs6000.c (rs6000_return_in_memory): Warn for
vector return by reference only if -Wpsabi.
(rs6000_pass_by_reference): Similarly, for argument passing.
From-SVN: r241058
gcc/ChangeLog:
* function-tests.c: Include "print-rtl.h".
(selftest::test_expansion_to_rtl): Call print_rtx_function on the
function, and verify what is dumped.
* print-rtl-function.c (print_edge): New function.
(begin_any_block): New function.
(end_any_block): New function.
(can_have_basic_block_p): New function.
(print_rtx_function): Track the basic blocks of insns in the
chain, wrapping those that are within blocks within "(block)"
directives. Remove the "(cfg)" directive.
From-SVN: r241057
GCC used to give warnings for line # 1 for these, but it prints no
line number anymore. Adjust.
gcc/testsuite/
* gcc.target/powerpc/warn-1.c: Change line number in dg-warning.
* gcc.target/powerpc/warn-2.c: Ditto.
From-SVN: r241056
2016-10-12 Yannick Moy <moy@adacore.com>
* einfo.adb, einfo.ads (Partial_Refinement_Constituents): Take
into account constituents that are themselves abstract states
with full or partial refinement visible.
* sem_prag.adb (Find_Encapsulating_State): Move function
to library-level, to share between subprograms.
(Analyze_Refined_Global_In_Decl_Part): Use
Find_Encapsulating_State to get relevant encapsulating state.
2016-10-12 Arnaud Charlet <charlet@adacore.com>
* gnat1drv.adb: Fix minor typo.
From-SVN: r241052
Since sparc is a valid architecture, the name of
getrandom_linux_sparc.go means that it will be ignored on sparc64,
even though it's whitelisted with a +build line.
On SPARC, clone has a unique return value convention which requires
some inline assembly to convert it to the normal convention.
Reviewed-on: https://go-review.googlesource.com/30873
From-SVN: r241051
2016-10-12 Yannick Moy <moy@adacore.com>
* sem_prag.adb (Analyze_Refined_Depends_In_Decl_Part): Adapt checking
for optional refinement of abstract state with partial
visible refinement.
(Analyze_Refined_Global_In_Decl_Part): Adapt checking for optional
refinement of abstract state with partial visible refinement. Implement
new rules in SPARK RM 7.2.4 related to optional refinement.
Also fix the missing detection of missing items.
From-SVN: r241050
2016-10-12 Hristian Kirtchev <kirtchev@adacore.com>
* einfo.adb Add new usage for Elist29 and Node35.
(Anonymous_Designated_Type): New routine.
(Anonymous_Master): Removed.
(Anonymous_Masters): New routine.
(Set_Anonymous_Designated_Type): New routine.
(Set_Anonymous_Master): Removed.
(Set_Anonymous_Masters): New routine.
(Write_Field29_Name): Add output for Anonymous_Masters.
(Write_Field35_Name): Remove the output for Anonymous_Master. Add
output for Anonymous_Designated_Type.
* einfo.ads Remove attribute Anonymous_Master along with
usage in entities. Add attributes Anonymous_Designated_Type
and Anonymous_Masters along with usage in entities.
(Anonymous_Designated_Type): New routine along with pragma Inline.
(Anonymous_Master): Removed along with pragma Inline.
(Anonymous_Masters): New routine along with pragma Inline.
(Set_Anonymous_Designated_Type): New routine along with pragma Inline.
(Set_Anonymous_Master): Removed along with pragma Inline.
(Set_Anonymous_Masters): New routine along with pragma Inline.
* exp_ch7.adb (Build_Anonymous_Master): Reuse an anonymous master
defined in the same unit if it services the same designated
type, otherwise create a new one.
(Create_Anonymous_Master): Reimplemented.
(Current_Anonymous_Master): New routine.
(In_Subtree): Removed.
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb (Analyze_Pragma, case Dynamic_Predicate):
Check properly whether there is an explicit assertion policy
for predicate checking, even in the presence of a general Ignore
assertion policy.
2016-10-12 Steve Baird <baird@adacore.com>
* sem.adb (Walk_Library_Items): Cope with ignored ghost units.
From-SVN: r241049
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* lib-writ.adb (Write_ALI): Removal of unused file entries from
dependency list must be performed before the list is sorted,
so that the dependency number of other files is properly set-up
for use in tools that relate entity information to the unit in
which they are declared.
2016-10-12 Hristian Kirtchev <kirtchev@adacore.com>
* exp_aggr.adb (Initialize_Ctrl_Array_Component):
Create a copy of the initialization expression to avoid sharing
it between multiple components.
2016-10-12 Yannick Moy <moy@adacore.com>
* einfo.adb, einfo.ads (Has_Partial_Visible_Refinement): New flag
in abtract states.
(Has_Non_Null_Visible_Refinement): Return true for patial refinement.
(Partial_Refinement_Constituents): New function returns the full or
partial refinement constituents depending on scope.
* sem_ch3.adb (Analyze_Declarations): Remove partial visible
refinements when exiting the scope of a package spec or body
and those partial refinements are not in scope afterwards.
* sem_ch7.adb, sem_ch7.ads (Install_Partial_Declarations): Mark
abstract states of parent units with partial refinement so that
it is visible.
* sem_prag.adb (Analyze_Part_Of_In_Decl_Part): Mark enclosing
abstract state if any as having partial refinement in that scope.
(Analyze_Refined_Global_In_Decl_Part): Check constituent usage
based on full or partial refinement depending on scope.
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* exp_ch4.adb (Expand_N_Type_Conversion): If the target type
has an invariant aspect, insert invariant call at the proper
place in the code rather than rewriting the expression as an
expression with actions, to prevent spurious semantic errors on
the rewritten conversion when it is the object in a renaming.
From-SVN: r241048
2016-10-12 Justin Squirek <squirek@adacore.com>
* sem_ch10.adb (Remove_Limited_With_Clause): Add a check to
detect accidental visibility.
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* exp_ch4.adb (Expand_Allocator): If the expression is a qualified
expression, add a predicate check after the constraint check.
* sem_res.adb (Resolve_Qualified_Expression): If context is an
allocator, do not apply predicate check, as it will be done when
allocator is expanded.
From-SVN: r241040
2016-10-12 Bob Duff <duff@adacore.com>
* xref_lib.adb: Use renamings-of-slices to ensure
that all references to Tables are properly bounds checked (when
checks are turned on).
* g-dyntab.ads, g-dyntab.adb: Default-initialize the array
components, so we don't get uninitialized pointers in case
of Tables containing access types. Misc cleanup of the code
and comments.
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* sem_attr.adb (Analyze_Attribute, case 'Type_Key): Implement
functionality of attribute, to provide a reasonably unique key
for a given type and detect any changes in the semantics of the
type or any of its subcomponents from version to version.
2016-10-12 Bob Duff <duff@adacore.com>
* sem_case.adb (Check_Choice_Set): Separate
checking for duplicates out into a separate pass from checking
full coverage, because the check for duplicates does not depend
on predicates. Therefore, we shouldn't do it separately for the
predicate vs. no-predicate case; we should share code. The code
for the predicate case was wrong.
From-SVN: r241039
2016-10-12 Jerome Lambourg <lambourg@adacore.com>
* init.c: Make sure to call finit on x86_64-vx7 to reinitialize
the FPU unit.
2016-10-12 Arnaud Charlet <charlet@adacore.com>
* lib-load.adb (Load_Unit): Generate an error message even when
Error_Node is null.
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* lib-writ.adb (Write_ALI): Disable optimization related to transitive
limited_with clauses for now.
2016-10-12 Javier Miranda <miranda@adacore.com>
* sem_attr.adb (Analyze_Attribute_Old_Result): Generating C
code handle 'old located in inlined _postconditions procedures.
(Analyze_Attribute [Attribute_Result]): Handle 'result when
rewriting the attribute as a reference to the formal parameter
_Result of inlined _postconditions procedures.
2016-10-12 Tristan Gingold <gingold@adacore.com>
* s-rident.ads (Profile_Info): Remove
Max_Protected_Entries restriction from GNAT_Extended_Ravenscar
* sem_ch9.adb (Analyze_Protected_Type_Declaration):
Not a controlled type on restricted runtimes.
2016-10-12 Gary Dismukes <dismukes@adacore.com>
* sem_ch3.adb (Derive_Subprogram): Add test
for Is_Controlled of Parent_Type when determining whether an
inherited subprogram with one of the special names Initialize,
Adjust, or Finalize should be derived with its normal name even
when inherited as a private operation (which would normally
result in the inherited operation having a special "hidden" name).
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* sem_res.adb (Resolve_Call): If a function call returns a
limited view of a type replace it with the non-limited view,
which must be available when compiling call. This was already
done elsewhere for non-overloaded calls, but needs to be done
after resolution if function name is overloaded.
2016-10-12 Javier Miranda <miranda@adacore.com>
* a-tags.adb (IW_Membership [private]): new overloaded
subprogram that factorizes the code needed to check if a
given type implements an interface type.
(IW_Membership
[public]): invoke the new internal IW_Membership function.
(Is_Descendant_At_Same_Level): Fix this routine to implement RM
3.9 (12.3/3)
From-SVN: r241036
2016-10-12 Tristan Gingold <gingold@adacore.com>
* exp_ch9.adb (Expand_N_Delay_Relative_Statement): Add support
for a secondary procedure in case of missing Ada.Calendar.Delays
* rtsfind.ads (RTU_Id): Add System_Relative_Delays.
(RE_Id): Add RO_RD_Delay_For.
* rtsfind.adb (Output_Entity_Name): Handle correctly units RO_XX.
* s-rident.ads: Remove No_Relative_Delays
restriction for GNAT_Extended_Ravenscar.
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* sem_elab.adb (Within_Initial_Condition): When deternining
the context of the expression, use the original node if it is
a pragma, because Check pragmas are rewritten as conditionals
when assertions are not enabled.
2016-10-12 Bob Duff <duff@adacore.com>
* spitbol_table.ads, spitbol_table.adb (Adjust, Finalize): Add
"overriding".
2016-10-12 Bob Duff <duff@adacore.com>
* a-strunb-shared.ads, a-strunb-shared.adb (Finalize):
Make sure Finalize is idempotent.
(Unreference): Check for
Empty_Shared_String, in case the reference count of the empty
string wraps around.
Also add "not null" in various places that can't be null.
2016-10-12 Jerome Lambourg <lambourg@adacore.com>
* init.c: Fix sigtramp with the x86_64-vx7-vxsim target on
Windows host.
2016-10-12 Vadim Godunko <godunko@adacore.com>
* s-os_lib.ads (Is_Owner_Readable_File): Renamed from
Is_Readable_File.
(Is_Owner_Writable_File): Renamed from Is_Writable_File.
(Is_Readable_File): Renames Is_Read_Accessible_File.
(Is_Writable_File): Renames Is_Write_Accessible_File.
From-SVN: r241035
* doc/xml/manual/intro.xml: Document LWG 2442 status.
* include/std/mutex [_GLIBCXX_HAVE_TLS] (__once_call_impl): Remove.
[_GLIBCXX_HAVE_TLS] (_Once_call): Declare primary template and define
partial specialization to unpack args and forward to std::invoke.
(call_once) [_GLIBCXX_HAVE_TLS]: Use forward_as_tuple and _Once_call
instead of __bind_simple and __once_call_impl.
(call_once) [!_GLIBCXX_HAVE_TLS]: Use __invoke instead of
__bind_simple.
* testsuite/30_threads/call_once/dr2442.cc: New test.
From-SVN: r241031
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* sem_ch12.adb (Check_Formal_Package_Instance): Skip an internal
formal entity without a parent only if the corresponding actual
entity has a different kind.
* exp_ch9.adb (Build_Class_Wide_Master): If the master is
declared locally, insert the renaming declaration after the
master declaration, to prevent access before elaboration in gigi.
From-SVN: r241029
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* contracts.adb (Analyze_Contracts): For a type declaration, analyze
an iterable aspect when present.
From-SVN: r241028
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* sem_ch12.adb (Check_Formal_Package_Instance): Handle properly
an instance of a formal package with defaults, when defaulted
parameters include tagged private types and array types.
2016-10-12 Tristan Gingold <gingold@adacore.com>
* restrict.ads, restrict.adb (Restricted_Profile): Adjust
comment, use Restricted_Tasking to compare restrictions.
* s-rident.ads (Profile_Name): Add Restricted_Tasking and
reorder literals.
(Profile_Info): Set restrictions for Restricted_Tasking.
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Analyze_Full_Type_Declaration): Set Ghost status
of type before elaborating inherited operations, so that the
Ghost status is set properly for them.
* ghost.adb (Check_Ghost_Overriding): A ghost subprogram can
override an abstract subprogram coming from an interface
operation.
From-SVN: r241026
2016-10-12 Eric Botcazou <ebotcazou@adacore.com>
PR ada/64057
* exp_ch5.adb (Is_Non_Local_Array): Return true for every array
that is not a component or slice of an entity in the current
scope.
From-SVN: r241025
This enhances location description generation so that the generated
opcodes for integer literals are as space-efficient when HOST_WIDE_INT
is 64-bits large than when it's 32-bits large. In particular, this
reduces the size of the opcodes generated to produce big unsigned
literals using small literal integers instead.
gcc/
* dwarf2out.c (int_loc_descriptor): Generate opcodes for another
equivalent 32-bit constant (modulo 2**32) when that yields
smaller instructions.
(size_of_int_loc_descriptor): Update accordingly.
gcc/testsuite/
* gnat.dg/debug8.adb: New testcase.
From-SVN: r241024
In Ada, it is possible to have nested subprograms in the following
configuration:
procedure Parent is
type T;
[...]
procedure Child (Value : T) is
begin
[...]
end Child;
begin
[...]
end Parent;
As we currently generate debugging information for Child first before
Parent, the debug info for T appears in global scope since the DIE for
Parent does not exist yet.
This patch makes sure that when we generate early debug info for a
nested function, we trigger generation for the parent function first.
gcc/
* dwarf2out.c (dwarf2out_early_global_decl): For nested
functions, call dwarf2out_decl on the parent function first.
gcc/testsuite/
* gnat.dg/debug9.adb: New testcase.
From-SVN: r241023
* tree-ssa-propagate.c
(substitute_and_fold_dom_walker::before_dom_children): Do not
ignore ASSERT_EXPRs but only preserve them.
* tree-vrp.c (remove_range_assertions): Deal with ASSERT_EXPRs
that have been propagated into.
(vrp_finalize): Enable DCE for substitute_and_fold.
* gcc.dg/tree-ssa/vrp35.c: Adjust.
* gcc.dg/tree-ssa/vrp36.c: Likewise.
* gcc.dg/tree-ssa/vrp46.c: Likewise.
From-SVN: r241021
2016-10-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/77920
* tree-vrp.c (simplify_div_or_mod_using_ranges): Simplify.
(simplify_min_or_max_using_ranges): Pass in gsi and use it.
(simplify_abs_using_ranges): Likewise.
(simplify_conversion_using_ranges): Likewise.
(simplify_stmt_using_ranges): Adjust.
* gcc.dg/torture/pr77920.c: New testcase.
From-SVN: r241020
* common.opt (Wimplicit-fallthrough) Turn into alias to
-Wimplicit-fallthrough=3. Remove EnabledBy.
(Wimplicit-fallthrough=): New option.
* gimplify.c (warn_implicit_fallthrough_r): Use
OPT_Wimplicit_fallthrough_ instead of OPT_Wimplicit_fallthrough.
* doc/invoke.texi (-Wimplicit-fallthrough): Document as alias
to -Wimplicit-fallthrough=3.
(-Wimplicit-fallthrough=): Document.
gcc/c-family/
* c.opt (Wextra): Add as C/C++/ObjC/ObjC++ option.
(Wimplicit-fallthrough=): Enable for these languages by -Wextra.
* c-opts.c (sanitize_cpp_opts): Initialize
cpp_opts->cpp_warn_implicit_fallthrough.
gcc/testsuite/
* c-c++-common/Wimplicit-fallthrough-25.c: New test.
* c-c++-common/Wimplicit-fallthrough-26.c: New test.
* c-c++-common/Wimplicit-fallthrough-27.c: New test.
* c-c++-common/Wimplicit-fallthrough-28.c: New test.
* c-c++-common/Wimplicit-fallthrough-29.c: New test.
* c-c++-common/Wimplicit-fallthrough-30.c: New test.
* c-c++-common/Wimplicit-fallthrough-31.c: New test.
* c-c++-common/Wimplicit-fallthrough-32.c: New test.
* c-c++-common/Wimplicit-fallthrough-33.c: New test.
libcpp/
* include/cpplib.h (struct cpp_options): Add
cpp_warn_implicit_fallthrough.
* init.c (cpp_create_reader): Initialize it to 0.
* lex.c (fallthrough_comment_p): Handle different
cpp_warn_implicit_fallthrough levels. Whitespace fixes.
From-SVN: r241013