From: Arjan van de Ven Date: Thu, 27 Jul 2006 23:12:08 +0000 (+0000) Subject: 2006-07-27 Arjan van de Ven X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa6adcab9d8c2ff6be87e30fb663ede9a664b9ff;p=platform%2Fupstream%2Fgcc.git 2006-07-27 Arjan van de Ven * config/i386/i386.md (stack_tls_protect_set_di) Use %gs rather than %fs for -mcmodel=kernel. (stack_tls_protect_test_di): Likewise. * testsuite/gcc.target/i386/stack-prot-kernel.c: New test. From-SVN: r115782 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 40420e0..9a2580c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-07-27 Arjan van de Ven + + * config/i386/i386.md (stack_tls_protect_set_di) Use %gs rather than + %fs for -mcmodel=kernel. + (stack_tls_protect_test_di): Likewise. + 2006-07-27 Carlos O'Donell * Makefile.in: Use mkinstalldirs. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 00e06ba..4808853 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -20393,7 +20393,15 @@ (set (match_scratch:DI 2 "=&r") (const_int 0)) (clobber (reg:CC FLAGS_REG))] "TARGET_64BIT" - "mov{q}\t{%%fs:%P1, %2|%2, QWORD PTR %%fs:%P1}\;mov{q}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2" + { + /* The kernel uses a different segment register for performance reasons; a + system call would not have to trash the userspace segment register, + which would be expensive */ + if (ix86_cmodel != CM_KERNEL) + return "mov{q}\t{%%fs:%P1, %2|%2, QWORD PTR %%fs:%P1}\;mov{q}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2"; + else + return "mov{q}\t{%%gs:%P1, %2|%2, QWORD PTR %%gs:%P1}\;mov{q}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2"; + } [(set_attr "type" "multi")]) (define_expand "stack_protect_test" @@ -20461,7 +20469,15 @@ UNSPEC_SP_TLS_TEST)) (clobber (match_scratch:DI 3 "=r"))] "TARGET_64BIT" - "mov{q}\t{%1, %3|%3, %1}\;xor{q}\t{%%fs:%P2, %3|%3, QWORD PTR %%fs:%P2}" + { + /* The kernel uses a different segment register for performance reasons; a + system call would not have to trash the userspace segment register, + which would be expensive */ + if (ix86_cmodel != CM_KERNEL) + return "mov{q}\t{%1, %3|%3, %1}\;xor{q}\t{%%fs:%P2, %3|%3, QWORD PTR %%fs:%P2}"; + else + return "mov{q}\t{%1, %3|%3, %1}\;xor{q}\t{%%gs:%P2, %3|%3, QWORD PTR %%gs:%P2}"; + } [(set_attr "type" "multi")]) (include "sse.md") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cc0bc14..4cfaccf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2006-07-27 Arjan van de Ven + + * gcc.target/i386/stack-prot-kernel.c: New test. + 2006-07-27 Roger Sayle * gcc.dg/builtins-55.c: New test case. diff --git a/gcc/testsuite/gcc.target/i386/stack-prot-kernel.c b/gcc/testsuite/gcc.target/i386/stack-prot-kernel.c new file mode 100644 index 0000000..94fdf4f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/stack-prot-kernel.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-O2 -fstack-protector-all -mcmodel=kernel" } */ + +void test1 (int x) +{ + char p[40]; + int i; + for (i=0; i<40; i++) + p[i] = x; +} + +/* { dg-final { scan-assembler-not "%fs" } } */