176 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 42; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s3 4target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"5target triple = "thumbv7-none-linux-android19"6 7define i32 @r() {8; CHECK-LABEL: define i32 @r() {9; CHECK-NEXT: entry:10; CHECK-NEXT: [[DOTLOC:%.*]] = alloca ptr, align 411; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[DOTLOC]])12; CHECK-NEXT: [[TMP0:%.*]] = call i1 @outlined_ir_func_0(ptr [[DOTLOC]], i32 0)13; CHECK-NEXT: [[DOTRELOAD:%.*]] = load ptr, ptr [[DOTLOC]], align 414; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[DOTLOC]])15; CHECK-NEXT: br i1 [[TMP0]], label [[IF_END8:%.*]], label [[ENTRY_AFTER_OUTLINE:%.*]]16; CHECK: entry_after_outline:17; CHECK-NEXT: [[CALL7:%.*]] = call i32 [[DOTRELOAD]]()18; CHECK-NEXT: br label [[IF_END8]]19; CHECK: if.end8:20; CHECK-NEXT: ret i32 021;22entry:23 %.fca.2.insert = insertvalue [5 x i32] zeroinitializer, i32 0, 224 %.fca.3.load = load i32, ptr null, align 425 %.fca.3.insert = insertvalue [5 x i32] zeroinitializer, i32 0, 326 %.fca.4.load = load i32, ptr null, align 427 %.fca.4.insert = insertvalue [5 x i32] zeroinitializer, i32 0, 428 %call = call i32 @p()29 %tobool.not = icmp eq i32 0, 030 br i1 false, label %if.end8, label %if.then31 32if.then: ; preds = %entry33 %0 = load i32, ptr null, align 434 %tobool1.not = icmp eq i32 0, 035 %1 = load i32, ptr null, align 436 %2 = load i32, ptr null, align 437 %cond = select i1 false, i32 0, i32 038 %tobool5.not = icmp eq i32 0, 039 br i1 false, label %if.end8, label %if.then640 41if.then6: ; preds = %if.then42 %3 = load ptr, ptr null, align 443 %call7 = call i32 %3()44 br label %if.end845 46if.end8: ; preds = %if.then6, %if.then, %entry47 ret i32 048}49 50declare i32 @p()51 52define i32 @u() {53; CHECK-LABEL: define i32 @u() {54; CHECK-NEXT: entry:55; CHECK-NEXT: [[TMP0:%.*]] = call i1 @outlined_ir_func_0(ptr null, i32 -1)56; CHECK-NEXT: br i1 [[TMP0]], label [[IF_END8:%.*]], label [[ENTRY_AFTER_OUTLINE:%.*]]57; CHECK: entry_after_outline:58; CHECK-NEXT: br label [[IF_END8]]59; CHECK: if.end8:60; CHECK-NEXT: ret i32 061;62entry:63 %.fca.2.insert = insertvalue [5 x i32] zeroinitializer, i32 0, 264 %.fca.3.load = load i32, ptr null, align 465 %.fca.3.insert = insertvalue [5 x i32] zeroinitializer, i32 0, 366 %.fca.4.load = load i32, ptr null, align 467 %.fca.4.insert = insertvalue [5 x i32] zeroinitializer, i32 0, 468 %call = call i32 @p()69 %tobool.not = icmp eq i32 0, 070 br i1 false, label %if.end8, label %if.then71 72if.then: ; preds = %entry73 %0 = load i32, ptr null, align 474 %tobool1.not = icmp eq i32 0, 075 %1 = load i32, ptr null, align 476 %2 = load i32, ptr null, align 477 %cond = select i1 false, i32 0, i32 078 %tobool5.not = icmp eq i32 0, 079 br i1 false, label %if.end8, label %if.then680 81if.then6: ; preds = %if.then82 %3 = load ptr, ptr null, align 483 br label %if.end884 85if.end8: ; preds = %if.then6, %if.then, %entry86 ret i32 087}88 89define i32 @w() !dbg !8 {90; CHECK-LABEL: define i32 @w(91; CHECK-SAME: ) !dbg [[DBG8:![0-9]+]] {92; CHECK-NEXT: entry:93; CHECK-NEXT: [[RETVAL_1_CE_LOC:%.*]] = alloca i32, align 494; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr [[RETVAL_1_CE_LOC]])95; CHECK-NEXT: [[TMP0:%.*]] = call i1 @outlined_ir_func_0(ptr [[RETVAL_1_CE_LOC]], i32 1), !dbg [[DBG11:![0-9]+]]96; CHECK-NEXT: [[RETVAL_1_CE_RELOAD:%.*]] = load i32, ptr [[RETVAL_1_CE_LOC]], align 497; CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr [[RETVAL_1_CE_LOC]])98; CHECK-NEXT: br i1 [[TMP0]], label [[CLEANUP10:%.*]], label [[ENTRY_AFTER_OUTLINE:%.*]]99; CHECK: entry_after_outline:100; CHECK-NEXT: [[CALL8:%.*]] = call i32 @llvm.bswap.i32(i32 0)101; CHECK-NEXT: br label [[CLEANUP10]]102; CHECK: cleanup10:103; CHECK-NEXT: [[RETVAL_1:%.*]] = phi i32 [ 0, [[ENTRY_AFTER_OUTLINE]] ], [ [[RETVAL_1_CE_RELOAD]], [[ENTRY:%.*]] ]104; CHECK-NEXT: ret i32 0105;106entry:107 %.fca.2.insert = insertvalue [5 x i32] zeroinitializer, i32 0, 2108 %.fca.3.load = load i32, ptr null, align 4109 %.fca.3.insert = insertvalue [5 x i32] zeroinitializer, i32 0, 3110 %.fca.4.load = load i32, ptr null, align 4111 %.fca.4.insert = insertvalue [5 x i32] zeroinitializer, i32 0, 4112 %call = call i32 @p()113 %tobool.not = icmp eq i32 0, 0114 br i1 false, label %cleanup10, label %if.then115 116if.then: ; preds = %entry117 call void @llvm.dbg.value(metadata i32 0, metadata !11, metadata !DIExpression()), !dbg !15118 %0 = load i32, ptr null, align 4119 %tobool1.not = icmp eq i32 0, 0120 %1 = load i32, ptr null, align 4121 %2 = load i32, ptr null, align 4122 %cond = select i1 false, i32 0, i32 0123 %tobool5.not = icmp eq i32 0, 0124 br i1 false, label %cleanup10, label %cleanup125 126cleanup: ; preds = %if.then127 %3 = load ptr, ptr null, align 4128 %call8 = call i32 @llvm.bswap.i32(i32 0)129 br label %cleanup10130 131cleanup10: ; preds = %cleanup, %if.then, %entry132 %retval.1 = phi i32 [ 0, %cleanup ], [ 0, %entry ], [ 0, %if.then ]133 ret i32 0134}135 136; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)137declare void @llvm.dbg.value(metadata, metadata, metadata) #0138 139; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)140declare i32 @llvm.bswap.i32(i32) #0141 142attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }143 144!llvm.dbg.cu = !{!0}145!llvm.module.flags = !{!7}146 147!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 18.0.0 (https://github.com/llvm/llvm-project.git 2ca028ce7c6de5f1350440012355a65383b8729a)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !2, splitDebugInlining: false, nameTableKind: None)148!1 = !DIFile(filename: "/tmp/foo.c", directory: "/home/davidino/llvm-build-upstream")149!2 = !{!3}150!3 = !DIGlobalVariableExpression(var: !4, expr: !DIExpression())151!4 = distinct !DIGlobalVariable(name: "n", scope: !0, file: !5, line: 19, type: !6, isLocal: false, isDefinition: true)152!5 = !DIFile(filename: "/tmp/foo.c", directory: "")153!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)154!7 = !{i32 2, !"Debug Info Version", i32 3}155!8 = distinct !DISubprogram(name: "w", scope: !5, file: !5, line: 54, type: !9, scopeLine: 54, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)156!9 = !DISubroutineType(types: !10)157!10 = !{}158!11 = !DILocalVariable(name: "t", scope: !12, file: !5, line: 57, type: !14)159!12 = distinct !DILexicalBlock(scope: !13, file: !5, line: 56, column: 17)160!13 = distinct !DILexicalBlock(scope: !8, file: !5, line: 56, column: 11)161!14 = !DIDerivedType(tag: DW_TAG_typedef, name: "a", file: !5, line: 2, baseType: !6)162!15 = !DILocation(line: 0, scope: !12)163;.164; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: [[META2:![0-9]+]], splitDebugInlining: false, nameTableKind: None)165; CHECK: [[META1]] = !DIFile(filename: "/tmp/foo.c", directory: {{.*}})166; CHECK: [[META2]] = !{[[META3:![0-9]+]]}167; CHECK: [[META3]] = !DIGlobalVariableExpression(var: [[META4:![0-9]+]], expr: !DIExpression())168; CHECK: [[META4]] = distinct !DIGlobalVariable(name: "n", scope: [[META0]], file: [[META5:![0-9]+]], line: 19, type: [[META6:![0-9]+]], isLocal: false, isDefinition: true)169; CHECK: [[META5]] = !DIFile(filename: "/tmp/foo.c", directory: "")170; CHECK: [[META6]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)171; CHECK: [[DBG8]] = distinct !DISubprogram(name: "w", scope: [[META5]], file: [[META5]], line: 54, type: [[META9:![0-9]+]], scopeLine: 54, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META10:![0-9]+]])172; CHECK: [[META9]] = !DISubroutineType(types: [[META10]])173; CHECK: [[META10]] = !{}174; CHECK: [[DBG11]] = !DILocation(line: 0, scope: [[DBG8]])175;.176