diff mbox

[target/x86_64] PR 63538

Message ID CAAs8HmzwCvBxexapyZv1siCLWi2mi1N4GEt8+RciqW=PsmhmVw@mail.gmail.com
State New
Headers show

Commit Message

Sriraman Tallam Oct. 16, 2014, 10:15 p.m. UTC
Hi,

   I have attached patch for bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63538

Please review.

Thanks
Sri
With -mcmodel=medium, .lrodata accesses must use far address.  Here 
the check for TREE_CODE(decl) == VAR_DECL in function ix86_encode_section_info
is removed as this does not handle STRING_CST and other. This is anyway 
done in ix86_in_large_data_p.

	* config/i386/i386.c (ix86_encode_section_info): Remove check for
	VAR_DECL.
	* gcc.dg/pr63538.c: New test.
diff mbox

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 216289)
+++ config/i386/i386.c	(working copy)
@@ -41387,8 +41387,7 @@  ix86_encode_section_info (tree decl, rtx rtl, int
 {
   default_encode_section_info (decl, rtl, first);
 
-  if (TREE_CODE (decl) == VAR_DECL
-      && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))
+  if ((TREE_STATIC (decl) || DECL_EXTERNAL (decl))
       && ix86_in_large_data_p (decl))
     SYMBOL_REF_FLAGS (XEXP (rtl, 0)) |= SYMBOL_FLAG_FAR_ADDR;
 }
Index: testsuite/gcc.dg/pr63538.c
===================================================================
--- testsuite/gcc.dg/pr63538.c	(revision 0)
+++ testsuite/gcc.dg/pr63538.c	(revision 0)
@@ -0,0 +1,14 @@ 
+/* PR63538 is about not using 64-bit addresses for .lrodata accesses when it
+   involves STRING_CSTs.  */
+/* { dg-do compile { target x86_64-*-* } } */
+/* { dg-options "-O2 -mcmodel=medium -mlarge-data-threshold=0" { target x86_64-*-* } } */
+
+#include <stdio.h>
+
+const char *str = "Hello World";
+
+int main() {
+ printf("str = %p %s\n",str, str);
+ return 0;
+}
+/* { dg-final { scan-assembler-not "movl" } } */