<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Some documentation about debugging the swift compiler:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift/blob/master/docs/DebuggingTheCompiler.rst" class="">https://github.com/apple/swift/blob/master/docs/DebuggingTheCompiler.rst</a></div><div class=""><br class=""></div><div class="">Possibly, not all flags are documented:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift/blob/master/lib/SILOptimizer/PassManager/PassManager.cpp" class="">https://github.com/apple/swift/blob/master/lib/SILOptimizer/PassManager/PassManager.cpp</a></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">To your specific question: We run several stages of the PerformanceInliner (<a href="https://github.com/apple/swift/blob/master/lib/SILOptimizer/Transforms/PerformanceInliner.cpp#L866" class="">https://github.com/apple/swift/blob/master/lib/SILOptimizer/Transforms/PerformanceInliner.cpp#L866</a>) during our PassPipeline (<a href="https://github.com/apple/swift/blob/master/lib/SILOptimizer/PassManager/PassPipeline.cpp#L221" class="">https://github.com/apple/swift/blob/master/lib/SILOptimizer/PassManager/PassPipeline.cpp#L221</a>) . One stage — “the high-level stage” — inlines everything up to “@_semantics” functions. The next stage also inlines those.</div><div class=""><br class=""></div><div class="">- Run PerformanceInliner without-semantic-inlining (<a href="https://github.com/apple/swift/blob/master/lib/SILOptimizer/PassManager/PassPipeline.cpp#L445" class="">https://github.com/apple/swift/blob/master/lib/SILOptimizer/PassManager/PassPipeline.cpp#L445</a>)</div><div class="">- Run Optimizations that rely on seeing @semantics calls</div><div class="">- &nbsp;…</div><div class="">- Run PerformanceInline with-semantic-inlining (<a href="https://github.com/apple/swift/blob/master/lib/SILOptimizer/PassManager/PassPipeline.cpp#L449" class="">https://github.com/apple/swift/blob/master/lib/SILOptimizer/PassManager/PassPipeline.cpp#L449</a>)</div><div class="">- …</div><div class=""><br class=""></div><div class="">If you mark a function like append with @_semantics which internally has calls to @_semantics functions you prevent the optimizations that rely on having those calls exposed/inlined from working since those calls are now hidden behind an @_semantics function that did not get inlined.</div><div class=""><br class=""></div><div class="">The file <a href="https://github.com/apple/swift/blob/master/lib/SILOptimizer/PassManager/PassPipeline.cpp" class="">https://github.com/apple/swift/blob/master/lib/SILOptimizer/PassManager/PassPipeline.cpp</a>&nbsp;contains the code that sets up the pass pipeline. You can see which optimizations are scheduled in which order.</div><div class=""><br class=""></div><div class="">If you want to see a list of passes being run dynamically "-Xllvm -sil-print-pass-name" would be the flag to add, I think.</div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Mar 3, 2017, at 9:58 AM, Ben Ng via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">

<title class=""></title>

<div class="">
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">I noticed that adding <i class="">any</i> semantic attribute to the two Array.append functions causes performance regressions in the Array benchmark. I think that it’s because the delayed inlining is blocking some array optimizations from happening.
<div class=""><br class=""></div>
<div class="">What are some tips for debugging this sort of issue? There are a whole bunch of passes, and it’s difficult to figure out how they all interact. Reading the SIL generated after all optimizations have been run is pretty tedious, and I’m hoping that there’s a smarter way to go about this</div></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div class=""><div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class=""><div class="">.</div>
<div class=""><br class=""></div>
<div class="">Can I get debug output that tells me what optimizations happened, and then diff the two outputs to find out what changed?</div></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div class=""><div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">
<div class=""><br class=""></div>
<div class="">I also see a “Pass Pipeline” utility that looks useful, but it’s not obvious to me how to use it.</div></div></div></div></blockquote></div><br class=""></body></html>