[clang] [CIR] Add Extend (signext/zeroext) handling to CallConvLowering (PR #195745)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue May 26 17:08:39 PDT 2026


================
@@ -0,0 +1,41 @@
+// Extend on a narrow return attaches llvm.signext (or llvm.zeroext) to
+// res_attrs while keeping the narrow type in the signature.  Body and
+// call-site IR are unchanged otherwise.
+// RUN: cir-opt %s -cir-call-conv-lowering="classification-attr=test_classify" \
+// RUN:   | FileCheck %s
+
+!s8i = !cir.int<s, 8>
+
+#extend_signed_return = {
+  return = { kind = "extend",
+             coerced_type = !cir.int<s, 32>,
+             sign_extend = true },
+  args   = [ ]
+}
+
+module attributes {
+  dlti.dl_spec = #dlti.dl_spec<
+    #dlti.dl_entry<i8, dense<8>: vector<2xi64>>,
+    #dlti.dl_entry<i32, dense<32>: vector<2xi64>>>
+} {
+
+  cir.func @returns_s8() -> !s8i
+      attributes { test_classify = #extend_signed_return } {
+    %0 = cir.const #cir.int<7> : !s8i
+    cir.return %0 : !s8i
+  }
+
+  // CHECK: cir.func{{.*}} @returns_s8() -> (!s8i {llvm.signext})
----------------
andykaylor wrote:

Will we need to do anything to lower this to LLVM IR?

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


More information about the cfe-commits mailing list