jlebar added a comment.

> The problem of adding this attribute conservatively for all functions is that 
> it prevents some optimizations to happen.

function-attrs removes the convergent attribute from anything it can prove does 
not call a convergent function.

I agree this is a nonoptimal solution.  A better way would be to assume that 
any cuda/opencl function is convergent and then figure out what isn't.  This 
would let you generate correct cuda/opencl code in a front-end without worrying 
about this attribute.

One problem with this approach is, suppose you call an external function, whose 
body llvm cannot see.  We need some way to mark this function as 
not-convergent, so that its callers can also be inferred to be not convergent.  
LLVM currently only has a "convergent" attribute.  In the absence of a new 
"not-convergent" attribute, the only way we can tell LLVM that this external 
function is not convergent is to leave off the attribute.  But then this means 
we assume all functions without the convergent attribute are not convergent, 
and thus we have to add the attribute everywhere, as this patch does.

OTOH if we added a not-convergent attribute, we'd have to have rules about what 
happens if both attributes are on a function, and everywhere that checked 
whether a function was convergent would become significantly more complicated.  
I'm not sure that's worthwhile.


https://reviews.llvm.org/D38113



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to