[clang] [CIR] Upstream ArraySubscriptExpr for fixed size array (PR #134536)
Nathan Lanza via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 9 11:11:18 PDT 2025
================
@@ -29,8 +29,15 @@ int f[5] = {1, 2};
void func() {
int arr[10];
-
// CHECK: %[[ARR:.*]] = cir.alloca !cir.array<!s32i x 10>, !cir.ptr<!cir.array<!s32i x 10>>, ["arr"]
+
+ int e = arr[1];
+ // CHECK: %[[INIT:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["e", init]
+ // CHECK: %[[IDX:.*]] = cir.const #cir.int<1> : !s32i
+ // CHECK: %[[ARR_PTR:.*]] = cir.cast(array_to_ptrdecay, %[[ARR]] : !cir.ptr<!cir.array<!s32i x 10>>), !cir.ptr<!s32i>
+ // CHECK: %[[ELE_PTR:.*]] = cir.ptr_stride(%[[ARR_PTR]] : !cir.ptr<!s32i>, %[[IDX]] : !s32i), !cir.ptr<!s32i>
+ // CHECK: %[[TMP:.*]] = cir.load %[[ELE_PTR]] : !cir.ptr<!s32i>, !s32i
+ // CHECK" cir.store %[[TMP]], %[[INIT]] : !s32i, !cir.ptr<!s32i>
----------------
lanza wrote:
The incubator is completely disjoint from upstream. There's no way to reconcile the two versions of the project via a rebase given how different ClangIR was to start. CIRGen was entirely different (it was more of an AST walk than a clone of CodeGen), the CIR dialect was in MLIR, CIR was first implemented as a conditional functionality on top of the CFG and not as a codegen-like path, etc. So feel free to do whatever you'd like. If you need the two paths to agree at some point it would have to be via manual intervention adding new patches on top of the incubator.
For context, the rebsaing process is (in psuedo python)
```
git checkout $(git merge-base incubator/main upstream/main)
for commit in reverse(find_all_upstream_commits):
git revert commit
git cherry-pick all_of_incubator -x 'ninja -C build check-clang-cir'
```
So feel free to introduce whatever changes you want to upstream, but you won't get them in the incubator and so you'll need to apply them manually if necessary.
https://github.com/llvm/llvm-project/pull/134536
More information about the cfe-commits
mailing list