1; Check that we will insert the correct padding if natural alignment of the 2; spilled data does not match the alignment specified in alloca instruction. 3; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s 4 5%PackedStruct = type <{ i64 }> 6 7declare void @consume(ptr) 8 9define ptr @f() presplitcoroutine { 10entry: 11 %data = alloca %PackedStruct, align 32 12 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) 13 %size = call i32 @llvm.coro.size.i32() 14 %alloc = call ptr @malloc(i32 %size) 15 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc) 16 call void @consume(ptr %data) 17 %0 = call i8 @llvm.coro.suspend(token none, i1 false) 18 switch i8 %0, label %suspend [i8 0, label %resume 19 i8 1, label %cleanup] 20resume: 21 call void @consume(ptr %data) 22 br label %cleanup 23 24cleanup: 25 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl) 26 call void @free(ptr %mem) 27 br label %suspend 28suspend: 29 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none) 30 ret ptr %hdl 31} 32 33; See if the padding was inserted before PackedStruct 34; CHECK-LABEL: %f.Frame = type { ptr, ptr, i1, [15 x i8], %PackedStruct } 35 36; See if we used correct index to access packed struct (padding is field 3) 37; CHECK-LABEL: @f( 38; CHECK: %[[DATA:.+]] = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 4 39; CHECK-NEXT: call void @consume(ptr %[[DATA]]) 40; CHECK: ret ptr 41 42; See if we used correct index to access packed struct (padding is field 3) 43; CHECK-LABEL: @f.resume( 44; CHECK: %[[DATA:.+]] = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 4 45; CHECK-NEXT: call void @consume(ptr %[[DATA]]) 46; CHECK: ret void 47 48declare ptr @llvm.coro.free(token, ptr) 49declare i32 @llvm.coro.size.i32() 50declare i8 @llvm.coro.suspend(token, i1) 51declare void @llvm.coro.resume(ptr) 52declare void @llvm.coro.destroy(ptr) 53 54declare token @llvm.coro.id(i32, ptr, ptr, ptr) 55declare i1 @llvm.coro.alloc(token) 56declare ptr @llvm.coro.begin(token, ptr) 57declare i1 @llvm.coro.end(ptr, i1, token) 58 59declare noalias ptr @malloc(i32) 60declare double @print(double) 61declare void @free(ptr) 62