Blame SOURCES/gcc48-rh1535655-6.patch

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