Skip to content

Commit

Permalink
[clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems (#97071)
Browse files Browse the repository at this point in the history
When generating runtime interface bindings, extend integral types to the
native register size rather than 64-bit per se

Fixes #94994
  • Loading branch information
weliveindetail authored Jul 3, 2024
1 parent 2a14c06 commit 1787d4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 5 additions & 3 deletions clang/lib/Interpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 0 additions & 4 deletions clang/unittests/Interpreter/InterpreterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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

0 comments on commit 1787d4b

Please sign in to comment.