[clang] [CIR] Forward caller storage for byref call arguments (PR #216499)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 24 12:20:34 PDT 2026


================
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --check-prefixes=LLVM,LLVM-CIR --input-file=%t-cir.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefixes=LLVM,OGCG --input-file=%t.ll %s
+
+struct WithDtor {
+  int x;
+  ~WithDtor();
+};
+
+struct Big {
+  long a, b, c, d;
+};
+
+void takeByref(WithDtor t);
+void takeTwoByref(WithDtor a, WithDtor b);
+void takeByval(Big b);
+
+// The callee must receive the temporary the caller destroys, not a copy of it.
+void callByref() {
----------------
andykaylor wrote:

Can you add a test case that passes a value byref for an object that has a copy-constructor? Is that supported now?

https://github.com/llvm/llvm-project/pull/216499


More information about the cfe-commits mailing list