// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes
// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
struct RT {
char A;
int B[10][20];
char C;
};
struct ST {
int X;
double Y;
struct RT Z;
};
// CHECK: Function Attrs: mustprogress noinline nounwind optnone
// CHECK-LABEL: @_Z3fooP2ST(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[S_ADDR:%.*]] = alloca ptr, align 8
// CHECK-NEXT: store ptr [[S:%.*]], ptr [[S_ADDR]], align 8
// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
// CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], ptr [[TMP0]], i64 1
// CHECK-NEXT: [[Z:%.*]] = getelementptr inbounds nuw [[STRUCT_ST]], ptr [[ARRAYIDX]], i32 0, i32 2
// CHECK-NEXT: [[B:%.*]] = getelementptr inbounds nuw [[STRUCT_RT:%.*]], ptr [[Z]], i32 0, i32 1
// CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x [20 x i32]], ptr [[B]], i64 0, i64 5
// CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [20 x i32], ptr [[ARRAYIDX1]], i64 0, i64 13
// CHECK-NEXT: ret ptr [[ARRAYIDX2]]
//
int *foo(struct ST *s) {
return &s[1].Z.B[5][13];
}