-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems #97071
[clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems #97071
Conversation
When generating runtime interface bindings, extend integral types to the native register size rather than 64-bit per se
@llvm/pr-subscribers-clang Author: Stefan Gränitz (weliveindetail) ChangesWhen 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:
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");
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a good catch. Any chance of adding a test case? Maybe something like:
enum X : short {...}
?
Co-authored-by: Vassil Vassilev <v.g.vassilev@gmail.com>
We could add a lot more tests in general, but I don't think this specific detail requires a dedicated one. It's a fix for an existing bug, so we have coverage already. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Great work, I can imagine how hard it would be to uncover it! Small note: I think you may also want to remove the Arm macro guards that mask the unittest in the same commit, as you did in the previous PR |
Also remove the comment that links to #94994 and add I checked locally, the test now passes. |
Thanks for your feedback everyone! |
When generating runtime interface bindings, extend integral types to the native register size rather than 64-bit per se Fixes llvm#94994
When generating runtime interface bindings, extend integral types to the native register size rather than 64-bit per se Fixes llvm#94994
When generating runtime interface bindings, extend integral types to the native register size rather than 64-bit per se
Fixes #94994