• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
3struct RT {
4  char A;
5  int B[10][20];
6  char C;
7};
8struct ST {
9  int X;
10  double Y;
11  struct RT Z;
12};
13
14// CHECK-LABEL: @_Z3fooP2ST(
15// CHECK-NEXT:  entry:
16// CHECK-NEXT:    [[S_ADDR:%.*]] = alloca %struct.ST*, align 8
17// CHECK-NEXT:    store %struct.ST* [[S:%.*]], %struct.ST** [[S_ADDR]], align 8
18// CHECK-NEXT:    [[TMP0:%.*]] = load %struct.ST*, %struct.ST** [[S_ADDR]], align 8
19// CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], %struct.ST* [[TMP0]], i64 1
20// CHECK-NEXT:    [[Z:%.*]] = getelementptr inbounds [[STRUCT_ST]], %struct.ST* [[ARRAYIDX]], i32 0, i32 2
21// CHECK-NEXT:    [[B:%.*]] = getelementptr inbounds [[STRUCT_RT:%.*]], %struct.RT* [[Z]], i32 0, i32 1
22// CHECK-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x [20 x i32]], [10 x [20 x i32]]* [[B]], i64 0, i64 5
23// CHECK-NEXT:    [[ARRAYIDX2:%.*]] = getelementptr inbounds [20 x i32], [20 x i32]* [[ARRAYIDX1]], i64 0, i64 13
24// CHECK-NEXT:    ret i32* [[ARRAYIDX2]]
25//
26int *foo(struct ST *s) {
27  return &s[1].Z.B[5][13];
28}
29