[clang] [CIR] Handle scalar-type element GEP in GlobalView offset computation (PR #201705)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 9 12:58:09 PDT 2026


================
@@ -175,7 +183,8 @@ uint64_t CIRGenBuilderTy::computeOffsetFromGlobalViewIndices(
       ty = arrayTy.getElementType();
       offset += layout.getTypeAllocSize(ty) * idx;
     } else {
-      llvm_unreachable("unexpected type");
+      // Scalar or pointer type: the index is a flat element count.
----------------
adams381 wrote:

Switched to `else if (mlir::isa<cir::IntType>(ty))` with the `llvm_unreachable` retained for unexpected types. Same reasoning as the forward function — the only non-aggregate type that reaches the navigator is the integer element of a string-literal GlobalViewAttr.


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


More information about the cfe-commits mailing list