diff mbox

[RFA] Minor erroneous path isolation followups

Message ID 5279DE82.1040703@redhat.com
State New
Headers show

Commit Message

Jeff Law Nov. 6, 2013, 6:15 a.m. UTC
Per a discussion between Richi and myself, this patch adds a 
__builtin_trap to the Java front end.  If someone could look at that 
code closely to ensure I didn't muck it up, I'd appreciated it.

With that code in the Java front-end, we can remove the hack from 
gate_isolate_erroneous_paths.

Finally, Ian noticed I didn't update invoke.texi.  For some silly reason 
I thought we'd get that from the various option definition files.

Bootstrapped and regression tested on x86_64-unknown-linux-gnu.  OK for 
the trunk?

	* doc/invoke.texi (-fisolate-erroneous-paths): Document.

	* gimple-ssa-isolate-paths.c (gate_isolate_erroneous_paths):
	No longer check if we have __builtin_trap, assume it's
	available.

	* java/builtins.c (initialize_builtins): Provide __builtin_trap.

Comments

Jakub Jelinek Nov. 6, 2013, 7:12 a.m. UTC | #1
On Tue, Nov 05, 2013 at 11:15:30PM -0700, Jeff Law wrote:
> 	* java/builtins.c (initialize_builtins): Provide __builtin_trap.

Without java/ ;)

> --- a/gcc/java/builtins.c
> +++ b/gcc/java/builtins.c
> @@ -580,6 +580,9 @@ initialize_builtins (void)
>  		  build_function_type_list (ptr_type_node, int_type_node, NULL_TREE),
>  		  "__builtin_return_address", ECF_NOTHROW | ECF_LEAF);
>  
> +  define_builtin (BUILT_IN_TRAP, "__builtin_trap",
> +		  build_function_type_list (void_type_node, NULL_TREE),
> +		  "__builtin_trap", ECF_NOTHROW | ECF_LEAF);

Missing ECF_NORETURN in there, which I'd say is quite essential for
__builtin_trap.

	Jakub
diff mbox

Patch

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 35f41d9..8fbe8ab 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -377,6 +377,7 @@  Objective-C and Objective-C++ Dialects}.
 -fira-region=@var{region} -fira-hoist-pressure @gol
 -fira-loop-pressure -fno-ira-share-save-slots @gol
 -fno-ira-share-spill-slots -fira-verbose=@var{n} @gol
+-fisolate-erroneous-paths @gol
 -fivopts -fkeep-inline-functions -fkeep-static-consts @gol
 -floop-block -floop-interchange -floop-strip-mine -floop-nest-optimize @gol
 -floop-parallelize-all -flto -flto-compression-level @gol
@@ -6735,6 +6736,7 @@  also turns on the following optimization flags:
 -finline-small-functions @gol
 -findirect-inlining @gol
 -fipa-sra @gol
+-fisolate-erroneous-paths @gol
 -foptimize-sibling-calls @gol
 -fpartial-inlining @gol
 -fpeephole2 @gol
@@ -7622,6 +7624,11 @@  it may significantly increase code size
 (see @option{--param ipcp-unit-growth=@var{value}}).
 This flag is enabled by default at @option{-O3}.
 
+@item -fisolate-erroneous-paths
+Detect paths which trigger erroneous or undefined behaviour.  Isolate those
+paths from the main control flow and turn the statement with erroneous or
+undefined behaviour into a trap.
+
 @item -ftree-sink
 @opindex ftree-sink
 Perform forward store motion  on trees.  This flag is
diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c
index 4868867..983ed4d 100644
--- a/gcc/gimple-ssa-isolate-paths.c
+++ b/gcc/gimple-ssa-isolate-paths.c
@@ -283,8 +283,7 @@  gate_isolate_erroneous_paths (void)
 {
   /* If we do not have a suitable builtin function for the trap statement,
      then do not perform the optimization.  */
-  return (flag_isolate_erroneous_paths != 0
-	  && builtin_decl_explicit (BUILT_IN_TRAP) != NULL);
+  return (flag_isolate_erroneous_paths != 0);
 }
 
 namespace {
diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c
index f971a6f..c8de217 100644
--- a/gcc/java/builtins.c
+++ b/gcc/java/builtins.c
@@ -580,6 +580,9 @@  initialize_builtins (void)
 		  build_function_type_list (ptr_type_node, int_type_node, NULL_TREE),
 		  "__builtin_return_address", ECF_NOTHROW | ECF_LEAF);
 
+  define_builtin (BUILT_IN_TRAP, "__builtin_trap",
+		  build_function_type_list (void_type_node, NULL_TREE),
+		  "__builtin_trap", ECF_NOTHROW | ECF_LEAF);
   build_common_builtin_nodes ();
 }