[clang] [Clang][CIR] Fix tests post #225415 (PR #225784)
Andrzej WarzyĆski via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 07:03:07 PDT 2026
https://github.com/banach-space created https://github.com/llvm/llvm-project/pull/225784
AI Assisted (codex)
>From 7ee7de1e54dc068867a8963e5539dd7f7111078f Mon Sep 17 00:00:00 2001
From: Andrzej Warzynski <andrzej.warzynski at arm.com>
Date: Wed, 23 Sep 2026 13:35:54 +0000
Subject: [PATCH] [Clang][CIR] Fix tests post #225415
AI Assisted (codex)
---
clang/test/CIR/CodeGen/base-init-eh.cpp | 2 +-
clang/test/CIR/CodeGen/ctor-null-init.cpp | 4 ++--
clang/test/CIR/CodeGen/delegating-ctor.cpp | 6 ++---
.../CIR/CodeGen/destructor-vtable-reinit.cpp | 8 +++----
clang/test/CIR/CodeGen/global-ptr-init.cpp | 2 +-
clang/test/CIR/CodeGen/inherited-ctors.cpp | 2 +-
clang/test/CIR/CodeGen/multi-vtable.cpp | 4 ++--
.../test/CIR/CodeGen/rtti-member-pointer.cpp | 8 +++----
clang/test/CIR/CodeGen/rtti-qualfn.cpp | 9 ++++---
clang/test/CIR/CodeGen/vbase.cpp | 2 +-
.../CIR/CodeGen/virtual-function-calls.cpp | 6 +----
clang/test/CIR/CodeGen/vtt.cpp | 24 +++++++++----------
clang/test/CIR/CodeGenCXX/base-layout.cpp | 2 +-
.../CodeGenCXX/vtable-pure-deleted-funcs.cpp | 2 +-
14 files changed, 38 insertions(+), 43 deletions(-)
diff --git a/clang/test/CIR/CodeGen/base-init-eh.cpp b/clang/test/CIR/CodeGen/base-init-eh.cpp
index c16aac8ef77a0b..24f6f7a93e73f0 100644
--- a/clang/test/CIR/CodeGen/base-init-eh.cpp
+++ b/clang/test/CIR/CodeGen/base-init-eh.cpp
@@ -100,7 +100,7 @@ void test_virt_base_initializer() {
// OGCG: define {{.*}} void @_ZN11VirtDerivedC1Ev
// OGCG: %[[THIS:.*]] = load ptr, ptr %{{.*}}
// OGCG: call void @_ZN4BaseC2Ei(ptr {{.*}} %[[THIS]], i32 {{.*}} 0)
-// OGCG: store ptr getelementptr inbounds inrange(-24, 0) ({ [3 x ptr] }, ptr @_ZTV11VirtDerived, i32 0, i32 0, i32 3), ptr %[[THIS]]
+// OGCG: store ptr getelementptr inbounds inrange(-24, 0) (i8, ptr @_ZTV11VirtDerived, i64 24), ptr %[[THIS]]
// OGCG: invoke void @_Z8mayThrowv()
// OGCG: to label %[[INVOKE_CONT:.*]] unwind label %[[LPAD:.*]]
// OGCG: [[INVOKE_CONT:.*]]:
diff --git a/clang/test/CIR/CodeGen/ctor-null-init.cpp b/clang/test/CIR/CodeGen/ctor-null-init.cpp
index d7fcdd3221de71..1e54556c4665e9 100644
--- a/clang/test/CIR/CodeGen/ctor-null-init.cpp
+++ b/clang/test/CIR/CodeGen/ctor-null-init.cpp
@@ -103,7 +103,7 @@ VDerived::VDerived() : VBase() {}
// OGCG: %[[ADDR:.*]] = getelementptr inbounds i8, ptr %[[THIS:.*]],
// OGCG: call void @llvm.memset.p0.i64(ptr align 8 %[[ADDR]], i8 0, i64 8, i1 false)
// OGCG: call void @_ZN5VBaseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %[[THIS]])
-// OGCG: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV8VDerived, i32 0, i32 0, i32 2), ptr %[[THIS]], align 8
+// OGCG: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV8VDerived, i64 16), ptr %[[THIS]], align 8
// CIR-LABEL: cir.func {{.*}}@_ZN8VDerivedC2Ev
// CIR: %[[BASE:.*]] = cir.base_class_addr {{.*}} : !cir.ptr<!rec_VDerived> nonnull [0] -> !cir.ptr<!rec_VBase>
@@ -125,4 +125,4 @@ VDerived::VDerived() : VBase() {}
// LLVM-LABEL: define {{.*}}@_ZN5VBaseC2Ev
// LLVM: store ptr getelementptr inbounds nuw (i8, ptr @_ZTV5VBase, i64 16), ptr %
// OGCG-LABEL: define {{.*}}@_ZN5VBaseC2Ev
-// OGCG: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV5VBase, i32 0, i32 0, i32 2), ptr %
+// OGCG: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV5VBase, i64 16), ptr %
diff --git a/clang/test/CIR/CodeGen/delegating-ctor.cpp b/clang/test/CIR/CodeGen/delegating-ctor.cpp
index 1dbd44ee068c04..f90eecf21b322b 100644
--- a/clang/test/CIR/CodeGen/delegating-ctor.cpp
+++ b/clang/test/CIR/CodeGen/delegating-ctor.cpp
@@ -283,8 +283,8 @@ Derived::Derived(const void *inVoid) { squawk(); }
// OGCG: store ptr %[[INVOID_ARG]], ptr %[[INVOID_ADDR]]
// OGCG: %[[THIS:.*]] = load ptr, ptr %[[THIS_ADDR]]
// OGCG: call void @_ZN4BaseC2Ev(ptr {{.*}} %[[THIS]])
-// OGCG: store ptr getelementptr inbounds inrange(-32, 8) ({ [5 x ptr] }, ptr @_ZTV7Derived, i32 0, i32 0, i32 4), ptr %[[THIS]]
-// OGCG: store ptr getelementptr inbounds inrange(-32, 8) ({ [5 x ptr] }, ptr @_ZTV7Derived, i32 0, i32 0, i32 4), ptr %[[THIS]]
+// OGCG: store ptr getelementptr inbounds inrange(-32, 8) (i8, ptr @_ZTV7Derived, i64 32), ptr %[[THIS]]
+// OGCG: store ptr getelementptr inbounds inrange(-32, 8) (i8, ptr @_ZTV7Derived, i64 32), ptr %[[THIS]]
// OGCG: %[[VPTR:.*]] = load ptr, ptr %[[THIS]]
// OGCG: %[[SQUAWK_ADDR:.*]] = getelementptr inbounds ptr, ptr %[[VPTR]], i64 0
// OGCG: %[[SQUAWK:.*]] = load ptr, ptr %[[SQUAWK_ADDR]]
@@ -320,7 +320,7 @@ Derived::Derived(const void *inVoid) { squawk(); }
// OGCG: %[[THIS_ADDR:.*]] = alloca ptr
// OGCG: store ptr %[[THIS_ARG]], ptr %[[THIS_ADDR]]
// OGCG: %[[THIS:.*]] = load ptr, ptr %[[THIS_ADDR]]
-// OGCG: store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV4Base, i32 0, i32 0, i32 2), ptr %[[THIS]]
+// OGCG: store ptr getelementptr inbounds inrange(-16, 8) (i8, ptr @_ZTV4Base, i64 16), ptr %[[THIS]]
// OGCG: %[[VPTR:.*]] = load ptr, ptr %[[THIS]]
// OGCG: %[[SQUAWK_ADDR:.*]] = getelementptr inbounds ptr, ptr %[[VPTR]], i64 0
// OGCG: %[[SQUAWK:.*]] = load ptr, ptr %[[SQUAWK_ADDR]]
diff --git a/clang/test/CIR/CodeGen/destructor-vtable-reinit.cpp b/clang/test/CIR/CodeGen/destructor-vtable-reinit.cpp
index 887c22588d2633..38d5fe9721e0e0 100644
--- a/clang/test/CIR/CodeGen/destructor-vtable-reinit.cpp
+++ b/clang/test/CIR/CodeGen/destructor-vtable-reinit.cpp
@@ -30,7 +30,7 @@ Base::~Base() { some_function(); }
// LLVM: %[[THIS_ADDR:.*]] = alloca ptr
// LLVM: %[[THIS:.*]] = load ptr, ptr %[[THIS_ADDR]]
// LLVMCIR-NEXT:store ptr getelementptr inbounds nuw (i8, ptr @_ZTV4Base, i64 16), ptr %[[THIS]]
-// OGCG-NEXT: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV4Base, i32 0, i32 0, i32 2), ptr %[[THIS]]
+// OGCG-NEXT: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV4Base, i64 16), ptr %[[THIS]]
// LLVM-NEXT: call void @_Z13some_functionv()
// LLVM-NEXT: ret void
@@ -59,7 +59,7 @@ Derived::~Derived() { some_function(); }
// LLVM: %[[THIS_ADDR:.*]] = alloca ptr
// LLVM: %[[THIS:.*]] = load ptr, ptr %[[THIS_ADDR]]
// LLVMCIR: store ptr getelementptr inbounds nuw (i8, ptr @_ZTV7Derived, i64 16), ptr %[[THIS]]
-// OGCG: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV7Derived, i32 0, i32 0, i32 2), ptr %[[THIS]]
+// OGCG: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV7Derived, i64 16), ptr %[[THIS]]
// LLVM-NEXT: call void @_Z13some_functionv()
// LLVM: call void @_ZN4BaseD2Ev(ptr {{.*}}%[[THIS]])
// LLVM: ret void
@@ -169,10 +169,10 @@ MultiBase::~MultiBase() { some_function(); }
// LLVM: %[[THIS_ADDR:.*]] = alloca ptr
// LLVM: %[[THIS:.*]] = load ptr, ptr %[[THIS_ADDR]]
// LLVMCIR: store ptr getelementptr inbounds nuw (i8, ptr @_ZTV9MultiBase, i64 16), ptr %[[THIS]]
-// OGCG: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr], [4 x ptr] }, ptr @_ZTV9MultiBase, i32 0, i32 0, i32 2), ptr %[[THIS]]
+// OGCG: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV9MultiBase, i64 16), ptr %[[THIS]]
// LLVM: %[[FATHER_ADDR:.*]] = getelementptr {{.*}}i8, ptr %[[THIS]], i{{32|64}} 8
// LLVMCIR: store ptr getelementptr inbounds nuw (i8, ptr @_ZTV9MultiBase, i64 48), ptr %[[FATHER_ADDR]]
-// OGCG: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr], [4 x ptr] }, ptr @_ZTV9MultiBase, i32 0, i32 1, i32 2), ptr %[[FATHER_ADDR]]
+// OGCG: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV9MultiBase, i64 48), ptr %[[FATHER_ADDR]]
// LLVM: call void @_Z13some_functionv()
// LLVM: call void @_ZN6FatherD2Ev(ptr {{.*}})
// LLVM: call void @_ZN6MotherD2Ev(ptr {{.*}}%[[THIS]])
diff --git a/clang/test/CIR/CodeGen/global-ptr-init.cpp b/clang/test/CIR/CodeGen/global-ptr-init.cpp
index 1520485cf3597c..9a9824881a98c0 100644
--- a/clang/test/CIR/CodeGen/global-ptr-init.cpp
+++ b/clang/test/CIR/CodeGen/global-ptr-init.cpp
@@ -13,4 +13,4 @@ B x;
// CIR: cir.global external @x = #cir.const_record<{#cir.global_view<@_ZTV1B, [0 : i32, 2 : i32]> : !cir.vptr}> : !rec_B
// LLVM: @x = global %struct.B { ptr getelementptr inbounds nuw (i8, ptr @_ZTV1B, i64 16) }, align 8
-// OGCG: @x = global %struct.B { ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 2) }, align 8
+// OGCG: @x = global %struct.B { ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTV1B, i64 16) }, align 8
diff --git a/clang/test/CIR/CodeGen/inherited-ctors.cpp b/clang/test/CIR/CodeGen/inherited-ctors.cpp
index e78279018772b7..6871c00da58500 100644
--- a/clang/test/CIR/CodeGen/inherited-ctors.cpp
+++ b/clang/test/CIR/CodeGen/inherited-ctors.cpp
@@ -162,7 +162,7 @@ void fallsthrough() {
// Note: see the note above for the CIR/LLVM-IR difference here.
// OGCG: %[[X_LOAD:.*]] = load i32, ptr %[[X_ALLOCA]]
// OGCG: call void @_ZN11VirtDerivedCI24BaseEi(ptr {{.*}}%[[THIS_LOAD]], ptr {{.*}}(i8, ptr @_ZTT21VirtualDelegatingCtor, i64 8), i32{{.*}}%[[X_LOAD]])
-// OGCG: store ptr getelementptr inbounds inrange(-24, 0) ({ [3 x ptr] }, ptr @_ZTV21VirtualDelegatingCtor, i32 0, i32 0, i32 3), ptr %[[THIS_LOAD]]
+// OGCG: store ptr getelementptr inbounds inrange(-24, 0) (i8, ptr @_ZTV21VirtualDelegatingCtor, i64 24), ptr %[[THIS_LOAD]]
//
// OGCG-LABEL: define linkonce_odr void @_ZN7DerivedCI24BaseEi(ptr {{.*}}, i32 {{.*}})
// OGCG: %[[THIS_ALLOCA:.*]] = alloca ptr
diff --git a/clang/test/CIR/CodeGen/multi-vtable.cpp b/clang/test/CIR/CodeGen/multi-vtable.cpp
index 33980b459886e6..e47cfd3cf90d37 100644
--- a/clang/test/CIR/CodeGen/multi-vtable.cpp
+++ b/clang/test/CIR/CodeGen/multi-vtable.cpp
@@ -177,7 +177,7 @@ Child::Child() {}
// OGCG: call void @_ZN6MotherC2Ev(ptr {{.*}} %[[THIS]])
// OGCG: %[[FATHER_BASE:.*]] = getelementptr{{.*}} i8, ptr %[[THIS]], i64 8
// OGCG: call void @_ZN6FatherC2Ev(ptr{{.*}} %[[FATHER_BASE]])
-// OGCG: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV5Child, i32 0, i32 0, i32 2), ptr %[[THIS]]
+// OGCG: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV5Child, i64 16), ptr %[[THIS]]
// OGCG: %[[FATHER_BASE:.*]] = getelementptr{{.*}} i8, ptr %[[THIS]], i64 8
-// OGCG: store ptr getelementptr inbounds inrange(-16, 8) ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV5Child, i32 0, i32 1, i32 2), ptr %[[FATHER_BASE]]
+// OGCG: store ptr getelementptr inbounds inrange(-16, 8) (i8, ptr @_ZTV5Child, i64 48), ptr %[[FATHER_BASE]]
// OGCG: ret void
diff --git a/clang/test/CIR/CodeGen/rtti-member-pointer.cpp b/clang/test/CIR/CodeGen/rtti-member-pointer.cpp
index a041db2cab6287..93975ebd0814d1 100644
--- a/clang/test/CIR/CodeGen/rtti-member-pointer.cpp
+++ b/clang/test/CIR/CodeGen/rtti-member-pointer.cpp
@@ -31,8 +31,8 @@ void throw_data_member_ptr() {
// OGCG-DAG: @_ZTSM1Ai = linkonce_odr constant [5 x i8] c"M1Ai\00", comdat
// OGCG-DAG: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat
-// OGCG-DAG: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1A }, comdat
-// OGCG-DAG: @_ZTIM1Ai = linkonce_odr constant { ptr, ptr, i32, ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv129__pointer_to_member_type_infoE, i64 2), ptr @_ZTSM1Ai, i32 0, ptr @_ZTIi, ptr @_ZTI1A }, comdat
+// OGCG-DAG: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 16), ptr @_ZTS1A }, comdat
+// OGCG-DAG: @_ZTIM1Ai = linkonce_odr constant { ptr, ptr, i32, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv129__pointer_to_member_type_infoE, i64 16), ptr @_ZTSM1Ai, i32 0, ptr @_ZTIi, ptr @_ZTI1A }, comdat
// OGCG-DAG: call void @__cxa_throw(ptr %{{.*}}, ptr @_ZTIM1Ai, ptr null)
void throw_member_fn_ptr() {
@@ -53,6 +53,6 @@ void throw_member_fn_ptr() {
// OGCG-DAG: @_ZTSM1AFvvE = linkonce_odr constant [8 x i8] c"M1AFvvE\00", comdat
// OGCG-DAG: @_ZTSFvvE = linkonce_odr constant [5 x i8] c"FvvE\00", comdat
-// OGCG-DAG: @_ZTIFvvE = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__function_type_infoE, i64 2), ptr @_ZTSFvvE }, comdat
-// OGCG-DAG: @_ZTIM1AFvvE = linkonce_odr constant { ptr, ptr, i32, ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv129__pointer_to_member_type_infoE, i64 2), ptr @_ZTSM1AFvvE, i32 0, ptr @_ZTIFvvE, ptr @_ZTI1A }, comdat
+// OGCG-DAG: @_ZTIFvvE = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__function_type_infoE, i64 16), ptr @_ZTSFvvE }, comdat
+// OGCG-DAG: @_ZTIM1AFvvE = linkonce_odr constant { ptr, ptr, i32, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv129__pointer_to_member_type_infoE, i64 16), ptr @_ZTSM1AFvvE, i32 0, ptr @_ZTIFvvE, ptr @_ZTI1A }, comdat
// OGCG-DAG: call void @__cxa_throw(ptr %{{.*}}, ptr @_ZTIM1AFvvE, ptr null)
diff --git a/clang/test/CIR/CodeGen/rtti-qualfn.cpp b/clang/test/CIR/CodeGen/rtti-qualfn.cpp
index 57fbf714a7d881..6a85498d484087 100644
--- a/clang/test/CIR/CodeGen/rtti-qualfn.cpp
+++ b/clang/test/CIR/CodeGen/rtti-qualfn.cpp
@@ -26,13 +26,12 @@ void f() noexcept {
// LLVM-DAG: @_ZTSFvvE = linkonce_odr constant [5 x i8] c"FvvE\00", comdat
// LLVM-DAG: @_ZTSPDoFvvE = linkonce_odr constant [8 x i8] c"PDoFvvE\00", comdat
-// CIR and OGCG represent the reference to the type info vtable differently,
-// as a byte offset from the vtable symbol or as an index into an array of
-// pointers, but both name its address point.
+// CIR and OGCG use byte offsets to name the type info vtable address point.
+// OGCG additionally marks these GEPs inbounds.
// LLVMCIR-DAG: @_ZTIFvvE = linkonce_odr constant { ptr, ptr } { ptr getelementptr (i8, ptr @_ZTVN10__cxxabiv120__function_type_infoE, i64 16), ptr @_ZTSFvvE }, comdat
// LLVMCIR-DAG: @_ZTIPDoFvvE = linkonce_odr constant { ptr, ptr, i32, ptr } { ptr getelementptr (i8, ptr @_ZTVN10__cxxabiv119__pointer_type_infoE, i64 16), ptr @_ZTSPDoFvvE, i32 64, ptr @_ZTIFvvE }, comdat
-// OGCG-DAG: @_ZTIFvvE = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__function_type_infoE, i64 2), ptr @_ZTSFvvE }, comdat
-// OGCG-DAG: @_ZTIPDoFvvE = linkonce_odr constant { ptr, ptr, i32, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv119__pointer_type_infoE, i64 2), ptr @_ZTSPDoFvvE, i32 64, ptr @_ZTIFvvE }, comdat
+// OGCG-DAG: @_ZTIFvvE = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__function_type_infoE, i64 16), ptr @_ZTSFvvE }, comdat
+// OGCG-DAG: @_ZTIPDoFvvE = linkonce_odr constant { ptr, ptr, i32, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv119__pointer_type_infoE, i64 16), ptr @_ZTSPDoFvvE, i32 64, ptr @_ZTIFvvE }, comdat
// The throw unwinds to the terminate scope of the enclosing noexcept function.
// LLVM-LABEL: define{{.*}} void @_Z1fv()
diff --git a/clang/test/CIR/CodeGen/vbase.cpp b/clang/test/CIR/CodeGen/vbase.cpp
index fb37a49c7856e9..b480609af620d9 100644
--- a/clang/test/CIR/CodeGen/vbase.cpp
+++ b/clang/test/CIR/CodeGen/vbase.cpp
@@ -136,5 +136,5 @@ void ppp() { B b; }
// OGCG: store ptr %[[THIS_ARG]], ptr %[[THIS_ADDR]]
// OGCG: %[[THIS:.*]] = load ptr, ptr %[[THIS_ADDR]]
// OGCG: %[[BASE_A_ADDR:.*]] = getelementptr inbounds i8, ptr %[[THIS]], i64 12
-// OGCG: store ptr getelementptr inbounds inrange(-24, 0) ({ [3 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 3), ptr %[[THIS]]
+// OGCG: store ptr getelementptr inbounds inrange(-24, 0) (i8, ptr @_ZTV1B, i64 24), ptr %[[THIS]]
// OGCG: ret void
diff --git a/clang/test/CIR/CodeGen/virtual-function-calls.cpp b/clang/test/CIR/CodeGen/virtual-function-calls.cpp
index 3d7e3a8ae47125..482b374c2d3b91 100644
--- a/clang/test/CIR/CodeGen/virtual-function-calls.cpp
+++ b/clang/test/CIR/CodeGen/virtual-function-calls.cpp
@@ -41,11 +41,7 @@ A::A() {}
// OGCG: %[[THIS_ADDR:.*]] = alloca ptr
// OGCG: store ptr %[[ARG0]], ptr %[[THIS_ADDR]]
// OGCG: %[[THIS:.*]] = load ptr, ptr %[[THIS_ADDR]]
-// OGCG: store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 2), ptr %[[THIS]]
-
-// NOTE: The GEP in OGCG looks very different from the one generated with CIR,
-// but it is equivalent. The OGCG GEP indexes by base pointer, then
-// structure, then array, whereas the CIR GEP indexes by byte offset.
+// OGCG: store ptr getelementptr inbounds inrange(-16, 8) (i8, ptr @_ZTV1A, i64 16), ptr %[[THIS]]
void f1(A *a) {
a->f('c');
diff --git a/clang/test/CIR/CodeGen/vtt.cpp b/clang/test/CIR/CodeGen/vtt.cpp
index 91283befe84be2..795b26ded3b9c5 100644
--- a/clang/test/CIR/CodeGen/vtt.cpp
+++ b/clang/test/CIR/CodeGen/vtt.cpp
@@ -127,13 +127,13 @@ void D::y() {}
// LLVM-COMMON-SAME: ], align 8
// OGCG-COMMON: @_ZTT1D = unnamed_addr constant [7 x ptr] [
-// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [4 x ptr], [4 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 3),
-// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) ({ [4 x ptr], [4 x ptr] }, ptr @_ZTC1D0_1B, i32 0, i32 0, i32 3),
-// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) ({ [4 x ptr], [4 x ptr] }, ptr @_ZTC1D0_1B, i32 0, i32 1, i32 3),
-// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) ({ [4 x ptr], [4 x ptr] }, ptr @_ZTC1D16_1C, i32 0, i32 0, i32 3),
-// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) ({ [4 x ptr], [4 x ptr] }, ptr @_ZTC1D16_1C, i32 0, i32 1, i32 3),
-// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) ({ [5 x ptr], [4 x ptr], [4 x ptr] }, ptr @_ZTV1D, i32 0, i32 2, i32 3),
-// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) ({ [5 x ptr], [4 x ptr], [4 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 3)
+// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 16) (i8, ptr @_ZTV1D, i64 24),
+// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) (i8, ptr @_ZTC1D0_1B, i64 24),
+// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) (i8, ptr @_ZTC1D0_1B, i64 56),
+// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) (i8, ptr @_ZTC1D16_1C, i64 24),
+// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) (i8, ptr @_ZTC1D16_1C, i64 56),
+// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) (i8, ptr @_ZTV1D, i64 96),
+// OGCG-COMMON-SAME: ptr getelementptr inbounds inrange(-24, 8) (i8, ptr @_ZTV1D, i64 64)
// OGCG-COMMON-SAME: ], align 8
// Construction vtable for B-in-D
@@ -234,7 +234,7 @@ void D::y() {}
// LLVM-RTTI-SAME: ptr @_ZTS1D, i32 2, i32 2, ptr @_ZTI1B, i64 2, ptr @_ZTI1C, i64 4098 }
// OGCG-RTTI: @_ZTI1D = constant { ptr, ptr, i32, i32, ptr, i64, ptr, i64 } {
-// OGCG-RTTI-SAME: ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2),
+// OGCG-RTTI-SAME: ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 16),
// OGCG-RTTI-SAME: ptr @_ZTS1D, i32 2, i32 2, ptr @_ZTI1B, i64 2, ptr @_ZTI1C, i64 4098 }, align 8
// OGCG-RTTI: @_ZTVN10__cxxabiv121__vmi_class_type_infoE = external global [0 x ptr]
@@ -522,11 +522,11 @@ D::D() {}
// OGCG-COMMON: call void @_ZN1BC2Ev(ptr {{.*}} %[[THIS]], ptr {{.*}} getelementptr inbounds nuw (i8, ptr @_ZTT1D, i64 8))
// OGCG-COMMON: %[[C_ADDR:.*]] = getelementptr inbounds i8, ptr %[[THIS]], i64 16
// OGCG-COMMON: call void @_ZN1CC2Ev(ptr {{.*}} %[[C_ADDR]], ptr {{.*}} getelementptr inbounds nuw (i8, ptr @_ZTT1D, i64 24))
-// OGCG-COMMON: store ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [4 x ptr], [4 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 3), ptr %[[THIS]]
+// OGCG-COMMON: store ptr getelementptr inbounds inrange(-24, 16) (i8, ptr @_ZTV1D, i64 24), ptr %[[THIS]]
// OGCG-COMMON: %[[A_ADDR:.*]] = getelementptr inbounds i8, ptr %[[THIS]], i64 40
-// OGCG-COMMON: store ptr getelementptr inbounds inrange(-24, 8) ({ [5 x ptr], [4 x ptr], [4 x ptr] }, ptr @_ZTV1D, i32 0, i32 2, i32 3), ptr %[[A_ADDR]]
+// OGCG-COMMON: store ptr getelementptr inbounds inrange(-24, 8) (i8, ptr @_ZTV1D, i64 96), ptr %[[A_ADDR]]
// OGCG-COMMON: %[[C_ADDR:.*]] = getelementptr inbounds i8, ptr %[[THIS]], i64 16
-// OGCG-COMMON: store ptr getelementptr inbounds inrange(-24, 8) ({ [5 x ptr], [4 x ptr], [4 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 3), ptr %[[C_ADDR]]
+// OGCG-COMMON: store ptr getelementptr inbounds inrange(-24, 8) (i8, ptr @_ZTV1D, i64 64), ptr %[[C_ADDR]]
// Base (C2) constructor for A
@@ -549,4 +549,4 @@ D::D() {}
// OGCG-COMMON: %[[THIS_ADDR:.*]] = alloca ptr
// OGCG-COMMON: store ptr %[[THIS_ARG]], ptr %[[THIS_ADDR]]
// OGCG-COMMON: %[[THIS:.*]] = load ptr, ptr %[[THIS_ADDR]]
-// OGCG-COMMON: store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 2), ptr %[[THIS]]
+// OGCG-COMMON: store ptr getelementptr inbounds inrange(-16, 8) (i8, ptr @_ZTV1A, i64 16), ptr %[[THIS]]
diff --git a/clang/test/CIR/CodeGenCXX/base-layout.cpp b/clang/test/CIR/CodeGenCXX/base-layout.cpp
index 62d2a1e8b285f7..a083e435194ddc 100644
--- a/clang/test/CIR/CodeGenCXX/base-layout.cpp
+++ b/clang/test/CIR/CodeGenCXX/base-layout.cpp
@@ -16,7 +16,7 @@ struct D : V3, B {};
constinit D d{};
// CIR: cir.global external @d = #cir.const_record<{#cir.const_record<{#cir.global_view<@_ZTV1D, [0 : i32, 2 : i32]> : !cir.vptr}> : !rec_V3, #cir.const_record<{#cir.const_record<{#cir.global_view<@_ZTV1D, [1 : i32, 2 : i32]> : !cir.vptr}> : !rec_V1, #cir.const_record<{#cir.global_view<@_ZTV1D, [2 : i32, 2 : i32]> : !cir.vptr}> : !rec_V2}> : !rec_B}> : !rec_D
// LLVM: @d = global %struct.D { %struct.V3 { ptr getelementptr inbounds nuw (i8, ptr @_ZTV1D, i64 16) }, %struct.B { %struct.V1 { ptr getelementptr inbounds nuw (i8, ptr @_ZTV1D, i64 40) }, %struct.V2 { ptr getelementptr inbounds nuw (i8, ptr @_ZTV1D, i64 64) } } }
-// OGCG: @d = global { ptr, ptr, ptr } { ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr], [3 x ptr], [3 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 2), ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr], [3 x ptr], [3 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 2), ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr], [3 x ptr], [3 x ptr] }, ptr @_ZTV1D, i32 0, i32 2, i32 2) }
+// OGCG: @d = global { ptr, ptr, ptr } { ptr getelementptr inbounds inrange(-16, 8) (i8, ptr @_ZTV1D, i64 16), ptr getelementptr inbounds inrange(-16, 8) (i8, ptr @_ZTV1D, i64 40), ptr getelementptr inbounds inrange(-16, 8) (i8, ptr @_ZTV1D, i64 64) }
struct Base {
diff --git a/clang/test/CIR/CodeGenCXX/vtable-pure-deleted-funcs.cpp b/clang/test/CIR/CodeGenCXX/vtable-pure-deleted-funcs.cpp
index c2fca1bd744bc3..7fdc07062b7dd9 100644
--- a/clang/test/CIR/CodeGenCXX/vtable-pure-deleted-funcs.cpp
+++ b/clang/test/CIR/CodeGenCXX/vtable-pure-deleted-funcs.cpp
@@ -18,7 +18,7 @@ void Struct::f3(){}
// CIR: cir.global constant external @_ZTI6Struct = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv117__class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS6Struct> : !cir.ptr<!u8i>}>
// LLVM-CIR: @_ZTI6Struct = constant { ptr, ptr } { ptr getelementptr (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 16), ptr @_ZTS6Struct }
-// LLVM-OGCG: @_ZTI6Struct = constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS6Struct }
+// LLVM-OGCG: @_ZTI6Struct = constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 16), ptr @_ZTS6Struct }
//
// CIR: cir.func private dso_local @__cxa_pure_virtual()
// LLVM: declare {{.*}}void @__cxa_pure_virtual()
More information about the cfe-commits
mailing list