This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, rtl-optimization]: Fix TRAP_IF dependencies by forcing pending loads to memory


On 05/19/2016 11:02 AM, Uros Bizjak wrote:
Hello!

I was looking at recent g++.dg/ext/sync-4.C testsuite FAILure on
alpha-linux-gnu. The testcase installs SIGSEGV handler and among other
tests, it does various tests with atomic operations on NULL addresses.

One test (f19):

FN(19, void, (__atomic_exchange((ditype*)p, (ditype*)0, (ditype*)0,
__ATOMIC_SEQ_CST)))

expands to following initial RTX sequence:

    5: r71:DI=0
    6: r70:DI=[r71:DI]
    7: {trap_if 0x1;use $29:DI;}
    8: barrier

where _.sched2 pass is free to reorder insns from

    6: $1:DI=[0]
      REG_UNUSED $1:DI
    7: {trap_if 0x1;use $29:DI;}
      REG_DEAD $29:DI
    8: barrier

to:

    7: {trap_if 0x1;use $29:DI;}
      REG_DEAD $29:DI
    6: $1:DI=[0]
      REG_UNUSED $1:DI
    8: barrier

resulting in:

$ ./a.out
Trace/breakpoint trap

Please note that handler is able to recover from SIGSEGV, but not from
SIGTRAP. If these two signals are reordered, the testcase fails.

Proposed patch solves this issue by also forcing pending loads to
memory. This way, memory access is ordered with trap insn, and the
testcase passes.

2016-05-19  Uros Bizjak  <ubizjak@gmail.com>

    * sched-deps.c (sched_analyze_2) <case TRAP_IF>: Also
    force pending loads from memory.

Patch was bootstrapped and regression tested on alphaev68-linux-gnu
and x86_64-linux-gnu {,-m32}.

OK for mainline and release branches?
OK.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]