alexfh wrote:

Reduced test case:
```
template <class _Fn>
void invoke(_Fn __f) {
  __f();
}
struct Duration {
  int lo_;
  int rep_hi_;
  int rep_lo_;
};
Duration Seconds(int);
struct Time {
  friend bool operator<(Time, Time);
  Duration rep_;
};
Time operator+(Time, Duration);
Time Now();
struct Node {
  long val;
  Node *n;
};
struct IntrusiveMPSCQueue {
  void Push(Node *);
  int notifier_;
};
int *L;
template <class>
struct C {};
struct CoreImpl {
  template <class Q>
  CoreImpl(C<Q>) {
    (void)invoke(Q(L));
  }
};
struct AnyInvocable : CoreImpl {
  template <class F>
  AnyInvocable(F f) : CoreImpl(C<F &&>()) {}
};
void S(AnyInvocable);
template <int SleepWhenEmpty>
void BatchPull() {
  IntrusiveMPSCQueue q;
  S([&] {
    Time stop = Now() + Seconds(3);
    long i;
    for (long j; j; ++j) q.Push(new Node(++i));
    while (Now() < stop);
    q.Push(new Node(0));
  });
}
void TestBody() { (void)BatchPull<true>; }
```

```
$ diff -u10 <(./clang-good -fnew-alignment=8 -fsanitize=alignment,null -O0 
-std=c++20 test.cc -emit-llvm -S -o -) <(./clang-bad -fnew-alignment=8 
-fsanitize=alignment,null -O0 -std=c++20 test.cc -emit-llvm -S -o -)
--- /dev/fd/63  2025-05-24 07:54:29.833789023 +0000
+++ /dev/fd/62  2025-05-24 07:54:29.833789023 +0000
@@ -275,21 +275,21 @@
   %91 = icmp eq i64 %90, 0, !nosanitize !4
   %92 = and i1 %88, %91, !nosanitize !4
   br i1 %92, label %94, label %93, !prof !5, !nosanitize !4

 93:                                               ; preds = %86
   call void @__ubsan_handle_type_mismatch_v1(ptr @13, i64 %89) #6, !nosanitize 
!4
   br label %94, !nosanitize !4

 94:                                               ; preds = %93, %86
   %95 = getelementptr inbounds nuw %struct.Node, ptr %87, i32 0, i32 0
-  store i64 0, ptr %95, align 8
+  store i32 0, ptr %95, align 8
   %96 = getelementptr inbounds nuw %struct.Node, ptr %87, i32 0, i32 1
   store ptr null, ptr %96, align 8
   call void @_ZN18IntrusiveMPSCQueue4PushEP4Node(ptr noundef nonnull align 4 
dereferenceable(4) %81, ptr noundef %87)
   ret void
 }

 declare dso_local { i64, i32 } @_Zpl4Time8Duration(i64, i32, i64, i32) #2

 declare dso_local { i64, i32 } @_Z3Nowv() #2
```

https://github.com/llvm/llvm-project/pull/138518
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to