[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 15:34:37 PST 2016


rnk added a comment.

Ultimately, Sema should be responsible for rejecting this, correct? In the meantime we can have CodeGen reject this and emit a null value to avoid crashing.


================
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()));
----------------
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(...);
  }


http://reviews.llvm.org/D17103





More information about the cfe-commits mailing list