Author: Stefan Gränitz Date: 2024-07-03T10:32:50+02:00 New Revision: 1787d4b28417ea9f26c0213e8f597cc5bb289144
URL: https://github.com/llvm/llvm-project/commit/1787d4b28417ea9f26c0213e8f597cc5bb289144 DIFF: https://github.com/llvm/llvm-project/commit/1787d4b28417ea9f26c0213e8f597cc5bb289144.diff LOG: [clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems (#97071) When generating runtime interface bindings, extend integral types to the native register size rather than 64-bit per se Fixes #94994 Added: Modified: clang/lib/Interpreter/Interpreter.cpp clang/unittests/Interpreter/InterpreterTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index 49dc92d60233a..b4882ab5d2236 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -686,10 +686,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(/*Unsigned=*/true, PtrBits); + TypeSourceInfo *TSI = Ctx.getTrivialTypeSourceInfo(UIntTy); ExprResult CastedExpr = S.BuildCStyleCastExpr(SourceLocation(), TSI, SourceLocation(), E); assert(!CastedExpr.isInvalid() && "Cannot create cstyle cast expr"); diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp index 29c5ead60b81e..a2e960f143111 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<const char *> Args = {"-fno-sized-deallocation"}; std::unique_ptr<Interpreter> 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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits