Blame SOURCES/gcc48-rh1535655-6.patch

343cc1
commit 5315d05c7295fbb9345d85d6bf7cbe7c975a19c8
343cc1
Author: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
343cc1
Date:   Tue Jan 16 11:22:01 2018 +0000
343cc1
343cc1
    HJ patch #5
343cc1
343cc1
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
343cc1
index e73389b..15cfe83 100644
343cc1
--- a/gcc/config/i386/i386.c
343cc1
+++ b/gcc/config/i386/i386.c
343cc1
@@ -4634,6 +4634,19 @@ ix86_set_indirect_branch_type (tree fndecl)
343cc1
 	}
343cc1
       else
343cc1
 	cfun->machine->indirect_branch_type = ix86_indirect_branch;
343cc1
+
343cc1
+      /* -mcmodel=large is not compatible with -mindirect-branch=thunk
343cc1
+	 nor -mindirect-branch=thunk-extern.  */
343cc1
+      if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
343cc1
+	  && ((cfun->machine->indirect_branch_type
343cc1
+	       == indirect_branch_thunk_extern)
343cc1
+	      || (cfun->machine->indirect_branch_type
343cc1
+		  == indirect_branch_thunk)))
343cc1
+	error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
343cc1
+	       "compatible",
343cc1
+	       ((cfun->machine->indirect_branch_type
343cc1
+		 == indirect_branch_thunk_extern)
343cc1
+		? "thunk-extern" : "thunk"));
343cc1
     }
343cc1
 
343cc1
   if (cfun->machine->function_return_type == indirect_branch_unset)
343cc1
@@ -4659,6 +4672,19 @@ ix86_set_indirect_branch_type (tree fndecl)
343cc1
 	}
343cc1
       else
343cc1
 	cfun->machine->function_return_type = ix86_function_return;
343cc1
+
343cc1
+      /* -mcmodel=large is not compatible with -mfunction-return=thunk
343cc1
+	 nor -mfunction-return=thunk-extern.  */
343cc1
+      if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
343cc1
+	  && ((cfun->machine->function_return_type
343cc1
+	       == indirect_branch_thunk_extern)
343cc1
+	      || (cfun->machine->function_return_type
343cc1
+		  == indirect_branch_thunk)))
343cc1
+	error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
343cc1
+	       "compatible",
343cc1
+	       ((cfun->machine->function_return_type
343cc1
+		 == indirect_branch_thunk_extern)
343cc1
+		? "thunk-extern" : "thunk"));
343cc1
     }
343cc1
 }
343cc1
 
343cc1
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
343cc1
index 4a365c7..7b33803 100644
343cc1
--- a/gcc/doc/invoke.texi
343cc1
+++ b/gcc/doc/invoke.texi
343cc1
@@ -14659,6 +14659,11 @@ to external call and return thunk provided in a separate object file.
343cc1
 You can control this behavior for a specific function by using the
343cc1
 function attribute @code{indirect_branch}.  @xref{Function Attributes}.
343cc1
 
343cc1
+Note that @option{-mcmodel=large} is incompatible with
343cc1
+@option{-mindirect-branch=thunk} nor
343cc1
+@option{-mindirect-branch=thunk-extern} since the thunk function may
343cc1
+not be reachable in large code model.
343cc1
+
343cc1
 @item -mfunction-return=@var{choice}
343cc1
 @opindex -mfunction-return
343cc1
 Convert function return with @var{choice}.  The default is @samp{keep},
343cc1
@@ -14670,6 +14675,11 @@ object file.  You can control this behavior for a specific function by
343cc1
 using the function attribute @code{function_return}.
343cc1
 @xref{Function Attributes}.
343cc1
 
343cc1
+Note that @option{-mcmodel=large} is incompatible with
343cc1
+@option{-mfunction-return=thunk} nor
343cc1
+@option{-mfunction-return=thunk-extern} since the thunk function may
343cc1
+not be reachable in large code model.
343cc1
+
343cc1
 @item -mindirect-branch-register
343cc1
 @opindex -mindirect-branch-register
343cc1
 Force indirect call and jump via register.
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
343cc1
new file mode 100644
343cc1
index 0000000..a0674bd
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-10.c
343cc1
@@ -0,0 +1,7 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mindirect-branch=thunk-inline -mfunction-return=keep -mcmodel=large" } */
343cc1
+
343cc1
+void
343cc1
+bar (void)
343cc1
+{
343cc1
+}
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
343cc1
new file mode 100644
343cc1
index 0000000..7a80a89
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-8.c
343cc1
@@ -0,0 +1,7 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mindirect-branch=thunk -mfunction-return=keep -mcmodel=large" } */
343cc1
+
343cc1
+void
343cc1
+bar (void)
343cc1
+{ /* { dg-error "'-mindirect-branch=thunk' and '-mcmodel=large' are not compatible" } */
343cc1
+}
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
343cc1
new file mode 100644
343cc1
index 0000000..d4d45c5
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-9.c
343cc1
@@ -0,0 +1,7 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mindirect-branch=thunk-extern -mfunction-return=keep -mcmodel=large" } */
343cc1
+
343cc1
+void
343cc1
+bar (void)
343cc1
+{ /* { dg-error "'-mindirect-branch=thunk-extern' and '-mcmodel=large' are not compatible" } */
343cc1
+}
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
343cc1
new file mode 100644
343cc1
index 0000000..3a2aead
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-10.c
343cc1
@@ -0,0 +1,9 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
343cc1
+/* { dg-additional-options "-fPIC" { target fpic } } */
343cc1
+
343cc1
+__attribute__ ((indirect_branch("thunk-extern")))
343cc1
+void
343cc1
+bar (void)
343cc1
+{ /* { dg-error "'-mindirect-branch=thunk-extern' and '-mcmodel=large' are not compatible" } */
343cc1
+}
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
343cc1
new file mode 100644
343cc1
index 0000000..8e52f03
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-11.c
343cc1
@@ -0,0 +1,9 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
343cc1
+/* { dg-additional-options "-fPIC" { target fpic } } */
343cc1
+
343cc1
+__attribute__ ((indirect_branch("thunk-inline")))
343cc1
+void
343cc1
+bar (void)
343cc1
+{
343cc1
+}
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
343cc1
new file mode 100644
343cc1
index 0000000..bdaa4f6
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-9.c
343cc1
@@ -0,0 +1,9 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mindirect-branch=keep -mfunction-return=keep -mcmodel=large" } */
343cc1
+/* { dg-additional-options "-fPIC" { target fpic } } */
343cc1
+
343cc1
+__attribute__ ((indirect_branch("thunk")))
343cc1
+void
343cc1
+bar (void)
343cc1
+{ /* { dg-error "'-mindirect-branch=thunk' and '-mcmodel=large' are not compatible" } */
343cc1
+}
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-17.c b/gcc/testsuite/gcc.target/i386/ret-thunk-17.c
343cc1
new file mode 100644
343cc1
index 0000000..0605e2c
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-17.c
343cc1
@@ -0,0 +1,7 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=keep -mcmodel=large" } */
343cc1
+
343cc1
+void
343cc1
+bar (void)
343cc1
+{ /* { dg-error "'-mfunction-return=thunk' and '-mcmodel=large' are not compatible" } */
343cc1
+}
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-18.c b/gcc/testsuite/gcc.target/i386/ret-thunk-18.c
343cc1
new file mode 100644
343cc1
index 0000000..307019d
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-18.c
343cc1
@@ -0,0 +1,8 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=keep -mcmodel=large" } */
343cc1
+/* { dg-additional-options "-fPIC" { target fpic } } */
343cc1
+
343cc1
+void
343cc1
+bar (void)
343cc1
+{ /* { dg-error "'-mfunction-return=thunk-extern' and '-mcmodel=large' are not compatible" } */
343cc1
+}
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-19.c b/gcc/testsuite/gcc.target/i386/ret-thunk-19.c
343cc1
new file mode 100644
343cc1
index 0000000..772617f
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-19.c
343cc1
@@ -0,0 +1,8 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
343cc1
+
343cc1
+__attribute__ ((function_return("thunk")))
343cc1
+void
343cc1
+bar (void)
343cc1
+{ /* { dg-error "'-mfunction-return=thunk' and '-mcmodel=large' are not compatible" } */
343cc1
+}
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-20.c b/gcc/testsuite/gcc.target/i386/ret-thunk-20.c
343cc1
new file mode 100644
343cc1
index 0000000..1e9f9bd
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-20.c
343cc1
@@ -0,0 +1,9 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
343cc1
+/* { dg-additional-options "-fPIC" { target fpic } } */
343cc1
+
343cc1
+__attribute__ ((function_return("thunk-extern")))
343cc1
+void
343cc1
+bar (void)
343cc1
+{ /* { dg-error "'-mfunction-return=thunk-extern' and '-mcmodel=large' are not compatible" } */
343cc1
+}
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-21.c b/gcc/testsuite/gcc.target/i386/ret-thunk-21.c
343cc1
new file mode 100644
343cc1
index 0000000..eea07f7
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-21.c
343cc1
@@ -0,0 +1,9 @@
343cc1
+/* { dg-do compile { target { lp64 } } } */
343cc1
+/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -mcmodel=large" } */
343cc1
+/* { dg-additional-options "-fPIC" { target fpic } } */
343cc1
+
343cc1
+__attribute__ ((function_return("thunk-inline")))
343cc1
+void
343cc1
+bar (void)
343cc1
+{
343cc1
+}