<div dir="ltr">yep, certainly. <div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 23, 2017 at 7:29 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Maybe use the DebugCounter mechanism Danny added? (see e.g. r295594 and <a href="http://llvm.org/docs/ProgrammersManual.html#adding-debug-counters-to-aid-in-debugging-your-code" target="_blank">http://llvm.org/docs/<wbr>ProgrammersManual.html#adding-<wbr>debug-counters-to-aid-in-<wbr>debugging-your-code</a> ).<div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 23, 2017 at 4:39 PM, Xinliang David Li via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: davidxl<br>
Date: Sun Apr 23 18:39:04 2017<br>
New Revision: 301148<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=301148&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=301148&view=rev</a><br>
Log:<br>
[PartialInine]: add triaging options<br>
<br>
There are more bugs (runtime failures) triggered when partial<br>
inlining is turned on. Add options to help triaging problems.<br>
<br>
Added:<br>
    llvm/trunk/test/Transforms/Cod<wbr>eExtractor/PartialInlineOptRem<wbr>ark.ll<br>
Modified:<br>
    llvm/trunk/lib/Transforms/IPO/<wbr>PartialInlining.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/<wbr>PartialInlining.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp?rev=301148&r1=301147&r2=301148&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Transform<wbr>s/IPO/PartialInlining.cpp?rev=<wbr>301148&r1=301147&r2=301148&vie<wbr>w=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/IPO/<wbr>PartialInlining.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/<wbr>PartialInlining.cpp Sun Apr 23 18:39:04 2017<br>
@@ -33,6 +33,17 @@ using namespace llvm;<br>
<br>
 STATISTIC(NumPartialInlined, "Number of functions partially inlined");<br>
<br>
+// Command line option to disable partial-inlining. The default is false:<br>
+static cl::opt<bool><br>
+    DisablePartialInlining("disabl<wbr>e-partial-inlining", cl::init(false),<br>
+                           cl::Hidden, cl::desc("Disable partial ininling"));<br>
+<br>
+// Command line option to set the maximum number of partial inlining allowed<br>
+// for the module. The default value of -1 means no limit.<br>
+static cl::opt<int> MaxNumPartialInlining(<br>
+    "max-partial-inlining", cl::init(-1), cl::Hidden, cl::ZeroOrMore,<br>
+    cl::desc("Max number of partial inlining. The default is unlimited"));<br>
+<br>
 namespace {<br>
 struct PartialInlinerImpl {<br>
   PartialInlinerImpl(InlineFunc<wbr>tionInfo IFI) : IFI(std::move(IFI)) {}<br>
@@ -41,6 +52,12 @@ struct PartialInlinerImpl {<br>
<br>
 private:<br>
   InlineFunctionInfo IFI;<br>
+  int NumPartialInlining = 0;<br>
+<br>
+  bool IsLimitReached() {<br>
+    return (MaxNumPartialInlining != -1 &&<br>
+            NumPartialInlining >= MaxNumPartialInlining);<br>
+  }<br>
 };<br>
 struct PartialInlinerLegacyPass : public ModulePass {<br>
   static char ID; // Pass identification, replacement for typeid<br>
@@ -164,6 +181,10 @@ Function *PartialInlinerImpl::unswitchF<wbr>u<br>
     else<br>
       llvm_unreachable("All uses must be calls");<br>
<br>
+    if (IsLimitReached())<br>
+      continue;<br>
+    NumPartialInlining++;<br>
+<br>
     OptimizationRemarkEmitter ORE(CS.getCaller());<br>
     DebugLoc DLoc = CS.getInstruction()->getDebugL<wbr>oc();<br>
     BasicBlock *Block = CS.getParent();<br>
@@ -185,6 +206,9 @@ Function *PartialInlinerImpl::unswitchF<wbr>u<br>
 }<br>
<br>
 bool PartialInlinerImpl::run(Module &M) {<br>
+  if (DisablePartialInlining)<br>
+    return false;<br>
+<br>
   std::vector<Function *> Worklist;<br>
   Worklist.reserve(M.size());<br>
   for (Function &F : M)<br>
<br>
Added: llvm/trunk/test/Transforms/Cod<wbr>eExtractor/PartialInlineOptRem<wbr>ark.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CodeExtractor/PartialInlineOptRemark.ll?rev=301148&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/test/Transfor<wbr>ms/CodeExtractor/PartialInline<wbr>OptRemark.ll?rev=301148&view=<wbr>auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/Transforms/Cod<wbr>eExtractor/PartialInlineOptRem<wbr>ark.ll (added)<br>
+++ llvm/trunk/test/Transforms/Cod<wbr>eExtractor/PartialInlineOptRem<wbr>ark.ll Sun Apr 23 18:39:04 2017<br>
@@ -0,0 +1,73 @@<br>
+; RUN: opt -S -partial-inliner -pass-remarks=partial-<wbr>inlining  -disable-output < %s 2>&1 | FileCheck %s<br>
+; RUN: opt -S -passes=partial-inliner  -pass-remarks=partial-inlining -disable-output < %s 2>&1 | FileCheck %s<br>
+; RUN: opt -S -partial-inliner -pass-remarks=partial-<wbr>inlining  -disable-output -max-partial-inlining=1 < %s 2>&1 | FileCheck %s<br>
+; RUN: opt -S -passes=partial-inliner  -pass-remarks=partial-inlining -disable-output -max-partial-inlining=1 < %s 2>&1 | FileCheck %s<br>
+<br>
+; RUN: opt -S -partial-inliner -pass-remarks=partial-<wbr>inlining  -disable-partial-inlining < %s 2>&1 | FileCheck --check-prefix=LIMIT %s<br>
+; RUN: opt -S -passes=partial-inliner  -pass-remarks=partial-<wbr>inlining  --disable-partial-inlining < %s 2>&1 | FileCheck  --check-prefix=LIMIT %s<br>
+; RUN: opt -S -partial-inliner -pass-remarks=partial-<wbr>inlining   -max-partial-inlining=0 < %s 2>&1 | FileCheck --check-prefix=LIMIT  %s<br>
+; RUN: opt -S -passes=partial-inliner  -pass-remarks=partial-<wbr>inlining  -max-partial-inlining=0 < %s 2>&1 | FileCheck --check-prefix=LIMIT  %s<br>
+<br>
+define i32 @bar(i32 %arg) local_unnamed_addr #0 !dbg !5 {<br>
+bb:<br>
+  %tmp = icmp slt i32 %arg, 0, !dbg !7<br>
+  br i1 %tmp, label %bb1, label %bb2, !dbg !8<br>
+<br>
+bb1:                                              ; preds = %bb<br>
+  tail call void (...) @foo() #0, !dbg !9<br>
+  tail call void (...) @foo() #0, !dbg !10<br>
+  tail call void (...) @foo() #0, !dbg !11<br>
+  tail call void (...) @foo() #0, !dbg !12<br>
+  tail call void (...) @foo() #0, !dbg !13<br>
+  tail call void (...) @foo() #0, !dbg !14<br>
+  tail call void (...) @foo() #0, !dbg !15<br>
+  tail call void (...) @foo() #0, !dbg !16<br>
+  tail call void (...) @foo() #0, !dbg !17<br>
+  br label %bb2, !dbg !18<br>
+<br>
+bb2:                                              ; preds = %bb1, %bb<br>
+  %tmp3 = phi i32 [ 0, %bb1 ], [ 1, %bb ]<br>
+  ret i32 %tmp3, !dbg !19<br>
+}<br>
+<br>
+; Function Attrs: nounwind<br>
+declare void @foo(...) local_unnamed_addr #0<br>
+<br>
+; Function Attrs: nounwind<br>
+define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 !dbg !20 {<br>
+bb:<br>
+; CHECK:remark{{.*}}bar partially inlined into dummy_caller<br>
+; LIMIT-NOT:remark{{.*}}bar partially inlined into dummy_caller<br>
+  %tmp = tail call i32 @bar(i32 %arg), !dbg !21<br>
+  ret i32 %tmp, !dbg !22<br>
+}<br>
+<br>
+attributes #0 = { nounwind }<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!llvm.module.flags = !{!3}<br>
+!llvm.ident = !{!4}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)<br>
+!1 = !DIFile(filename: "t.c", directory: "/tmp")<br>
+!2 = !{}<br>
+!3 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!4 = !{!"clang "}<br>
+!5 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !6, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)<br>
+!6 = !DISubroutineType(types: !2)<br>
+!7 = !DILocation(line: 4, column: 14, scope: !5)<br>
+!8 = !DILocation(line: 4, column: 6, scope: !5)<br>
+!9 = !DILocation(line: 5, column: 5, scope: !5)<br>
+!10 = !DILocation(line: 6, column: 5, scope: !5)<br>
+!11 = !DILocation(line: 7, column: 5, scope: !5)<br>
+!12 = !DILocation(line: 8, column: 5, scope: !5)<br>
+!13 = !DILocation(line: 9, column: 5, scope: !5)<br>
+!14 = !DILocation(line: 10, column: 5, scope: !5)<br>
+!15 = !DILocation(line: 11, column: 5, scope: !5)<br>
+!16 = !DILocation(line: 12, column: 5, scope: !5)<br>
+!17 = !DILocation(line: 13, column: 5, scope: !5)<br>
+!18 = !DILocation(line: 14, column: 5, scope: !5)<br>
+!19 = !DILocation(line: 17, column: 1, scope: !5)<br>
+!20 = distinct !DISubprogram(name: "dummy_caller", scope: !1, file: !1, line: 19, type: !6, isLocal: false, isDefinition: true, scopeLine: 19, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)<br>
+!21 = !DILocation(line: 21, column: 11, scope: !20)<br>
+!22 = !DILocation(line: 21, column: 4, scope: !20)<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</blockquote></div><br></div>