[clang] [CIR] Upstream pointer subtraction handling (PR #163306)
Shawn K via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 14 13:34:50 PDT 2025
================
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
+
+typedef unsigned long size_type;
+
+size_type size(unsigned long *_start, unsigned long *_finish) {
+ // CIR-LABEL: cir.func dso_local @_Z4sizePmS_
+ // CIR: %[[D:.*]] = cir.ptr_diff {{.*}} : !cir.ptr<!u64i> -> !s64i
+ // CIR: %[[U:.*]] = cir.cast integral %[[D]] : !s64i -> !u64i
+ // CIR: cir.return {{.*}} : !u64i
+
+ return static_cast<size_type>(_finish - _start);
+}
----------------
kimsh02 wrote:
Incubator file didn't have LLVM checks
https://github.com/llvm/llvm-project/pull/163306
More information about the cfe-commits
mailing list