diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
| commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
| tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /test/Transforms/CodeExtractor | |
| parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) | |
Notes
Diffstat (limited to 'test/Transforms/CodeExtractor')
7 files changed, 593 insertions, 1 deletions
diff --git a/test/Transforms/CodeExtractor/PartialInlineDebug.ll b/test/Transforms/CodeExtractor/PartialInlineDebug.ll new file mode 100644 index 000000000000..f03b38345611 --- /dev/null +++ b/test/Transforms/CodeExtractor/PartialInlineDebug.ll @@ -0,0 +1,104 @@ +; RUN: opt < %s -S -partial-inliner -skip-partial-inlining-cost-analysis=true | FileCheck %s + +; CHECK-LABEL: @callee +; CHECK: %mul = mul nsw i32 %v, 10, !dbg ![[DBG1:[0-9]+]] +define i32 @callee(i32 %v) !dbg !16 { +entry: + %cmp = icmp sgt i32 %v, 2000 + br i1 %cmp, label %if.then, label %if.end + +if.then: ; preds = %entry + %mul = mul nsw i32 %v, 10, !dbg !17 + br label %if.then2 + +if.then2: + %sub = sub i32 %v, 10, !dbg !23 + br label %if.end + +if.end: ; preds = %if.then, %entry + %v2 = phi i32 [ %v, %entry ], [ %mul, %if.then2 ] + %add = add nsw i32 %v2, 200 + ret i32 %add +} + +; CHECK-LABEL: @caller +; CHECK: codeRepl.i: +; CHECK-NEXT: call void @callee.2_if.then(i32 %v, i32* %mul.loc.i), !dbg ![[DBG2:[0-9]+]] +define i32 @caller(i32 %v) !dbg !8 { +entry: + %call = call i32 @callee(i32 %v), !dbg !14 + ret i32 %call +} + + +; CHECK-LABEL: @callee2 +; CHECK: %sub = sub i32 %v, 10, !dbg ![[DBG3:[0-9]+]] +define i32 @callee2(i32 %v) !dbg !18 { +entry: + %cmp = icmp sgt i32 %v, 2000 + br i1 %cmp, label %if.then, label %if.end + +if.then: + br label %if.then2 + +if.then2: + %sub = sub i32 %v, 10, !dbg !20 + br label %if.end + +if.end: + %v2 = phi i32 [ %v, %entry ], [ %sub, %if.then2 ] + %add = add nsw i32 %v2, 200 + ret i32 %add +} + +; CHECK-LABEL: @caller2 +; CHECK: codeRepl.i: +; CHECK-NEXT: call void @callee2.1_if.then(i32 %v, i32* %sub.loc.i), !dbg ![[DBG4:[0-9]+]] +define i32 @caller2(i32 %v) !dbg !21 { +entry: + %call = call i32 @callee2(i32 %v), !dbg !22 + ret i32 %call +} + +; CHECK-LABEL: define internal void @callee2.1_if.then +; CHECK: br label %if.then, !dbg ![[DBG5:[0-9]+]] + +; CHECK-LABEL: define internal void @callee.2_if.then +; CHECK: br label %if.then, !dbg ![[DBG6:[0-9]+]] + +; CHECK: ![[DBG1]] = !DILocation(line: 10, column: 7, +; CHECK: ![[DBG2]] = !DILocation(line: 10, column: 7, +; CHECK: ![[DBG3]] = !DILocation(line: 110, column: 17, +; CHECK: ![[DBG4]] = !DILocation(line: 110, column: 17, +; CHECK: ![[DBG5]] = !DILocation(line: 110, column: 17, +; CHECK: ![[DBG6]] = !DILocation(line: 10, column: 7, + + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5, !6} +!llvm.ident = !{!7} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 (trunk 177881)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) +!1 = !DIFile(filename: "test.c", directory: "/tmp") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{i32 1, !"min_enum_size", i32 4} +!7 = !{!"clang version 6.0.0"} +!8 = distinct !DISubprogram(name: "caller", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !12) +!9 = !DISubroutineType(types: !10) +!10 = !{!11, !11} +!11 = !DIBasicType(name: "int", size: 19, encoding: DW_ATE_signed) +!12 = !{!13} +!13 = !DILocalVariable(name: "v", arg: 1, scope: !8, file: !1, line: 3, type: !11) +!14 = !DILocation(line: 5, column: 10, scope: !8) +!15 = distinct !DILexicalBlock(scope: !16, file: !1, line: 9, column: 7) +!16 = distinct !DISubprogram(name: "callee", scope: !1, file: !1, line: 8, type: !9, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !12) +!17 = !DILocation(line: 10, column: 7, scope: !15) +!18 = distinct !DISubprogram(name: "callee2", scope: !1, file: !1, line: 8, type: !9, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !12) +!19 = distinct !DILexicalBlock(scope: !18, file: !1, line: 100, column: 1) +!20 = !DILocation(line: 110, column: 17, scope: !19) +!21 = distinct !DISubprogram(name: "caller2", scope: !1, file: !1, line: 8, type: !9, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !12) +!22 = !DILocation(line: 110, column: 17, scope: !21) +!23 = !DILocation(line: 15, column: 7, scope: !15) diff --git a/test/Transforms/CodeExtractor/PartialInlineNoInline.ll b/test/Transforms/CodeExtractor/PartialInlineNoInline.ll new file mode 100644 index 000000000000..6c0b83298d23 --- /dev/null +++ b/test/Transforms/CodeExtractor/PartialInlineNoInline.ll @@ -0,0 +1,45 @@ +; RUN: opt < %s -partial-inliner -S -stats -pass-remarks=partial-inlining 2>&1 | FileCheck %s +; RUN: opt < %s -passes=partial-inliner -S -stats -pass-remarks=partial-inlining 2>&1 | FileCheck %s + +@stat = external global i32, align 4 + +define i32 @inline_fail(i32 %count, ...) { +entry: + %vargs = alloca i8*, align 8 + %vargs1 = bitcast i8** %vargs to i8* + call void @llvm.va_start(i8* %vargs1) + %stat1 = load i32, i32* @stat, align 4 + %cmp = icmp slt i32 %stat1, 0 + br i1 %cmp, label %bb2, label %bb1 + +bb1: ; preds = %entry + %vg1 = add nsw i32 %stat1, 1 + store i32 %vg1, i32* @stat, align 4 + %va1 = va_arg i8** %vargs, i32 + call void @foo(i32 %count, i32 %va1) #2 + br label %bb2 + +bb2: ; preds = %bb1, %entry + %res = phi i32 [ 1, %bb1 ], [ 0, %entry ] + call void @llvm.va_end(i8* %vargs1) + ret i32 %res +} + +define i32 @caller(i32 %arg) { +bb: + %res = tail call i32 (i32, ...) @inline_fail(i32 %arg, i32 %arg) + ret i32 %res +} + +declare void @foo(i32, i32) +declare void @llvm.va_start(i8*) +declare void @llvm.va_end(i8*) + +; Check that no remarks have been emitted, inline_fail has not been partial +; inlined, no code has been extracted and the partial-inlining counter +; has not been incremented. + +; CHECK-NOT: remark +; CHECK: tail call i32 (i32, ...) @inline_fail(i32 %arg, i32 %arg) +; CHECK-NOT: inline_fail.1_bb1 +; CHECK-NOT: partial-inlining diff --git a/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll b/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll new file mode 100644 index 000000000000..a51bdd01df5a --- /dev/null +++ b/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll @@ -0,0 +1,169 @@ +; RUN: opt -S -partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s +; RUN: opt -S -passes=partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s +; Require a dummy block (if.then.b) as successor to if.then due to PI requirement +; of region containing more than one BB. +define signext i32 @bar(i32 signext %value, i32 signext %ub) #0 !prof !30 { +entry: + %value.addr = alloca i32, align 4 + %ub.addr = alloca i32, align 4 + %sum = alloca i32, align 4 + %i = alloca i32, align 4 + store i32 %value, i32* %value.addr, align 4 + store i32 %ub, i32* %ub.addr, align 4 + store i32 0, i32* %sum, align 4 + store i32 0, i32* %i, align 4 + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %0 = load i32, i32* %i, align 4 + %1 = load i32, i32* %ub.addr, align 4 + %cmp = icmp slt i32 %0, %1 + br i1 %cmp, label %for.body, label %for.cond2, !prof !31 + +for.body: ; preds = %for.cond + %2 = load i32, i32* %value.addr, align 4 + %rem = srem i32 %2, 20 + %cmp1 = icmp eq i32 %rem, 0 + br i1 %cmp1, label %if.then, label %if.else, !prof !32 + +if.then: ; preds = %for.body + %3 = load i32, i32* %value.addr, align 4 + %4 = load i32, i32* %i, align 4 + %mul = mul nsw i32 %4, 5 + %add = add nsw i32 %3, %mul + %5 = load i32, i32* %sum, align 4 + %add2 = add nsw i32 %5, %add + store i32 %add2, i32* %sum, align 4 + br label %if.then.b + +if.then.b: ; preds = %if.then + br label %if.end + +if.else: ; preds = %for.body + %6 = load i32, i32* %value.addr, align 4 + %7 = load i32, i32* %i, align 4 + %sub = sub nsw i32 %6, %7 + %8 = load i32, i32* %sum, align 4 + %add3 = add nsw i32 %8, %sub + store i32 %add3, i32* %sum, align 4 + br label %if.end + +if.end: ; preds = %if.else, %if.then + br label %for.inc + +for.inc: ; preds = %if.end + %9 = load i32, i32* %i, align 4 + %inc = add nsw i32 %9, 1 + store i32 %inc, i32* %i, align 4 + br label %for.cond + +for.cond2: ; preds = %for.cond + %10 = load i32, i32* %i, align 4 + %11 = load i32, i32* %ub.addr, align 4 + %cmp2 = icmp slt i32 %10, %11 + br i1 %cmp2, label %for.body2, label %for.end, !prof !31 + +for.body2: ; preds = %for.cond2 + %12 = load i32, i32* %value.addr, align 4 + %rem2 = srem i32 %12, 20 + %cmp3 = icmp eq i32 %rem2, 0 + br i1 %cmp3, label %if.then2, label %if.else2, !prof !32 + +if.then2: ; preds = %for.body2 + %13 = load i32, i32* %value.addr, align 4 + %14 = load i32, i32* %i, align 4 + %mul2 = mul nsw i32 %14, 5 + %add4 = add nsw i32 %13, %mul2 + %15 = load i32, i32* %sum, align 4 + %add5 = add nsw i32 %15, %add4 + store i32 %add5, i32* %sum, align 4 + br label %if.then2.b + +if.then2.b: ; preds = %if.then2 + br label %if.end2 + +if.else2: ; preds = %for.body2 + %16 = load i32, i32* %value.addr, align 4 + %17 = load i32, i32* %i, align 4 + %sub2 = sub nsw i32 %16, %17 + %18 = load i32, i32* %sum, align 4 + %add6 = add nsw i32 %18, %sub2 + store i32 %add6, i32* %sum, align 4 + br label %if.end2 + +if.end2: ; preds = %if.else2, %if.then2 + br label %for.inc2 + +for.inc2: ; preds = %if.end2 + %19 = load i32, i32* %i, align 4 + %inc2 = add nsw i32 %19, 1 + store i32 %inc2, i32* %i, align 4 + br label %for.cond2 + +for.end: ; preds = %for.cond2 + %20 = load i32, i32* %sum, align 4 + ret i32 %20 +} + +define signext i32 @foo(i32 signext %value, i32 signext %ub) #0 !prof !30 { +; CHECK-LABEL: @foo +; CHECK-NOT: call signext i32 @bar +; CHECK: codeRepl1.i: +; CHECK: call void @bar.1_if.then +; CHECK: codeRepl.i: +; CHECK: call void @bar.1_if.then2 +entry: + %value.addr = alloca i32, align 4 + %ub.addr = alloca i32, align 4 + store i32 %value, i32* %value.addr, align 4 + store i32 %ub, i32* %ub.addr, align 4 + %0 = load i32, i32* %value.addr, align 4 + %1 = load i32, i32* %ub.addr, align 4 + %call = call signext i32 @bar(i32 signext %0, i32 signext %1) + ret i32 %call +} + +; CHECK-LABEL: define internal void @bar.1_if.then2 +; CHECK: .exitStub: +; CHECK: ret void + +; CHECK-LABEL: define internal void @bar.1_if.then +; CHECK: .exitStub: +; CHECK: ret void + +!llvm.module.flags = !{!0, !1, !2} +!llvm.ident = !{!29} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 1, !"ProfileSummary", !3} +!3 = !{!4, !5, !6, !7, !8, !9, !10, !11} +!4 = !{!"ProfileFormat", !"InstrProf"} +!5 = !{!"TotalCount", i64 103} +!6 = !{!"MaxCount", i64 100} +!7 = !{!"MaxInternalCount", i64 1} +!8 = !{!"MaxFunctionCount", i64 100} +!9 = !{!"NumCounts", i64 5} +!10 = !{!"NumFunctions", i64 3} +!11 = !{!"DetailedSummary", !12} +!12 = !{!13, !14, !15, !16, !17, !18, !18, !19, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28} +!13 = !{i32 10000, i64 100, i32 1} +!14 = !{i32 100000, i64 100, i32 1} +!15 = !{i32 200000, i64 100, i32 1} +!16 = !{i32 300000, i64 100, i32 1} +!17 = !{i32 400000, i64 100, i32 1} +!18 = !{i32 500000, i64 100, i32 1} +!19 = !{i32 600000, i64 100, i32 1} +!20 = !{i32 700000, i64 100, i32 1} +!21 = !{i32 800000, i64 100, i32 1} +!22 = !{i32 900000, i64 100, i32 1} +!23 = !{i32 950000, i64 100, i32 1} +!24 = !{i32 990000, i64 1, i32 4} +!25 = !{i32 999000, i64 1, i32 4} +!26 = !{i32 999900, i64 1, i32 4} +!27 = !{i32 999990, i64 1, i32 4} +!28 = !{i32 999999, i64 1, i32 4} +!29 = !{!"clang version 6.0.0 (123456)"} +!30 = !{!"function_entry_count", i64 2} +!31 = !{!"branch_weights", i32 100, i32 1} +!32 = !{!"branch_weights", i32 0, i32 100} diff --git a/test/Transforms/CodeExtractor/PartialInlinePGORegion.ll b/test/Transforms/CodeExtractor/PartialInlinePGORegion.ll new file mode 100644 index 000000000000..27c858f3de60 --- /dev/null +++ b/test/Transforms/CodeExtractor/PartialInlinePGORegion.ll @@ -0,0 +1,120 @@ +; RUN: opt -S -partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s +; RUN: opt -S -passes=partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s +; Require a dummy block (if.then.b) as successor to if.then due to PI requirement +; of region containing more than one BB. +define signext i32 @bar(i32 signext %value, i32 signext %ub) #0 !prof !30 { +entry: + %value.addr = alloca i32, align 4 + %ub.addr = alloca i32, align 4 + %sum = alloca i32, align 4 + %i = alloca i32, align 4 + store i32 %value, i32* %value.addr, align 4 + store i32 %ub, i32* %ub.addr, align 4 + store i32 0, i32* %sum, align 4 + store i32 0, i32* %i, align 4 + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %0 = load i32, i32* %i, align 4 + %1 = load i32, i32* %ub.addr, align 4 + %cmp = icmp slt i32 %0, %1 + br i1 %cmp, label %for.body, label %for.end, !prof !31 + +for.body: ; preds = %for.cond + %2 = load i32, i32* %value.addr, align 4 + %rem = srem i32 %2, 20 + %cmp1 = icmp eq i32 %rem, 0 + br i1 %cmp1, label %if.then, label %if.else, !prof !32 + +if.then: ; preds = %for.body + %3 = load i32, i32* %value.addr, align 4 + %4 = load i32, i32* %i, align 4 + %mul = mul nsw i32 %4, 5 + %add = add nsw i32 %3, %mul + %5 = load i32, i32* %sum, align 4 + %add2 = add nsw i32 %5, %add + store i32 %add2, i32* %sum, align 4 + br label %if.then.b + +if.then.b: ; preds = %if.then + br label %if.end + +if.else: ; preds = %for.body + %6 = load i32, i32* %value.addr, align 4 + %7 = load i32, i32* %i, align 4 + %sub = sub nsw i32 %6, %7 + %8 = load i32, i32* %sum, align 4 + %add3 = add nsw i32 %8, %sub + store i32 %add3, i32* %sum, align 4 + br label %if.end + +if.end: ; preds = %if.else, %if.then + br label %for.inc + +for.inc: ; preds = %if.end + %9 = load i32, i32* %i, align 4 + %inc = add nsw i32 %9, 1 + store i32 %inc, i32* %i, align 4 + br label %for.cond + +for.end: ; preds = %for.cond + %10 = load i32, i32* %sum, align 4 + ret i32 %10 +} + +define signext i32 @foo(i32 signext %value, i32 signext %ub) #0 !prof !30 { +; CHECK-LABEL: @foo +; CHECK: codeRepl.i: +; CHECK-NOT: call signext i32 @bar +; CHECK: call void @bar.1_if.then +entry: + %value.addr = alloca i32, align 4 + %ub.addr = alloca i32, align 4 + store i32 %value, i32* %value.addr, align 4 + store i32 %ub, i32* %ub.addr, align 4 + %0 = load i32, i32* %value.addr, align 4 + %1 = load i32, i32* %ub.addr, align 4 + %call = call signext i32 @bar(i32 signext %0, i32 signext %1) + ret i32 %call +} + +; CHECK-LABEL: define internal void @bar.1_if.then +; CHECK: .exitStub: +; CHECK: ret void + +!llvm.module.flags = !{!0, !1, !2} +!llvm.ident = !{!29} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 1, !"ProfileSummary", !3} +!3 = !{!4, !5, !6, !7, !8, !9, !10, !11} +!4 = !{!"ProfileFormat", !"InstrProf"} +!5 = !{!"TotalCount", i64 103} +!6 = !{!"MaxCount", i64 100} +!7 = !{!"MaxInternalCount", i64 1} +!8 = !{!"MaxFunctionCount", i64 100} +!9 = !{!"NumCounts", i64 5} +!10 = !{!"NumFunctions", i64 3} +!11 = !{!"DetailedSummary", !12} +!12 = !{!13, !14, !15, !16, !17, !18, !18, !19, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28} +!13 = !{i32 10000, i64 100, i32 1} +!14 = !{i32 100000, i64 100, i32 1} +!15 = !{i32 200000, i64 100, i32 1} +!16 = !{i32 300000, i64 100, i32 1} +!17 = !{i32 400000, i64 100, i32 1} +!18 = !{i32 500000, i64 100, i32 1} +!19 = !{i32 600000, i64 100, i32 1} +!20 = !{i32 700000, i64 100, i32 1} +!21 = !{i32 800000, i64 100, i32 1} +!22 = !{i32 900000, i64 100, i32 1} +!23 = !{i32 950000, i64 100, i32 1} +!24 = !{i32 990000, i64 1, i32 4} +!25 = !{i32 999000, i64 1, i32 4} +!26 = !{i32 999900, i64 1, i32 4} +!27 = !{i32 999990, i64 1, i32 4} +!28 = !{i32 999999, i64 1, i32 4} +!29 = !{!"clang version 6.0.0 (123456)"} +!30 = !{!"function_entry_count", i64 2} +!31 = !{!"branch_weights", i32 100, i32 1} +!32 = !{!"branch_weights", i32 0, i32 100} diff --git a/test/Transforms/CodeExtractor/PartialInlineVarArg.ll b/test/Transforms/CodeExtractor/PartialInlineVarArg.ll new file mode 100644 index 000000000000..415eb9ba1754 --- /dev/null +++ b/test/Transforms/CodeExtractor/PartialInlineVarArg.ll @@ -0,0 +1,83 @@ +; RUN: opt < %s -partial-inliner -S -skip-partial-inlining-cost-analysis | FileCheck %s +; RUN: opt < %s -passes=partial-inliner -S -skip-partial-inlining-cost-analysis | FileCheck %s + +@stat = external global i32, align 4 + +define i32 @vararg(i32 %count, ...) { +entry: + %vargs = alloca i8*, align 8 + %stat1 = load i32, i32* @stat, align 4 + %cmp = icmp slt i32 %stat1, 0 + br i1 %cmp, label %bb2, label %bb1 + +bb1: ; preds = %entry + %vg1 = add nsw i32 %stat1, 1 + store i32 %vg1, i32* @stat, align 4 + %vargs1 = bitcast i8** %vargs to i8* + call void @llvm.va_start(i8* %vargs1) + %va1 = va_arg i8** %vargs, i32 + call void @foo(i32 %count, i32 %va1) #2 + call void @llvm.va_end(i8* %vargs1) + br label %bb2 + +bb2: ; preds = %bb1, %entry + %res = phi i32 [ 1, %bb1 ], [ 0, %entry ] + ret i32 %res +} + +declare void @foo(i32, i32) +declare void @llvm.va_start(i8*) +declare void @llvm.va_end(i8*) + +define i32 @caller1(i32 %arg) { +bb: + %tmp = tail call i32 (i32, ...) @vararg(i32 %arg) + ret i32 %tmp +} +; CHECK-LABEL: @caller1 +; CHECK: codeRepl.i: +; CHECK-NEXT: call void (i32, i8**, i32, ...) @vararg.2_bb1(i32 %stat1.i, i8** %vargs.i, i32 %arg) + +define i32 @caller2(i32 %arg, float %arg2) { +bb: + %tmp = tail call i32 (i32, ...) @vararg(i32 %arg, i32 10, float %arg2) + ret i32 %tmp +} + +; CHECK-LABEL: @caller2 +; CHECK: codeRepl.i: +; CHECK-NEXT: call void (i32, i8**, i32, ...) @vararg.2_bb1(i32 %stat1.i, i8** %vargs.i, i32 %arg, i32 10, float %arg2) + +; Test case to check that we do not extract a vararg function, if va_end is in +; a block that is not outlined. +define i32 @vararg_not_legal(i32 %count, ...) { +entry: + %vargs = alloca i8*, align 8 + %vargs0 = bitcast i8** %vargs to i8* + %stat1 = load i32, i32* @stat, align 4 + %cmp = icmp slt i32 %stat1, 0 + br i1 %cmp, label %bb2, label %bb1 + +bb1: ; preds = %entry + %vg1 = add nsw i32 %stat1, 1 + store i32 %vg1, i32* @stat, align 4 + %vargs1 = bitcast i8** %vargs to i8* + call void @llvm.va_start(i8* %vargs1) + %va1 = va_arg i8** %vargs, i32 + call void @foo(i32 %count, i32 %va1) + br label %bb2 + +bb2: ; preds = %bb1, %entry + %res = phi i32 [ 1, %bb1 ], [ 0, %entry ] + %ptr = phi i8* [ %vargs1, %bb1 ], [ %vargs0, %entry] + call void @llvm.va_end(i8* %ptr) + ret i32 %res +} + +; CHECK-LABEL: @caller3 +; CHECK: tail call i32 (i32, ...) @vararg_not_legal(i32 %arg, i32 %arg) +define i32 @caller3(i32 %arg) { +bb: + %res = tail call i32 (i32, ...) @vararg_not_legal(i32 %arg, i32 %arg) + ret i32 %res +} diff --git a/test/Transforms/CodeExtractor/PartialInlineVarArgsDebug.ll b/test/Transforms/CodeExtractor/PartialInlineVarArgsDebug.ll new file mode 100644 index 000000000000..dc3e77203e0c --- /dev/null +++ b/test/Transforms/CodeExtractor/PartialInlineVarArgsDebug.ll @@ -0,0 +1,67 @@ +; RUN: opt < %s -S -partial-inliner -skip-partial-inlining-cost-analysis=true | FileCheck %s + +; CHECK-LABEL: @callee +; CHECK: %mul = mul nsw i32 %v, 10, !dbg ![[DBG1:[0-9]+]] +define i32 @callee(i32 %v, ...) !dbg !16 { +entry: + %cmp = icmp sgt i32 %v, 2000, !dbg !17 + br i1 %cmp, label %if.then, label %if.end, !dbg !19 + +if.then: ; preds = %entry + %mul = mul nsw i32 %v, 10, !dbg !20 + br label %if.end, !dbg !21 + +if.end: ; preds = %if.then, %entry + %v2 = phi i32 [ %v, %entry ], [ %mul, %if.then ] + %add = add nsw i32 %v2, 200, !dbg !22 + ret i32 %add, !dbg !23 +} + +; CHECK-LABEL: @caller +; CHECK: codeRepl.i: +; CHECK-NEXT: call void (i32, i32*, ...) @callee.1_if.then(i32 %v, i32* %mul.loc.i, i32 99), !dbg ![[DBG2:[0-9]+]] +define i32 @caller(i32 %v) !dbg !8 { +entry: + %call = call i32 (i32, ...) @callee(i32 %v, i32 99), !dbg !14 + ret i32 %call, !dbg !15 +} + +; CHECK-LABEL: define internal void @callee.1_if.then +; CHECK: br label %if.then, !dbg ![[DBG3:[0-9]+]] + +; CHECK: ![[DBG1]] = !DILocation(line: 10, column: 7, +; CHECK: ![[DBG2]] = !DILocation(line: 10, column: 7, +; CHECK: ![[DBG3]] = !DILocation(line: 10, column: 7, + + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5, !6} +!llvm.ident = !{!7} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 (trunk 177881)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) +!1 = !DIFile(filename: "test.c", directory: "/tmp") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{i32 1, !"min_enum_size", i32 4} +!7 = !{!"clang version 6.0.0"} +!8 = distinct !DISubprogram(name: "caller", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !12) +!9 = !DISubroutineType(types: !10) +!10 = !{!11, !11} +!11 = !DIBasicType(name: "int", size: 19, encoding: DW_ATE_signed) +!12 = !{!13} +!13 = !DILocalVariable(name: "v", arg: 1, scope: !8, file: !1, line: 3, type: !11) +!14 = !DILocation(line: 5, column: 10, scope: !8) +!15 = !DILocation(line: 5, column: 3, scope: !8) +!16 = distinct !DISubprogram(name: "callee", scope: !1, file: !1, line: 8, type: !9, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !26) +!26 = !{!27} +!27 = !DILocalVariable(name: "v", arg: 1, scope: !16, file: !1, line: 8, type: !11) +!17 = !DILocation(line: 9, column: 9, scope: !18) +!18 = distinct !DILexicalBlock(scope: !16, file: !1, line: 9, column: 7) +!19 = !DILocation(line: 9, column: 7, scope: !16) +!20 = !DILocation(line: 10, column: 7, scope: !18) +!21 = !DILocation(line: 10, column: 5, scope: !18) +!22 = !DILocation(line: 11, column: 5, scope: !16) +!36 = !DILocation(line: 12, column: 10, scope: !16) +!23 = !DILocation(line: 12, column: 3, scope: !16) diff --git a/test/Transforms/CodeExtractor/live_shrink_hoist.ll b/test/Transforms/CodeExtractor/live_shrink_hoist.ll index d1b310f01769..1f57146c9418 100644 --- a/test/Transforms/CodeExtractor/live_shrink_hoist.ll +++ b/test/Transforms/CodeExtractor/live_shrink_hoist.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -partial-inliner -max-num-inline-blocks=2 -skip-partial-inlining-cost-analysis < %s | FileCheck %s +; RUN: opt -S -partial-inliner -max-num-inline-blocks=3 -skip-partial-inlining-cost-analysis < %s | FileCheck %s ; RUN: opt -S -passes=partial-inliner -max-num-inline-blocks=2 -skip-partial-inlining-cost-analysis < %s | FileCheck %s %class.A = type { i32 } @@ -16,6 +16,10 @@ bb: br i1 %tmp3, label %bb4, label %bb9 bb4: ; preds = %bb + %foo = icmp eq i32 %tmp2, 0 + br i1 %foo, label %bb5, label %bb9 + +bb5: ; preds = %bb4 call void @_ZN1A7memfuncEv(%class.A* nonnull %tmp) %tmp5 = getelementptr inbounds %class.A, %class.A* %tmp, i64 0, i32 0 %tmp6 = load i32, i32* %tmp5, align 4, !tbaa !6 |
