[clang] [CIR] Tolerate identical source and destination in cir.copy (PR #193852)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 24 06:07:44 PDT 2026
================
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
+
+// This is UB, but Clang allows it and it is used in one of the
+// llvm-test-suite MultiSource tests.
+
+struct S {
+ int a;
+ int b;
+ int c;
+};
+
+void test_self_initialize() {
+ struct S s = s;
----------------
erichkeane wrote:
See my other comment, I hadn't realized that `llvm.memcpy` defined the self-copy semantic (rather than it being UB, like memcpy), which makes me much less concerned.
I think I'm alright with the no-op copy, and i suspect we'll just delete it later anyway, but i no longer feel strongly.
https://github.com/llvm/llvm-project/pull/193852
More information about the cfe-commits
mailing list