[PATCH] D25166: [CUDA] Mark device functions as nounwind.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 3 09:19:14 PDT 2016


jlebar added a comment.

In https://reviews.llvm.org/D25166#559117, @rnk wrote:

> It feels like the right thing is to disable EH in device side compilation, but obviously that won't work because it would reject try/throw in host code.


Exactly.

> I think instead of doing that, we should make sure that CUDA diagnoses try / catch / throw in device functions, > and then do what you've done here.

Disallowing try/throw is https://reviews.llvm.org/D25036.

> Also, take a look at CodeGenFunction::getInvokeDestImpl(). I think you should add some checks in there to return nullptr if we're doing a device-side CUDA compilation. That's a much more direct way to ensure we never generate invokes on the device side.

Hm...if we did this but didn't mark functions as "this never throws", would that really take care of everything?  For example, if we were to call an external function which is itself not marked as noexcept, llvm wouldn't be able to infer that we don't throw.

Are you saying we should do both?  I'm happy to do that, but I am not sure, if we keep the nounwind attribute in, whether it's possible to write a testcase.

> Can we use a noexcept exception specification instead of this GCC attribute?

I have no attachment to this specific attribute, but wouldn't adding noexcept change the semantics of the program (because traits can detect whether or not noexcept is present)?


https://reviews.llvm.org/D25166





More information about the cfe-commits mailing list