[PATCH] D17103: [CUDA] Don't crash when trying to printf a non-scalar object.

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 10 16:09:51 PST 2016


rnk added inline comments.

================
Comment at: lib/CodeGen/CGCUDABuiltin.cpp:105
@@ -99,3 +104,3 @@
       llvm::Value *P = Builder.CreateStructGEP(AllocaTy, Alloca, I - 1);
       llvm::Value *Arg = Args[I].RV.getScalarVal();
       Builder.CreateAlignedStore(Arg, P, DL.getPrefTypeAlignment(Arg->getType()));
----------------
rnk wrote:
> I assume this is what's asserting. Probably this code should do something like:
>   if (Args[I].RV.isScalar()) {
>     Arg = Args[I].RV.getScalarVal();
>   } else {
>     ErrorUnsupported(E, "non-scalar variadic argument");
>     Arg = CGM.getNullValue(...);
>   }
Under the assumption that the implementation of vprintf expects an old-school va_list byte array, then it's probably easier to implement this behavior rather than try to diagnose it. All you have to do is memcpy the bytes of the aggregate.

You also might want to handle _Complex values.


http://reviews.llvm.org/D17103





More information about the cfe-commits mailing list