On Wed, Jan 18, 2017 at 03:22:15PM +0100, Richard Biener wrote: > > So I guess a way to keep allocation layout implicit until after inlining is > > this: instead of exposing the helper struct in the IR immediately, somehow > > keep > > it on the side, associated only with the SIMT region, and not finalized. > > This > > would allow to populate it as needed during inlining, but the downside is > > that > > references to privatized vars would get weirder: they would need to be via > > IFNs > > that track association with the loop and the privatized variable. Like > > this: > > > > void *omp_simt = IFN_GOMP_SIMT_ENTER_BY_UID (simduid); > > > > int *tmp_ptr = IFN_GOMP_SIMT_VAR_REF (omp_simt, simduid, uid_for_tmp); > > > > for (...) > > foo (tmp_ptr); > > > > *tmp_ptr = {CLOBBER}; /* ??? for each privatized variable? */ > > IFN_GOMP_SIMT_EXIT (.omp_simt); > > > > (note how in this scheme we'd need to emit separate CLOBBERs for each field) > > > > But absence of explicit struct would hurt alias analysis I'm afraid: it > > wouldn't > > be able to deduce that references to different privatized variable do not > > alias > > until after calls to SIMT_VAR_REF are replaced. Or is that not an issue? > > It probably is. > > But I guess I was asking whether you could initially emit > > void *omp_simt = IFN_GOMP_SIMT_ENTER (0); > > for (int i = n1; i < n2; i++) > foo (&tmp); > > IFN_GOMP_SIMT_EXIT (omp_simt); > > and only after inlining do liveness / use analysis of everything between > SIMT_ENTER and SIMT_EXIT doing the rewriting only at that point.
Can't it be e.g. recorded inside a flag on the VAR_DECLs or magic attributes on them during omplower time and then only finalized into the magic .local alloca in the pass_omp_device_lower pass? The inliner would need to be able to add those flags or magic attributes also when duplicating vars/parameters from inline functions into the SIMT region (perhaps some flag on GIMPLE_CALL stmts, or on bbs in the simt region, or something similar could turn that behavior on in the inliner)? Jakub