brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · a8153a4 Raw
128 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs2; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s3 4; This test ensures that an extra output is not added when there is a bitcast5; that is relocated to outside of the extraction due to a starting lifetime6; instruction outside of the extracted region.7 8; Additionally, we check that the newly added bitcast instruction is excluded in9; further extractions.10 11declare void @llvm.lifetime.start.p0(ptr nocapture)12declare void @llvm.lifetime.end.p0(ptr nocapture)13 14define void @outline_bitcast_base() {15entry:16  %a = alloca i32, align 417  %b = alloca i32, align 418  %c = alloca i32, align 419  %d = alloca i32, align 420  store i32 2, ptr %a, align 421  store i32 3, ptr %b, align 422  store i32 4, ptr %c, align 423  %al = load i32, ptr %a24  %bl = load i32, ptr %b25  %cl = load i32, ptr %c26  ret void27}28 29define void @outline_bitcast_removed() {30entry:31  %a = alloca i32, align 432  %b = alloca i32, align 433  %c = alloca i32, align 434  %d = alloca i32, align 435  store i32 2, ptr %a, align 436  store i32 3, ptr %b, align 437  store i32 4, ptr %c, align 438  %al = load i32, ptr %a39  %bl = load i32, ptr %b40  %cl = load i32, ptr %c41  call void @llvm.lifetime.start.p0(ptr %d)42  %am = load i32, ptr %b43  %bm = load i32, ptr %a44  %cm = load i32, ptr %c45  call void @llvm.lifetime.end.p0(ptr %d)46  ret void47}48 49; The first bitcast is moved down to lifetime start, and, since the original50; endpoint does not match the new endpoint, we cannot extract and outline the51; second bitcast and set of adds.  Outlining only occurs in this case due to52; the lack of a cost model, as denoted by the debug command line argument.53 54define void @outline_bitcast_base2(i32 %a, i32 %b, i32 %c) {55entry:56  %d = alloca i32, align 457  %al = add i32 %a, %b58  %bl = add i32 %b, %a59  %cl = add i32 %b, %c60  %buffer = mul i32 %a, %b61  %am = add i32 %a, %b62  %bm = add i32 %b, %a63  %cm = add i32 %b, %c64  call void @llvm.lifetime.start.p0(ptr %d)65  call void @llvm.lifetime.end.p0(ptr %d)66  ret void67}68 69; CHECK-LABEL: @outline_bitcast_base(70; CHECK-NEXT:  entry:71; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 472; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 473; CHECK-NEXT:    [[C:%.*]] = alloca i32, align 474; CHECK-NEXT:    [[D:%.*]] = alloca i32, align 475; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]])76; CHECK-NEXT:    ret void77;78;79; CHECK-LABEL: @outline_bitcast_removed(80; CHECK-NEXT:  entry:81; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 482; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 483; CHECK-NEXT:    [[C:%.*]] = alloca i32, align 484; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]])85; CHECK-NEXT:    [[AM:%.*]] = load i32, ptr [[B]], align 486; CHECK-NEXT:    [[BM:%.*]] = load i32, ptr [[A]], align 487; CHECK-NEXT:    [[CM:%.*]] = load i32, ptr [[C]], align 488; CHECK-NEXT:    ret void89;90;91; CHECK-LABEL: @outline_bitcast_base2(92; CHECK-NEXT:  entry:93; CHECK-NEXT:    call void @outlined_ir_func_1(i32 [[A:%.*]], i32 [[B:%.*]], i32 [[C:%.*]])94; CHECK-NEXT:    [[BUFFER:%.*]] = mul i32 [[A]], [[B]]95; CHECK-NEXT:    call void @outlined_ir_func_1(i32 [[A]], i32 [[B]], i32 [[C]])96; CHECK-NEXT:    ret void97;98;99; CHECK-LABEL: @outlined_ir_func_0(100; CHECK-NEXT:  newFuncRoot:101; CHECK-NEXT:    br label [[ENTRY_TO_OUTLINE:%.*]]102; CHECK:       entry_to_outline:103; CHECK-NEXT:    store i32 2, ptr [[TMP0:%.*]], align 4104; CHECK-NEXT:    store i32 3, ptr [[TMP1:%.*]], align 4105; CHECK-NEXT:    store i32 4, ptr [[TMP2:%.*]], align 4106; CHECK-NEXT:    [[AL:%.*]] = load i32, ptr [[TMP0]], align 4107; CHECK-NEXT:    [[BL:%.*]] = load i32, ptr [[TMP1]], align 4108; CHECK-NEXT:    [[CL:%.*]] = load i32, ptr [[TMP2]], align 4109; CHECK-NEXT:    br label [[ENTRY_AFTER_OUTLINE_EXITSTUB:%.*]]110; CHECK:       entry_after_outline.exitStub:111; CHECK-NEXT:    ret void112;113;114; CHECK-LABEL: @outlined_ir_func_1(115; CHECK-NEXT:  newFuncRoot:116; CHECK-NEXT:    [[D:%.*]] = alloca i32, align 4117; CHECK-NEXT:    call void @llvm.lifetime.start.p0(ptr [[D]])118; CHECK-NEXT:    br label [[ENTRY_TO_OUTLINE:%.*]]119; CHECK:       entry_to_outline:120; CHECK-NEXT:    [[AL:%.*]] = add i32 [[TMP0:%.*]], [[TMP1:%.*]]121; CHECK-NEXT:    [[BL:%.*]] = add i32 [[TMP1]], [[TMP0]]122; CHECK-NEXT:    [[CL:%.*]] = add i32 [[TMP1]], [[TMP2:%.*]]123; CHECK-NEXT:    call void @llvm.lifetime.end.p0(ptr [[D]])124; CHECK-NEXT:    br label [[ENTRY_AFTER_OUTLINE_EXITSTUB:%.*]]125; CHECK:       entry_after_outline.exitStub:126; CHECK-NEXT:    ret void127;128