/* { dg-do compile } */ /* { dg-options "-g -O2 -fpic" } */ typedef double T1[10]; typedef double T2[10][10]; typedef int T3[10]; void fn1 (void); void fn2 (int, ...);
static void bar (double v, double w, double x, double y, double z) { double a; if (v / w < 200.0) { a = x + (y - x) * __builtin_exp (-v / w); fn2 (0); fn2 (1, a * 20.2 / z, z); fn1 (); } } static void baz (T2 u, T2 v, T2 w, T2 x, T1 y, T3 z, double q, int j, int k) { int i = z[k]; if (u[i][j] > 0.0) bar (q, x[i][j], v[i][j], w[i][j], y[i]); } static T2 a, b, c, d; static T1 e; static T3 f; void test (int j, int k, double q) { baz (a, b, c, d, e, f, q, j, k); } ICEs on redhat/gcc-4_4-branch on i686-linux (and x86_64-linux -m32), with: internal compiler error: output_operand: invalid expression as operand I haven't been able to make this testcase ICE on the trunk, but I believe the issue is just latent there, so I'm filing it here rather than tracking it internally. The issue is that %ebx + offset addition is CSEd, so we have: leal (%ebx,%ecx,8), %ecx ... fldl a...@gotoff(%ecx) fldl c...@gotoff(%ecx) fldl b...@gotoff(%ecx) fldl d...@gotoff(%ecx) (as this is in a loop, I don't think that is even a bad idea, the code is at least shorter). But var-tracking finds out one of the tracked variables lives in: (note 189 177 190 4 (var_location w (expr_list:REG_DEP_TRUE (mem/s:DF (plus:SI (reg:SI 2 cx [75]) (const:SI (unspec:SI [ (symbol_ref:SI ("d") [flags 0x2] <var_decl 0x7f9bb4c3faa0 d>) ] 1))) [2 S8 A64]) (const_int 0 [0x0]))) NOTE_INSN_VAR_LOCATION) and i?86 delegitimize hook, as it doesn't see the PIC register anywhere in the expression, just gives up. We don't have a target hook that would verify what we throw at dw2_asm_output_addr_rtx won't ICE and target's checking ICEs when it sees an unexpected UNSPEC (or on other targets e.g. might generate invalid assembly). So, either we need to add such a target hook which will check the rtx and tell caller it is not valid (so dwarf2out would just skip that location), or we need to teach delegitimize langhook in this case to return some fancy address (in this case it would be (symbol_ref "d") + (reg cx) - (reg bx)). Unfortunately the delegitimization langhook is called not just in dwarf2out, but in other places too, so it needs some verification whether it wouldn't cause problems there. -- Summary: ICE in output_operand Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43139