On Thu, 19 Jan 2017, Jakub Jelinek wrote: > On Thu, Jan 19, 2017 at 04:36:25PM +0300, Alexander Monakov wrote: > > > One of the problems with that is that it means that you can't easily turn > > > addressable private variables into non-addressable ones once you force > > > them > > > into such struct that can't be easily SRA split. > > > In contrast, if you can get the variable flags/attributes work, if they > > > become non-addressable (which is especially important to get rid of C++ > > > abstraction penalties), you simply don't add them into the specially > > > allocated block. > > > > I agree; I'd like to implement the approach with per-variable attributes > > once > > it's clear how it ought to work (right now I'm not sure if placing CLOBBERs > > on > > both entry and exit would be enough; if I understood correctly, Richard is > > saying they might be moved, unless the middle-end is changed to prevent it). > > I think we drop CLOBBERs in certain cases, though primarily those with > MEM_REF on the lhs rather than just VAR_DECL, or even with VAR_DECL in EH > optimizations if the clobbers are the sole thing in the EH pad. > I think adding the abnormal edges would look safest to me, after all, before > it is fully lowered it is kind like a loop, some threads in the warp might > bypass it. We also use abnormal edges for vfork etc.
In that case, Richard, Jakub, may I ask you to have another look at the alternative approach I gave in response to Richard early in this subthread? It already enforces proper dependencies and doesn't commit data to one struct until the very last moment. So perhaps it would be simpler to integrate promotion of non-addressable vars into there. That is, if after inlining we have void *omp_simt = GOMP_SIMT_ENTER_BY_UID (simduid, dummy_size, dummy_align); // replacement for originally private or inlined 'int var1;' int *pvar1 = GOMP_SIMT_VAR_REF (omp_simt, simduid, uid_for_var1); for ( ... ) { ... } *pvar1 = CLOBBER; GOMP_SIMT_EXIT (omp_simt); and we see that pvar1 is only used inside MEM_REFs, we can recreate 'int var1;' (now that we're sure it's non-addressable) and replace *pvar1 accordingly. Teaching the alias oracle that GOMP_SIMT_VAR_REF returns unique pointers should be reasonable, right? Thanks. Alexander