[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 9 10:15:52 PDT 2024
================
@@ -1774,6 +1774,18 @@ llvm::Constant *ConstantEmitter::emitForMemory(CodeGenModule &CGM,
return Res;
}
+ if (const auto *BIT = destType->getAs<BitIntType>()) {
+ if (BIT->getNumBits() > 128) {
+ // Long _BitInt has array of bytes as in-memory type.
+ ConstantAggregateBuilder Builder(CGM);
+ llvm::Type *DesiredTy = CGM.getTypes().ConvertTypeForMem(destType);
+ auto *CI = cast<llvm::ConstantInt>(C);
----------------
rjmccall wrote:
The test case here is just going to be something like `_SomeSplitBitIntType x = (unsigned long) &someVariable;`. What code do we actually produce for this? Sometimes we'll be able to fall back on dynamic initialization, but that's not always an option.
Ideally, it's just invalid to do something like that. It certainly needs to be diagnosed if the integer type is narrower than the pointer, and wider is also problematic, although less so and in a different way.
https://github.com/llvm/llvm-project/pull/91364
More information about the cfe-commits
mailing list