<table><tr><td style="">This revision was automatically updated to reflect the committed changes.<br />Closed by commit rL282733: [thinlto] Add cold-callsite import heuristic (authored by Prazek).
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://reviews.llvm.org/D24940" rel="noreferrer">View Revision</a></tr></table><br /><div><strong><strong>Changed prior to commit:</strong></strong><div><a href="https://reviews.llvm.org/D24940?vs=72745&id=72969#toc" rel="noreferrer">https://reviews.llvm.org/D24940?vs=72745&id=72969#toc</a></div></div><br /><div><strong><strong>Repository:</strong></strong><div><div>rL LLVM</div></div></div><br /><div><a href="https://reviews.llvm.org/D24940" rel="noreferrer">https://reviews.llvm.org/D24940</a></div><br /><div><strong><strong>Files:</strong></strong><div><div>llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp<br />
llvm/trunk/test/Transforms/FunctionImport/hotness_based_import.ll</div></div></div><br /><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><span style="color: #4b4d51; font-weight: bold;">llvm/trunk/test/Transforms/FunctionImport/hotness_based_import.ll</span></div><div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; ">; Test import with default hot multiplier (3)
</div><div style="padding: 0 8px; margin: 0 4px; ">; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=1 --S | FileCheck %s --check-prefix=CHECK --check-prefix=HOT-DEFAULT
</div><div style="padding: 0 8px; margin: 0 4px; background: #ffd0d0;">; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=1 --S -import-hot-multiplier=3.0 | FileCheck %s --check-prefix=CHECK --check-prefix=HOT-DEFAULT
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=1 --S -import-hot-multiplier=3.0 <span class="bright">-import-cold-multiplier=0.0 </span>| FileCheck %s --check-prefix=CHECK --check-prefix=HOT-DEFAULT
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-DEFAULT-DAG: define available_externally void @hot1()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-DEFAULT-DAG: define available_externally void @hot2()
</div><div style="padding: 0 8px; margin: 0 4px; background: #ffd0d0;">; HOT-DEFAULT-DAG: define available_externally void @cold()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-DEFAULT-DAG: define available_externally void @none1()
</div><div style="padding: 0 8px; margin: 0 4px; ">
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; HOT-DEFAULT-NOT: define available_externally void @cold()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-DEFAULT-NOT: define available_externally void @hot3()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-DEFAULT-NOT: define available_externally void @none2()
</div><div style="padding: 0 8px; margin: 0 4px; background: #F7F7F7; color: #74777D; border-style: dashed; border-color: #C7CCD9; border-width: 1px 0;">...</div><div style="padding: 0 8px; margin: 0 4px; ">; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=1 -import-hot-multiplier=1.0 --S | FileCheck %s --check-prefix=CHECK --check-prefix=HOT-ONE
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-ONE-DAG: define available_externally void @hot1()
</div><div style="padding: 0 8px; margin: 0 4px; background: #ffd0d0;">; HOT-ONE-DAG: define available_externally void @cold()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-ONE-DAG: define available_externally void @none1()
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; HOT-ONE-NOT: define available_externally void @cold()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-ONE-NOT: define available_externally void @hot2()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-ONE-NOT: define available_externally void @hot3()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-ONE-NOT: define available_externally void @none2()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-ONE-NOT: define available_externally void @none3()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-ONE-NOT: define available_externally void @cold2()
</div><div style="padding: 0 8px; margin: 0 4px; ">
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=1 -import-hot-multiplier=1.0 -import-cold-multiplier=1.0 --S | FileCheck %s --check-prefix=CHECK --check-prefix=HOT-COLD-ONE
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; HOT-COLD-ONE-DAG: define available_externally void @hot1()
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; HOT-COLD-ONE-DAG: define available_externally void @cold()
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; HOT-COLD-ONE-DAG: define available_externally void @none1()
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; HOT-COLD-ONE-NOT: define available_externally void @hot2()
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; HOT-COLD-ONE-NOT: define available_externally void @hot3()
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; HOT-COLD-ONE-NOT: define available_externally void @none2()
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; HOT-COLD-ONE-NOT: define available_externally void @none3()
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; HOT-COLD-ONE-NOT: define available_externally void @cold2()
</div><div style="padding: 0 8px; margin: 0 4px; ">
</div><div style="padding: 0 8px; margin: 0 4px; ">; Test import with hot multiplier 0.0 and high threshold - don't import functions called from hot callsite.
</div><div style="padding: 0 8px; margin: 0 4px; background: #ffd0d0;">; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=10 -import-hot-multiplier=0.0 --S | FileCheck %s --check-prefix=CHECK --check-prefix=HOT-ZERO
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=10 -import-hot-multiplier=0.0 -<span class="bright">import-cold-multiplier=1.0 -</span>-S | FileCheck %s --check-prefix=CHECK --check-prefix=HOT-ZERO
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-ZERO-DAG: define available_externally void @cold()
</div><div style="padding: 0 8px; margin: 0 4px; ">; HOT-ZERO-DAG: define available_externally void @none1()
</div></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><span style="color: #4b4d51; font-weight: bold;">llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp</span></div><div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; ">                               "`import-instr-limit` threshold by this factor "
</div><div style="padding: 0 8px; margin: 0 4px; ">                               "before processing newly imported functions"));
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">
</div><div style="padding: 0 8px; margin: 0 4px; ">static cl::opt<float> ImportHotMultiplier(
</div><div style="padding: 0 8px; margin: 0 4px; ">    "import-hot-multiplier", cl::init(3.0), cl::Hidden, cl::value_desc("x"),
</div><div style="padding: 0 8px; margin: 0 4px; background: #ffd0d0;">    cl::<span class="bright">ZeroOrMore, cl::</span>desc("Multiply the `import-instr-limit` threshold for <span class="bright">"</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #ffd0d0;"><span class="bright">                             "hot callsites"));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">    cl::desc("Multiply the `import-instr-limit` threshold for <span class="bright">hot callsites"));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">// FIXME: This multiplier was not really tuned up.
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">static cl::opt<float> ImportColdMultiplier(
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">    "import-cold-multiplier", cl::init(0), cl::Hidden, cl::value_desc("N"),
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">    cl::desc("Multiply the `import-instr-limit` threshold for cold callsites"));
</div><div style="padding: 0 8px; margin: 0 4px; ">
</div><div style="padding: 0 8px; margin: 0 4px; ">static cl::opt<bool> PrintImports("print-imports", cl::init(false), cl::Hidden,
</div><div style="padding: 0 8px; margin: 0 4px; background: #F7F7F7; color: #74777D; border-style: dashed; border-color: #C7CCD9; border-width: 1px 0;">...</div><div style="padding: 0 8px; margin: 0 4px; ">    }
</div><div style="padding: 0 8px; margin: 0 4px; ">
</div><div style="padding: 0 8px; margin: 0 4px; background: #ffd0d0;">    <span class="bright">// FIXME: Also lower the threshold for cold callsites.</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">    <span class="bright">auto GetBonusMultiplier = [](CalleeInfo::HotnessType Hotness) -> float {</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">      if (Hotness == CalleeInfo::HotnessType::Hot)
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">        return ImportHotMultiplier;
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">      if (Hotness == CalleeInfo::HotnessType::Cold)
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">        return ImportColdMultiplier;
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">      return 1.0;
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">    };
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">
</div><div style="padding: 0 8px; margin: 0 4px; ">    const auto NewThreshold =
</div><div style="padding: 0 8px; margin: 0 4px; background: #ffd0d0;">        Edge.second.Hotness<span class="bright"> == CalleeInfo::HotnessType::Hot</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #ffd0d0;">            ? Threshold * ImportHotMultiplier
</div><div style="padding: 0 8px; margin: 0 4px; background: #ffd0d0;">            : Threshold;
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">        <span class="bright">Threshold * GetBonusMultiplier(</span>Edge.second.Hotness<span class="bright">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; ">    auto *CalleeSummary = selectCallee(GUID, NewThreshold, Index);
</div><div style="padding: 0 8px; margin: 0 4px; ">    if (!CalleeSummary) {
</div></div></div></div></div><br />