Skip to content

Commit

Permalink
Merge pull request rust-lang#352 from rust-lang/update-libgccjit
Browse files Browse the repository at this point in the history
Fix #[inline(always)] attribute and support unsigned comparison for signed integers
  • Loading branch information
antoyo authored Oct 17, 2023
2 parents cf8c391 + e2f32c7 commit 4dce75f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions doc/tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Tests

## Show the rustc command for UI tests

Add ` --test-args "--verbose"` to `./x.py test`.
1 change: 1 addition & 0 deletions failing-ui-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ tests/ui/lto/all-crates.rs
tests/ui/async-await/deep-futures-are-freeze.rs
tests/ui/closures/capture-unsized-by-ref.rs
tests/ui/generator/resume-after-return.rs
tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs
3 changes: 3 additions & 0 deletions src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
codegen_fn_attrs.inline
};
if let Some(attr) = inline_attr(cx, inline) {
if let FnAttribute::AlwaysInline = attr {
func.add_attribute(FnAttribute::Inline);
}
func.add_attribute(attr);
}

Expand Down
13 changes: 13 additions & 0 deletions src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
IntPredicate::IntNE => {
return self.context.new_comparison(None, ComparisonOp::NotEquals, cmp, self.context.new_rvalue_one(self.int_type));
},
// TODO(antoyo): cast to u128 for unsigned comparison. See below.
IntPredicate::IntUGT => (ComparisonOp::Equals, 2),
IntPredicate::IntUGE => (ComparisonOp::GreaterThanEquals, 1),
IntPredicate::IntULT => (ComparisonOp::Equals, 0),
Expand Down Expand Up @@ -444,6 +445,18 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
rhs = self.context.new_cast(None, rhs, a_type);
}
}
match op {
IntPredicate::IntUGT | IntPredicate::IntUGE | IntPredicate::IntULT | IntPredicate::IntULE => {
if !a_type.is_vector() {
let unsigned_type = a_type.to_unsigned(&self.cx);
lhs = self.context.new_cast(None, lhs, unsigned_type);
rhs = self.context.new_cast(None, rhs, unsigned_type);
}
},
// TODO(antoyo): we probably need to handle signed comparison for unsigned
// integers.
_ => (),
}
self.context.new_comparison(None, op.to_gcc_comparison(), lhs, rhs)
}
}
Expand Down

0 comments on commit 4dce75f

Please sign in to comment.