[COMMITTED 1/2] borrowck: Avoid overloading issues on 32bit architectures

2024-08-12 Thread Arthur Cohen
On architectures where `size_t` is `unsigned int`, such as 32bit x86,
we encounter an issue with `PlaceId` and `FreeRegion` being aliases to
the same types. This poses an issue for overloading functions for these
two types, such as `push_subset` in that case. This commit renames one
of these `push_subset` functions to avoid the issue, but this should be
fixed with a newtype pattern for these two types.

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-fact-collector.h (points): Rename
`push_subset(PlaceId, PlaceId)` to `push_subset_place(PlaceId, PlaceId)`
---
 gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
index bb8fedaf3db..6601c981779 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
@@ -334,7 +334,7 @@ protected: // Main collection entry points (for different 
categories).
expr.get_rhs () - 1, current_bb, current_stmt);
 
 issue_read_move (expr.get_rhs ());
-push_subset (lhs, expr.get_rhs ());
+push_place_subset (lhs, expr.get_rhs ());
   }
 
   void visit (const CallExpr &expr) override
@@ -660,7 +660,7 @@ protected: // Subset helpers.
   }
   }
 
-  void push_subset (PlaceId lhs, PlaceId rhs)
+  void push_place_subset (PlaceId lhs, PlaceId rhs)
   {
 auto &lhs_place = place_db[lhs];
 auto &rhs_place = place_db[rhs];
-- 
2.45.2



[COMMITTED 2/2] borrowck: Fix debug prints on 32-bits architectures

2024-08-12 Thread Arthur Cohen
gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder.h: Cast size_t values to 
unsigned
long before printing.
* checks/errors/borrowck/rust-bir-fact-collector.h: Likewise.
---
 gcc/rust/checks/errors/borrowck/rust-bir-builder.h| 3 ++-
 gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h | 6 --
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-builder.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-builder.h
index e9108703be1..6b29eaeba5a 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-builder.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-builder.h
@@ -91,7 +91,8 @@ private:
  ctx.fn_free_regions[bound.second.get_index ()]);
 
auto last_bound = universal_region_bounds.back ();
-   rust_debug ("\t\t %ld: %ld", last_bound.first, last_bound.second);
+   rust_debug ("\t\t %lu: %lu", (unsigned long) last_bound.first,
+   (unsigned long) last_bound.second);
   }
 
 // TODO: handle type_region constraints
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
index 6601c981779..1cd6b4d480d 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
@@ -621,14 +621,16 @@ protected: // Generic BIR operations.
 protected: // Subset helpers.
   void push_subset (FreeRegion lhs, FreeRegion rhs)
   {
-rust_debug ("\t\tpush_subset: '?%lu: '?%lu", lhs, rhs);
+rust_debug ("\t\tpush_subset: '?%lu: '?%lu", (unsigned long) lhs,
+   (unsigned long) rhs);
 
 facts.subset_base.emplace_back (lhs, rhs, get_current_point_mid ());
   }
 
   void push_subset_all (FreeRegion lhs, FreeRegion rhs)
   {
-rust_debug ("\t\tpush_subset_all: '?%lu: '?%lu", lhs, rhs);
+rust_debug ("\t\tpush_subset_all: '?%lu: '?%lu", (unsigned long) lhs,
+   (unsigned long) rhs);
 
 for (auto point : cfg_points_all)
   facts.subset_base.emplace_back (lhs, rhs, point);
-- 
2.45.2