From ca2ab5f9e3470e87923c7b950b7b06e5ff21119e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Fri, 28 Jun 2024 16:43:42 +0200 Subject: [PATCH 1/3] [clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems When generating runtime interface bindings, extend integral types to the native register size rather than 64-bit per se --- clang/lib/Interpreter/Interpreter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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"); From 0defacfc9ba642fdb0fc5b01584615e6e4ebcc54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Sat, 29 Jun 2024 12:45:43 +0200 Subject: [PATCH 2/3] Add parameter hit for getBitIntType() Co-authored-by: Vassil Vassilev --- clang/lib/Interpreter/Interpreter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index e6d6ab6024bb8..3968e33ea5d0f 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -677,7 +677,7 @@ class InterfaceKindVisitor // reduce the number of overloads of `__clang_Interpreter_SetValueNoAlloc`. void HandleIntegralOrEnumType(const Type *Ty) { uint64_t PtrBits = Ctx.getTypeSize(Ctx.VoidPtrTy); - QualType UIntTy = Ctx.getBitIntType(true, PtrBits); + QualType UIntTy = Ctx.getBitIntType(/*Unsigned=*/true, PtrBits); TypeSourceInfo *TSI = Ctx.getTrivialTypeSourceInfo(UIntTy); ExprResult CastedExpr = S.BuildCStyleCastExpr(SourceLocation(), TSI, SourceLocation(), E); From f0fffbadc430de0acb6550fccbb6771a3d49ea8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Mon, 1 Jul 2024 15:38:35 +0200 Subject: [PATCH 3/3] Re-enable InterpreterTest.Value from ClangReplInterpreterTests in ARM --- clang/unittests/Interpreter/InterpreterTest.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp index bbd854149d5f5..83e0cc6b73d9c 100644 --- a/clang/unittests/Interpreter/InterpreterTest.cpp +++ b/clang/unittests/Interpreter/InterpreterTest.cpp @@ -282,9 +282,6 @@ TEST_F(InterpreterTest, InstantiateTemplate) { EXPECT_EQ(42, fn(NewA.getPtr())); } -// This test exposes an ARM specific problem in the interpreter, see -// https://github.com/llvm/llvm-project/issues/94994. -#ifndef __arm__ TEST_F(InterpreterTest, Value) { std::vector Args = {"-fno-sized-deallocation"}; std::unique_ptr Interp = createInterpreter(Args); @@ -383,6 +380,5 @@ TEST_F(InterpreterTest, Value) { EXPECT_EQ(V9.getKind(), Value::K_PtrOrObj); EXPECT_TRUE(V9.isManuallyAlloc()); } -#endif /* ifndef __arm__ */ } // end anonymous namespace