[clang] [CIR] Classify empty records as Ignore in x86_64 callconv (PR #211078)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 21 14:55:05 PDT 2026
================
@@ -0,0 +1,50 @@
+// RUN: cir-opt %s -cir-call-conv-lowering=target=x86_64 | FileCheck %s
+
+!s32i = !cir.int<s, 32>
+!rec_E0 = !cir.struct<"E0" {}>
+
+module attributes {
+ dlti.dl_spec = #dlti.dl_spec<
+ #dlti.dl_entry<i32, dense<32>: vector<2xi64>>,
+ #dlti.dl_entry<i64, dense<64>: vector<2xi64>>>
+} {
+
+ // A zero-field record (a C empty struct) classifies as Ignore: the argument
+ // is dropped from the lowered signature.
+ cir.func @take_empty(%arg0: !rec_E0) {
+ cir.return
+ }
+
+ // CHECK: cir.func{{.*}} @take_empty()
+ // CHECK-NEXT: cir.return
+
+ // The empty argument is dropped even when a real argument remains; the real
+ // argument shifts down to the first slot.
+ cir.func @take_mixed(%arg0: !rec_E0, %arg1: !s32i) -> !s32i {
+ cir.return %arg1 : !s32i
+ }
+
+ // CHECK: cir.func{{.*}} @take_mixed(%arg0: !s32i) -> !s32i
+ // CHECK-NEXT: cir.return %arg0 : !s32i
+
+ // An empty-record return is dropped: the function returns void.
+ cir.func @ret_empty() -> !rec_E0 {
+ %0 = cir.alloca "r" align(1) : !cir.ptr<!rec_E0>
+ %1 = cir.load %0 : !cir.ptr<!rec_E0>, !rec_E0
+ cir.return %1 : !rec_E0
+ }
+
+ // CHECK: cir.func{{.*}} @ret_empty()
+ // CHECK-NOT: -> !rec_E0
----------------
adams381 wrote:
The slot survives this pass, so `CHECK-NOT: !rec_E0` fails on the `cir.alloca`/`cir.load`. Switched to positively checking that the return is dropped and the slot survives.
https://github.com/llvm/llvm-project/pull/211078
More information about the cfe-commits
mailing list