[clang] [clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems (PR #97071)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 28 08:22:16 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Stefan Gränitz (weliveindetail)

<details>
<summary>Changes</summary>

When generating runtime interface bindings, extend integral types to the native register size rather than 64-bit per se

---
Full diff: https://github.com/llvm/llvm-project/pull/97071.diff


1 Files Affected:

- (modified) clang/lib/Interpreter/Interpreter.cpp (+5-3) 


``````````diff
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 7a95278914276..e6d6ab6024bb8 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -673,10 +673,12 @@ class InterfaceKindVisitor
   }
 
 private:
-  // Force cast these types to uint64 to reduce the number of overloads of
-  // `__clang_Interpreter_SetValueNoAlloc`.
+  // Force cast these types to the uint that fits the register size. That way we
+  // reduce the number of overloads of `__clang_Interpreter_SetValueNoAlloc`.
   void HandleIntegralOrEnumType(const Type *Ty) {
-    TypeSourceInfo *TSI = Ctx.getTrivialTypeSourceInfo(Ctx.UnsignedLongLongTy);
+    uint64_t PtrBits = Ctx.getTypeSize(Ctx.VoidPtrTy);
+    QualType UIntTy = Ctx.getBitIntType(true, PtrBits);
+    TypeSourceInfo *TSI = Ctx.getTrivialTypeSourceInfo(UIntTy);
     ExprResult CastedExpr =
         S.BuildCStyleCastExpr(SourceLocation(), TSI, SourceLocation(), E);
     assert(!CastedExpr.isInvalid() && "Cannot create cstyle cast expr");

``````````

</details>


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


More information about the cfe-commits mailing list