Skip to content

Commit

Permalink
rewriter: avoid segfaulting on non-scalar, non-struct direct types
Browse files Browse the repository at this point in the history
This doesn't actually handle the type, but it avoids segfaulting and dumps the unexpected type.
In this case, it happens to be a `union`, which we need to handle I believe,
but we can do that in a follow-up PR.
  • Loading branch information
kkysen committed Sep 21, 2024
1 parent 05e2920 commit 9c2346d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/rewriter/DetermineAbi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
// chosen to pass directly in registers
static std::vector<CAbiArgKind> classifyDirectType(const clang::Type &type,
const clang::ASTContext &astContext) {
if (type.isVoidType())
if (type.isVoidType()) {
return {};
if (type.isScalarType()) {
} else if (type.isScalarType()) {
switch (type.getScalarTypeKind()) {
case clang::Type::ScalarTypeKind::STK_CPointer:
case clang::Type::ScalarTypeKind::STK_Bool:
Expand All @@ -42,7 +42,7 @@ static std::vector<CAbiArgKind> classifyDirectType(const clang::Type &type,
llvm::report_fatal_error(
"unsupported scalar type (obj-C object, Clang block, or C++ member) found during ABI computation");
}
} else {
} else if (type.getAsStructureType()) {
// Handle the case where we pass a struct directly in a register.
// The strategy here is to iterate through each field of the struct
// and record the ABI type each time we exit an eightbyte chunk.
Expand Down Expand Up @@ -115,6 +115,7 @@ static std::vector<CAbiArgKind> classifyDirectType(const clang::Type &type,
return out;
}
}
type.dump();
llvm::report_fatal_error(
"classifyDirectType called on non-scalar, non-canPassInRegisters type");
}
Expand Down

0 comments on commit 9c2346d

Please sign in to comment.