================
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++03 -fclangir 
-emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++03 -fclangir 
-emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM,LLVMCIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++03 -emit-llvm %s 
-o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM,OGCG
+
+struct Struct {
+  int member;
+  Struct(int);
+};
+
+extern "C" Struct getStruct(int i) { return i; }
+
+extern "C" void use() {
+  int g = getStruct(0).member;
+
+  // CIR-LABEL: @use()
+  // CIR: %[[G_ALLOCA:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["g", init]
+  // CIR: %[[TEMP_ALLOCA:.*]] = cir.alloca !rec_Struct, !cir.ptr<!rec_Struct>
+  // CIR: %[[ZERO:.*]] = cir.const #cir.int<0> : !s32i
+  // CIR: %[[GET_STRUCT_CALL:.*]] = cir.call @getStruct(%[[ZERO]])
+  // CIR: cir.store{{.*}} %[[GET_STRUCT_CALL]], %[[TEMP_ALLOCA]]
+  // CIR: %[[GET_MEMBER:.*]] = cir.get_member %[[TEMP_ALLOCA]][0] {name = 
"member"}
+  // CIR: %[[LOAD_MEM:.*]] = cir.load{{.*}}%[[GET_MEMBER]]
+  // CIR: cir.store{{.*}} %[[LOAD_MEM]], %[[G_ALLOCA]] : !s32i, !cir.ptr<!s32i>
+  //
+  // LLVM-LABEL: @use()
+  // LLVM: %[[G_ALLOCA:.*]] = alloca i32
+  // LLVM: %[[TEMP_ALLOCA:.*]] = alloca %struct.Struct
+  //
+  // LLVMCIR: %[[GET_STRUCT_CALL:.*]] = call %struct.Struct @getStruct(i32 
noundef 0)
+  // LLVMCIR: store %struct.Struct %[[GET_STRUCT_CALL]], ptr %[[TEMP_ALLOCA]]
+  // OGCG: %[[GET_STRUCT_CALL_BEFORE:.*]] = call i32 @getStruct(i32 noundef 0)
+  // OGCG: %[[GET_STRUCT_CALL:.*]] = getelementptr{{.*}}%struct.Struct, ptr 
%[[TEMP_ALLOCA]]
----------------
andykaylor wrote:

Are the indexes on this zero? I can't see from these checks if the LLVMCIR 
output is equivalent.

https://github.com/llvm/llvm-project/pull/190795
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to