--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2 -Wno-pmf-conversions -fno-checking" }
+
+class c {
+ long b;
+};
+class B {
+public:
+ typedef void *d;
+};
+class aa {
+public:
+ aa(B::d);
+};
+class e : public B {
+public:
+ e();
+};
+unsigned int f;
+struct g {
+ struct h : c {
+ h(unsigned int &i) : c(reinterpret_cast<c &>(i)) {}
+ unsigned int ad();
+ };
+};
+class n : g {
+public:
+ n(int);
+ void j() {
+ unsigned int a;
+ h k(a);
+ __atomic_compare_exchange_n(&f, &a, k.ad(), true, 3, 0);
+ }
+};
+int l;
+class m : e {
+ void ar() {
+ n b(l);
+ b.j();
+ }
+ virtual void bd() { aa(d(&m::ar)); }
+};
+void o() { new m; }
auto_bitmap addresses_taken;
auto_bitmap not_reg_needs;
auto_bitmap suitable_for_renaming;
+ bool optimistic_not_addressable = false;
tree var;
unsigned i;
gimple_call_set_arg (stmt, 1, null_pointer_node);
gimple_ior_addresses_taken (addresses_taken, stmt);
gimple_call_set_arg (stmt, 1, arg);
+ /* Remember we have to check again below. */
+ optimistic_not_addressable = true;
}
else if (is_asan_mark_p (stmt)
|| gimple_call_internal_p (stmt, IFN_GOMP_SIMT_ENTER))
/* Operand caches need to be recomputed for operands referencing the updated
variables and operands need to be rewritten to expose bare symbols. */
- if (!bitmap_empty_p (suitable_for_renaming))
+ if (!bitmap_empty_p (suitable_for_renaming)
+ || optimistic_not_addressable)
{
FOR_EACH_BB_FN (bb, cfun)
for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
if (optimize_atomic_compare_exchange_p (stmt))
{
tree expected = gimple_call_arg (stmt, 1);
- if (bitmap_bit_p (suitable_for_renaming,
- DECL_UID (TREE_OPERAND (expected, 0))))
+ tree decl = TREE_OPERAND (expected, 0);
+ if (bitmap_bit_p (suitable_for_renaming, DECL_UID (decl)))
{
fold_builtin_atomic_compare_exchange (&gsi);
continue;
}
+ else if (!TREE_ADDRESSABLE (decl))
+ /* If there are partial defs of the decl we may
+ have cleared the addressable bit but set
+ DECL_NOT_GIMPLE_REG_P. We have to restore
+ TREE_ADDRESSABLE here. */
+ TREE_ADDRESSABLE (decl) = 1;
}
else if (is_asan_mark_p (stmt))
{