Hi! On Wed, 25 Feb 2015 18:00:54 +0100, Jakub Jelinek wrote: > On Wed, Feb 25, 2015 at 11:28:12AM +0100, Thomas Schwinge wrote: > > Am I on the right track with my assumption that it is correct that > > nvptx.c:nvptx_option_override is not invoked in the offloading code path, > > so we'd need a new target hook (?) to consolidate/override the options in > > this scenario? > > > > > > Using this to forcefully disable -fvar-tracking (as done in > > nvptx_option_override), should then allow me to drop the following > > beautiful specimen of a patch (which I didn't commit anywhere, so far): > > Supposedly you could just disable var-tracking for > targetm.no_register_allocation case, or change that assert to > allow pseudos for targetm.no_register_allocation? Just changing the assert, or handling this configuration differently: diff --git gcc/var-tracking.c gcc/var-tracking.c index 9ec5d8b..e37dc19 100644 --- gcc/var-tracking.c +++ gcc/var-tracking.c @@ -5439,6 +5449,10 @@ use_type (rtx loc, struct count_use_info *cui, machine_mode *modep) if (REG_P (loc)) { + if (targetm.no_register_allocation) + if (REGNO (loc) >= FIRST_PSEUDO_REGISTER) + return MO_CLOBBER; + gcc_assert (REGNO (loc) < FIRST_PSEUDO_REGISTER); if (loc == cfa_base_rtx) ... is not enough: by the looks of it, the var-tracking code is just not prepared to see pseudo registers, for example: /* Structure holding the IN or OUT set for a basic block. */ typedef struct dataflow_set_def { [...] /* Attributes for registers (lists of attrs). */ attrs regs[FIRST_PSEUDO_REGISTER]; [...] ..., which is asserted in several places (one of which we stumbled over; I added more in the attached var-tracking-asserts.patch). I tried disabling it: diff --git gcc/var-tracking.c gcc/var-tracking.c index 9ec5d8b..e37dc19 100644 --- gcc/var-tracking.c +++ gcc/var-tracking.c @@ -10404,7 +10421,10 @@ public: /* opt_pass methods: */ virtual bool gate (function *) { - return (flag_var_tracking && !targetm.delay_vartrack); + return (flag_var_tracking + && !targetm.delay_vartrack + /* This code is not prepared to handle pseudo registers. */ + && !targetm.no_register_allocation); } virtual unsigned int execute (function *) ..., but then we run into: $ build-gcc/gcc/xgcc -Bbuild-gcc/gcc/ -Bbuild-gcc/x86_64-unknown-linux-gnu/lib{gomp,gfortran}/ -Bbuild-gcc/x86_64-unknown-linux-gnu/lib{gomp,gfortran}/.libs -Ibuild-gcc/x86_64-unknown-linux-gnu/lib{gomp,gfortran} -Isource-gcc/{include,lib{gomp,gfortran}} -Lbuild-gcc/x86_64-unknown-linux-gnu/lib{gomp,gfortran}/.libs -Wl,-rpath,"$PWD"/build-gcc/x86_64-unknown-linux-gnu/lib{gomp,gfortran}/.libs source-gcc/libgomp/testsuite/libgomp.fortran/examples-4/e.50.1.f90 -Wall -Wextra -O2 -fopenmp -lgfortran -g source-gcc/libgomp/testsuite/libgomp.fortran/examples-4/e.50.1.f90: In function '__e_50_1_mod_MOD_vec_mult._omp_fn.1': source-gcc/libgomp/testsuite/libgomp.fortran/examples-4/e.50.1.f90:31:0: internal compiler error: in get_insn_template, at final.c:2124 p(i) = v1(i) * v2(i) ^ 0x6b3765 get_insn_template(int, rtx_def*) [...]/source-gcc/gcc/final.c:2124 0x6b55de final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*) [...]/source-gcc/gcc/final.c:2986 0x6b6bff final(rtx_insn*, _IO_FILE*, int) [...]/source-gcc/gcc/final.c:2089 0x6b76e9 rest_of_handle_final [...]/source-gcc/gcc/final.c:4488 0x6b76e9 execute [...]/source-gcc/gcc/final.c:4563 [...] mkoffload: fatal error: build-gcc/gcc/x86_64-unknown-linux-gnu-accel-nvptx-none-gcc returned 1 exit status [...] Is this not the right way to skip it, or, Bernd, is this because we're not yet handling some debug stuff in nvptx? (I tested that does not help with that.) The following does make it work (that is, resolve the ICEs), but that feels a bit too much ;-) of a hack: --- gcc/var-tracking.c +++ gcc/var-tracking.c @@ -10305,7 +10322,8 @@ variable_tracking_main_1 (void) { bool success; - if (flag_var_tracking_assignments < 0) + if (flag_var_tracking_assignments < 0 + || targetm.no_register_allocation) { delete_debug_insns (); return 0; > Anyway, if var-tracking is never useful for NVPTX, if you want to override > it early, flag_var_tracking* options are Optimization options, thus you'd > need a target hook similar to the one I've added today, but instead of > TARGET_OPTION_NODE do something similar for OPTIMIZATION_NODE streaming. Grüße, Thomas