================
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o 
%t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o 
%t-cir.ll
+// RUN: FileCheck --check-prefixes=LLVM,LLVM-CIR --input-file=%t-cir.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefixes=LLVM,OGCG --input-file=%t.ll %s
+
+struct DA {
+  unsigned a : 31;
+  unsigned b : 1;
+  void *p;
+  void *q;
+};
+
+struct I {
+  unsigned a : 31;
+  unsigned b : 1;
+  unsigned w : 31;
+  unsigned u : 1;
+  unsigned long v;
+  void *t;
+};
+
+union U {
+  struct DA d;
+  struct I i;
+};
+
+unsigned readW(union U x) { return x.i.w; }
+
+// CIR:      cir.func{{.*}} @readW(%arg0: !cir.ptr<!rec_U> {llvm.align = 8 : 
i64, llvm.byval = !rec_U, llvm.noundef} loc({{.+}})) -> !u32i
+// CIR:        %[[X:.*]] = cir.alloca "x" align(8) init : !cir.ptr<!rec_U>
+// CIR:        cir.copy %arg0 align(8) to %[[X]] align(8) : !cir.ptr<!rec_U>
+
+// LLVM:       define dso_local i32 @readW(ptr noundef byval(%union.U) align 8 
%[[ARG:.+]])
+// LLVM-CIR:     %[[X:.+]] = alloca %union.U, align 8
+// LLVM-CIR:     call void @llvm.memcpy.p0.p0.i64(ptr align 8 %[[X]], ptr 
align 8 %[[ARG]], i64 24, i1 false)
----------------
adams381 wrote:

^ Yes, this exactly.  I'm working on that follow-up.  Its getting pretty big at 
this point.

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

Reply via email to