1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 2; RUN: opt < %s -passes=infer-alignment -S | FileCheck %s 3 4; ------------------------------------------------------------------------------ 5; Scalar type 6; ------------------------------------------------------------------------------ 7 8define void @alloca_local(i8 %x, i32 %y) { 9; CHECK-LABEL: define void @alloca_local 10; CHECK-SAME: (i8 [[X:%.*]], i32 [[Y:%.*]]) { 11; CHECK-NEXT: [[ALLOCA:%.*]] = alloca i32, align 4 12; CHECK-NEXT: [[LOAD_I8:%.*]] = load i8, ptr [[ALLOCA]], align 4 13; CHECK-NEXT: [[LOAD_I32:%.*]] = load i32, ptr [[ALLOCA]], align 4 14; CHECK-NEXT: store i8 [[X]], ptr [[ALLOCA]], align 4 15; CHECK-NEXT: store i32 [[Y]], ptr [[ALLOCA]], align 4 16; CHECK-NEXT: ret void 17; 18 %alloca = alloca i32, align 1 19 20 %load.i8 = load i8, ptr %alloca, align 1 21 %load.i32 = load i32, ptr %alloca, align 1 22 23 store i8 %x, ptr %alloca, align 1 24 store i32 %y, ptr %alloca, align 1 25 26 ret void 27} 28 29; ------------------------------------------------------------------------------ 30; Struct type 31; ------------------------------------------------------------------------------ 32 33%struct.pair = type { { i32, i32 }, { i32, i32 } } 34 35define void @alloca_struct(i32 %x) { 36; CHECK-LABEL: define void @alloca_struct 37; CHECK-SAME: (i32 [[X:%.*]]) { 38; CHECK-NEXT: [[ALLOCA_STRUCT:%.*]] = alloca [[STRUCT_PAIR:%.*]], align 8 39; CHECK-NEXT: [[GEP_0:%.*]] = getelementptr [[STRUCT_PAIR]], ptr [[ALLOCA_STRUCT]], i64 0, i32 1 40; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr { i32, i32 }, ptr [[GEP_0]], i64 0, i32 1 41; CHECK-NEXT: [[LOAD_2:%.*]] = load i32, ptr [[GEP_0]], align 8 42; CHECK-NEXT: store i32 0, ptr [[GEP_0]], align 8 43; CHECK-NEXT: [[LOAD_1:%.*]] = load i32, ptr [[GEP_1]], align 4 44; CHECK-NEXT: store i32 0, ptr [[GEP_1]], align 4 45; CHECK-NEXT: ret void 46; 47 %alloca.struct = alloca %struct.pair 48 49 %gep.0 = getelementptr %struct.pair, ptr %alloca.struct, i64 0, i32 1 50 %gep.1 = getelementptr { i32, i32 }, ptr %gep.0, i64 0, i32 1 51 52 %load.2 = load i32, ptr %gep.0, align 1 53 store i32 0, ptr %gep.0, align 1 54 55 %load.1 = load i32, ptr %gep.1, align 1 56 store i32 0, ptr %gep.1, align 1 57 58 ret void 59} 60