[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Fri May 31 03:00:02 PDT 2024


================
@@ -2012,26 +2015,27 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
 }
 
 llvm::Value *CodeGenFunction::EmitToMemory(llvm::Value *Value, QualType Ty) {
-  // Bool has a different representation in memory than in registers.
-  if (hasBooleanRepresentation(Ty)) {
-    // This should really always be an i1, but sometimes it's already
-    // an i8, and it's awkward to track those cases down.
-    if (Value->getType()->isIntegerTy(1))
-      return Builder.CreateZExt(Value, ConvertTypeForMem(Ty), "frombool");
-    assert(Value->getType()->isIntegerTy(getContext().getTypeSize(Ty)) &&
-           "wrong value rep of bool");
+  if (hasBooleanRepresentation(Ty) ||
+      (Ty->isBitIntType() && Value->getType()->isIntegerTy())) {
----------------
Fznamznon wrote:

`_BitInt` that now has an array of bytes as memory type,  is returned from a function via sret(memory type) parameter. Additionally in `EmitFunctionEpilog` there is a load and a store (demo of these load an store https://godbolt.org/z/K37j4f1jn) of return value emitted that has memory type. 

Same for bool, though its memory type is not an array. I suppose there can be more cases, see comment that used to be on lines 2017-2018
```
    // This should really always be an i1, but sometimes it's already
    // an i8, and it's awkward to track those cases down.
```

https://github.com/llvm/llvm-project/pull/91364


More information about the cfe-commits mailing list