cchen created this revision. Herald added a project: All. cchen requested review of this revision. Herald added a reviewer: jdoerfert. Herald added subscribers: cfe-commits, sstefan1. Herald added a project: clang.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D126494 Files: clang/lib/CodeGen/CodeGenModule.cpp Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -4648,7 +4648,13 @@ InitDecl->getFlexibleArrayInitChars(getContext()); CharUnits CstSize = CharUnits::fromQuantity( getDataLayout().getTypeAllocSize(Init->getType())); - assert(VarSize == CstSize && "Emitted constant has unexpected size"); + // 'long double' is treated as 'double' in device code + const BuiltinType *BType = D->getType()->getAs<BuiltinType>(); + bool IsLongDouble = BType && BType->getKind() == BuiltinType::LongDouble; + bool IsDevice = getLangOpts().HIP || getLangOpts().CUDA || + getLangOpts().OpenMPIsDevice; + assert((VarSize == CstSize || (IsDevice && IsLongDouble)) && + "Emitted constant has unexpected size"); #endif } }
Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -4648,7 +4648,13 @@ InitDecl->getFlexibleArrayInitChars(getContext()); CharUnits CstSize = CharUnits::fromQuantity( getDataLayout().getTypeAllocSize(Init->getType())); - assert(VarSize == CstSize && "Emitted constant has unexpected size"); + // 'long double' is treated as 'double' in device code + const BuiltinType *BType = D->getType()->getAs<BuiltinType>(); + bool IsLongDouble = BType && BType->getKind() == BuiltinType::LongDouble; + bool IsDevice = getLangOpts().HIP || getLangOpts().CUDA || + getLangOpts().OpenMPIsDevice; + assert((VarSize == CstSize || (IsDevice && IsLongDouble)) && + "Emitted constant has unexpected size"); #endif } }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits