Skip to content

Commit f6db15b

Browse files
weliveindetaillravenclaw
authored andcommitted
[clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems (llvm#97071)
When generating runtime interface bindings, extend integral types to the native register size rather than 64-bit per se Fixes llvm#94994
1 parent bb78318 commit f6db15b

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

clang/lib/Interpreter/Interpreter.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,12 @@ class InterfaceKindVisitor
686686
}
687687

688688
private:
689-
// Force cast these types to uint64 to reduce the number of overloads of
690-
// `__clang_Interpreter_SetValueNoAlloc`.
689+
// Force cast these types to the uint that fits the register size. That way we
690+
// reduce the number of overloads of `__clang_Interpreter_SetValueNoAlloc`.
691691
void HandleIntegralOrEnumType(const Type *Ty) {
692-
TypeSourceInfo *TSI = Ctx.getTrivialTypeSourceInfo(Ctx.UnsignedLongLongTy);
692+
uint64_t PtrBits = Ctx.getTypeSize(Ctx.VoidPtrTy);
693+
QualType UIntTy = Ctx.getBitIntType(/*Unsigned=*/true, PtrBits);
694+
TypeSourceInfo *TSI = Ctx.getTrivialTypeSourceInfo(UIntTy);
693695
ExprResult CastedExpr =
694696
S.BuildCStyleCastExpr(SourceLocation(), TSI, SourceLocation(), E);
695697
assert(!CastedExpr.isInvalid() && "Cannot create cstyle cast expr");

clang/unittests/Interpreter/InterpreterTest.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@ TEST_F(InterpreterTest, InstantiateTemplate) {
282282
EXPECT_EQ(42, fn(NewA.getPtr()));
283283
}
284284

285-
// This test exposes an ARM specific problem in the interpreter, see
286-
// https://github.com/llvm/llvm-project/issues/94994.
287-
#ifndef __arm__
288285
TEST_F(InterpreterTest, Value) {
289286
std::vector<const char *> Args = {"-fno-sized-deallocation"};
290287
std::unique_ptr<Interpreter> Interp = createInterpreter(Args);
@@ -383,6 +380,5 @@ TEST_F(InterpreterTest, Value) {
383380
EXPECT_EQ(V9.getKind(), Value::K_PtrOrObj);
384381
EXPECT_TRUE(V9.isManuallyAlloc());
385382
}
386-
#endif /* ifndef __arm__ */
387383

388384
} // end anonymous namespace

0 commit comments

Comments
 (0)