OSDN Git Service

2009-04-20 Eric Botcazou <ebotcazou@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Apr 2009 09:02:17 +0000 (09:02 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Apr 2009 09:02:17 +0000 (09:02 +0000)
* adaint.h (__gnat_lwp_self): Declare on Linux.

* adaint.c (__gnat_os_filename): Add ATTRIBUTE_UNUSED on 'filename'.

2009-04-20  Robert Dewar  <dewar@adacore.com>

* exp_ch5.adb, usage.adb, back_end.adb, opt.ads: Implement
front-end part of -fpreserve-control-flow switch.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146376 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/adaint.c
gcc/ada/adaint.h
gcc/ada/back_end.adb
gcc/ada/exp_ch5.adb
gcc/ada/opt.ads
gcc/ada/usage.adb

index ef790b2..aec5ecc 100644 (file)
@@ -1,3 +1,14 @@
+2009-04-20  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * adaint.h (__gnat_lwp_self): Declare on Linux.
+
+       * adaint.c (__gnat_os_filename): Add ATTRIBUTE_UNUSED on 'filename'.
+
+2009-04-20  Robert Dewar  <dewar@adacore.com>
+
+       * exp_ch5.adb, usage.adb, back_end.adb, opt.ads: Implement
+       front-end part of -fpreserve-control-flow switch.
+
 2009-04-20  Bob Duff  <duff@adacore.com>
 
        * rtsfind.adb: Minor comment fix
index e49e0f0..0047e44 100644 (file)
@@ -666,7 +666,8 @@ __gnat_get_debuggable_suffix_ptr (int *len, const char **value)
 /* Returns the OS filename and corresponding encoding.  */
 
 void
-__gnat_os_filename (char *filename, char *w_filename ATTRIBUTE_UNUSED,
+__gnat_os_filename (char *filename ATTRIBUTE_UNUSED,
+                   char *w_filename ATTRIBUTE_UNUSED,
                    char *os_name, int *o_length,
                    char *encoding ATTRIBUTE_UNUSED, int *e_length)
 {
@@ -3512,7 +3513,8 @@ __gnat_pthread_setaffinity_np (pthread_t th ATTRIBUTE_UNUSED,
    thread. We need to do a system call in order to retrieve this
    information. */
 #include <sys/syscall.h>
-void *__gnat_lwp_self (void) {
+void *__gnat_lwp_self (void)
+{
    return (void *) syscall (__NR_gettid);
 }
 #endif
index 2ecaf73..46c1f2f 100644 (file)
@@ -176,6 +176,9 @@ extern int    __gnat_dup2                      (int, int);
 
 extern void   __gnat_os_filename                   (char *, char *, char *,
                                                    int *, char *, int *);
+#if defined (linux)
+extern void   *__gnat_lwp_self                    (void);
+#endif
 
 #if defined (__MINGW32__) && !defined (RTX)
 extern void   __gnat_plist_init                    (void);
index 7a4e4da..baf3ffd 100644 (file)
@@ -219,6 +219,13 @@ package body Back_End is
 
             if Switch_Chars (First .. Last) = "fno-inline" then
                Opt.Suppress_All_Inlining := True;
+
+            --  Another special check, the switch -fpreserve-control-flow
+            --  which is also a back end switch sets the front end flag
+            --  that inhibits improper control flow transformations.
+
+            elsif Switch_Chars (First .. Last) = "fpreserve-control-flow" then
+               Opt.Suppress_Control_Flow_Optimizations := True;
             end if;
          end if;
       end Scan_Back_End_Switches;
index 5008f4c..6afcc6f 100644 (file)
@@ -3272,9 +3272,12 @@ package body Exp_Ch5 is
 
       --     return not (expression);
 
-      --  Only do these optimizations if we are at least at -O1 level
+      --  Only do these optimizations if we are at least at -O1 level and
+      --  do not do them if control flow optimizations are suppressed.
 
-      if Optimization_Level > 0 then
+      if Optimization_Level > 0
+        and then not Opt.Suppress_Control_Flow_Optimizations
+      then
          if Nkind (N) = N_If_Statement
            and then No (Elsif_Parts (N))
            and then Present (Else_Statements (N))
index 4964534..9b8cf0b 100644 (file)
@@ -1061,6 +1061,11 @@ package Opt is
    --  Set by -fno-inline. Suppresses all inlining, both front end and back end
    --  regardless of any other switches that are set.
 
+   Suppress_Control_Flow_Optimizations : Boolean := False;
+   --  GNAT
+   --  Set by -fpreserve-control-flow. Suppresses control flow optimizations
+   --  that interfere with coverage analysis based on the object code.
+
    System_Extend_Pragma_Arg : Node_Id := Empty;
    --  GNAT
    --  Set non-empty if and only if a correct Extend_System pragma was present
index 55a3f49..76d9a25 100644 (file)
@@ -99,6 +99,9 @@ begin
 
       Write_Switch_Char ("fno-inline   ", "");
       Write_Line ("Inhibit all inlining (makes executable smaller)");
+
+      Write_Switch_Char ("fpreserve-control-flow ", "");
+      Write_Line ("Preserve control flow for coverage analysis");
    end if;
 
    --  Common switches available to both GCC and JGNAT