This is the mail archive of the gcc-bugs@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]

[Bug middle-end/50691] New: Incorrect argument evaluation in call with __thread argument


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50691

             Bug #: 50691
           Summary: Incorrect argument evaluation in call with __thread
                    argument
    Classification: Unclassified
           Product: gcc
           Version: 4.4.6
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: danglin@gcc.gnu.org
              Host: hppa-unknown-linux-gnu
            Target: hppa-unknown-linux-gnu
             Build: hppa-unknown-linux-gnu


This was found debugging the FAIL of the reuse test in mpfr-3.1.0.

We have in mpfr_log2:

 extern __thread mpfr_cache_t __gmpfr_cache_const_log2;
 mpfr_t t, tt;

 mpfr_cache(t, __gmpfr_cache_const_log2, MPFR_RNDD);

The generated assembly code is:

(gdb) disass $pc-64,$pc+32
Dump of assembler code from 0x403154d8 to 0x40315538:
  0x403154d8 <mpfr_log2+452>:    copy r4,r19
  0x403154dc <mpfr_log2+456>:    ldil L%-80000000,r11
  0x403154e0 <mpfr_log2+460>:    cmpiclr,<> 0,r7,r0
  0x403154e4 <mpfr_log2+464>:    addi 1,r13,r13
  0x403154e8 <mpfr_log2+468>:    ldi 20,r14
  0x403154ec <mpfr_log2+472>:    addil L%0,r19,r1
  0x403154f0 <mpfr_log2+476>:    ldo 7b4(r1),r12
  0x403154f4 <mpfr_log2+480>:    ldo 4(r11),r11
  0x403154f8 <mpfr_log2+484>:    copy r12,r26
  0x403154fc <mpfr_log2+488>:    b,l 0x403090e8,rp
  0x40315500 <mpfr_log2+492>:    copy r19,r4
  0x40315504 <mpfr_log2+496>:    copy r4,r19
  0x40315508 <mpfr_log2+500>:    copy ret0,r25
  0x4031550c <mpfr_log2+504>:    copy r19,r4
  0x40315510 <mpfr_log2+508>:    b,l 0x40309248,rp
  0x40315514 <mpfr_log2+512>:    ldi 3,r24
=> 0x40315518 <mpfr_log2+516>:    copy r4,r19

The call at 0x40315510 is the call to mpfr_cache.  The preceding
call at 0x403154fc is to __tls_get_addr.  The argument setup for
it has clobbered the argument setup of the first argument to the
call to mpfr_cache.

We have in .expand:

;; mpfr_cache (&t, &__gmpfr_cache_const_log2, 3);

(insn 210 209 211 ../../src/log2.c:118 (set (reg:SI 26 %r26)
       (reg/f:SI 90 virtual-stack-vars)) -1 (nil))

(insn 211 210 212 ../../src/log2.c:118 (parallel [
           (set (reg:SI 181)
               (unspec:SI [
                       (symbol_ref:SI ("__gmpfr_cache_const_log2") [flags 0x50]
<var_decl 0x402b2630 __gmpfr_cache_const_log2>)
                   ] 10))
           (clobber (reg:SI 1 %r1))
           (use (reg:SI 19 %r19))
       ]) -1 (nil))

(insn 212 211 213 ../../src/log2.c:118 (set (reg:SI 26 %r26)
       (reg:SI 181)) -1 (nil))

(call_insn/u 213 212 214 ../../src/log2.c:118 (parallel [
           (set (reg:SI 4 %r4)
               (reg:SI 19 %r19))
           (set (reg:SI 28 %r28)
               (call (mem:SI (symbol_ref/v:SI ("@__tls_get_addr") [flags 0x41])
[0 S4 A32])
                   (const_int 64 [0x40])))
           (clobber (reg:SI 1 %r1))
           (clobber (reg:SI 2 %r2))
           (use (reg:SI 4 %r4))
           (use (reg:SI 19 %r19))
           (use (const_int 0 [0x0]))
       ]) -1 (expr_list:REG_EH_REGION (const_int 0 [0x0])
       (nil))
   (expr_list:REG_DEP_TRUE (use (reg:SI 26 %r26))
       (nil)))

(insn 214 213 215 ../../src/log2.c:118 (set (reg:SI 182)
       (reg:SI 28 %r28)) -1 (nil))

(insn 215 214 216 ../../src/log2.c:118 (set (reg:SI 25 %r25)
       (reg:SI 182)) -1 (expr_list:REG_EQUAL (symbol_ref:SI
("__gmpfr_cache_const_log2") [flags 0x50] <var_decl 0x402b2630
__gmpfr_cache_const_log2>)
       (nil)))

(insn 216 215 217 ../../src/log2.c:118 (set (reg:SI 24 %r24)
       (const_int 3 [0x3])) -1 (nil))

(call_insn 217 216 0 ../../src/log2.c:118 (parallel [
           (set (reg:SI 4 %r4)
               (reg:SI 19 %r19))
           (set (reg:SI 28 %r28)
               (call (mem:SI (symbol_ref/v:SI ("@mpfr_cache") [flags 0x41]
<function_decl 0x402fea00 mpfr_cache>) [0 S4 A32])
                   (const_int 16 [0x10])))
           (clobber (reg:SI 1 %r1))
           (clobber (reg:SI 2 %r2))
           (use (reg:SI 4 %r4))
           (use (reg:SI 19 %r19))
           (use (const_int 0 [0x0]))
       ]) -1 (nil)
   (expr_list:REG_DEP_TRUE (use (reg:SI 24 %r24))
       (expr_list:REG_DEP_TRUE (use (reg:SI 25 %r25))
           (expr_list:REG_DEP_TRUE (use (reg:SI 26 %r26))
               (nil)))))

As can be seen, the set in insn 210 is dead.


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