Fix one more bug in code generation...
Example code:
int foo()
{
unsigned int x = 0xf2a3e218;
return ((int*)x)[0];
}
[email protected]
Review URL: https://chromiumcodereview.appspot.com/10389146
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index fc37c41..792a9f6 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -9377,6 +9377,25 @@
return 0;
}
}
+ /* Disallow direct access to addresses between 2GB and 4GB.
+
+ Example problem code:
+ int f()
+ {
+ unsigned int x = 0xf2a3e218;
+ return ((int*)x)[0];
+ }
+
+ Incorrect assembly generated with -O2:
+ movl -224140776(%r15), %eax
+
+ Correct assembly generated with -O2:
+ movl $4070826520, %eax
+ movl %nacl:(%r15,%rax), %eax */
+ if (TARGET_64BIT && TARGET_NACL
+ && !index_reg && base_reg && REGNO (base_reg) == R15_REG
+ && GET_CODE (disp) == CONST_INT && INTVAL (disp) < 0)
+ return 0;
/* Allow arg pointer and stack pointer as index if there is not scaling. */
if (base_reg && index_reg && scale == 1