[PATCH] D126494: [clang] avoid assert due to device treated long double as double
Chi Chun Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 26 12:04:34 PDT 2022
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
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126494.432349.patch
Type: text/x-patch
Size: 959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220526/75bae512/attachment.bin>
More information about the cfe-commits
mailing list