Fix several missing i1/i8 casts #525
No reviewers
Labels
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#525
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/misc-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -175,2 +175,4 @@
}
let val = value.to_basic_value_enum(ctx, generator, target.custom.unwrap())?;
// Perform i1 <-> i8 conversion as needed
Do we need i1 at all?
IIRC it just creates problems and does not solve any. Another LLVM design flaw.
All boolean instructions (e.g.
icmp
) returni1
, and LLVM's ABI usesi1
for boolean parameters in functions. I would prefer to follow these conventions as we need these casts either way.Hmm OK, but then I don't remember why we can't just use i1 for the Python bool type. Then we would not need any casts?
On i1 vs i8 for bools, is this the relevant commit?
31dcd2dde9
Right, that's the one, and the reason to complain about LLVM.
@ -177,0 +187,4 @@
let llvm_ptr_elem_ty = llvm_ptr_elem_ty.into_int_type().get_bit_width();
match (llvm_val_ty, llvm_ptr_elem_ty) {
(v_bits, elem_bits) if v_bits == elem_bits && matches!(v_bits, 1 | 8) => val,
This is a bit of a shotgun solution. Can't we be more subtle and just have the casts explicitly where they are needed?
How about using i1 for bools instead, and casting them when calling foreign functions?
Then information about what is a bool stays in the LLVM IR.
a2922b24e0
to7e273d93b0
Removed a lot of explicit checks as they are already handled in
bool_to_i1
andbool_to_i8
.7e273d93b0
to51264996b0