<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
`SROA' is an early stage pass running at the very beginning of the<br>
pipeline in `-O{1,2,3}'. Greg Bedwell's report from his DExTer tool<br>
shows SROA on function as one of the major culprits of Debug Info<br>
loss.<br>
<br></blockquote><div><br></div><div>The methodology I used is with the opt-bisect-limit option on clang, so it's not strictly the case that the results presented show that the loss in "debugability" occurs during the SROA pass itself directly but rather that the effect of running SROA is some loss in debugability to the final program. I didn't make that point clear enough during my lightning talk session! <br></div><div><br></div><div>Looking at some of the results in more detail, I think the reason that the reason our results differ is because what I'm measuring is not actually variable info loss directly, but as a consequence of the impact on stepping. My standard disclaimer with all results from this tool is that a non-perfect debugging experience score is not necessarily indicative of something wrong, but should be looked at in conjunction with all the other factors such as what the pass is trying to achieve optimization-wise, etc etc. That is to say, it's not necessarily a bug, but it can be (especially when observed as a regression between compiler revisions).</div><div><br></div><div>Using the standard Fibonacci example with clang and lldb from this afternoon:</div><div><br></div><div><div><font face="monospace, monospace"> 1 #ifdef _MSC_VER</font></div><div><font face="monospace, monospace"> 2 # define DEX_NOINLINE __declspec(noinline)</font></div><div><font face="monospace, monospace"> 3 #else</font></div><div><font face="monospace, monospace"> 4 # define DEX_NOINLINE __attribute__((__noinline__))</font></div><div><font face="monospace, monospace"> 5 #endif</font></div><div><font face="monospace, monospace"> 6</font></div><div><font face="monospace, monospace"> 7 DEX_NOINLINE</font></div><div><font face="monospace, monospace"> 8 void Fibonacci(int terms, int& total)</font></div><div><font face="monospace, monospace"> 9 {</font></div><div><font face="monospace, monospace">10 int first = 0;</font></div><div><font face="monospace, monospace">11 int second = 1;</font></div><div><font face="monospace, monospace">12</font></div><div><font face="monospace, monospace">13 for (int i = 0; i < terms; ++i)</font></div><div><font face="monospace, monospace">14 {</font></div><div><font face="monospace, monospace">15 int next = first + second; // DexWatch('i', 'first', 'second', 'total')</font></div><div><font face="monospace, monospace">16 total += first; // DexWatch('i', 'first', 'second', 'total', 'next')</font></div><div><font face="monospace, monospace">17 first = second; // DexWatch('i', 'first', 'second', 'total', 'next')</font></div><div><font face="monospace, monospace">18 second = next; // DexWatch('i', 'first', 'second', 'total', 'next')</font></div><div><font face="monospace, monospace">19 }</font></div><div><font face="monospace, monospace">20 }</font></div><div><font face="monospace, monospace">21</font></div><div><font face="monospace, monospace">22 int main()</font></div><div><font face="monospace, monospace">23 {</font></div><div><font face="monospace, monospace">24 int total = 0;</font></div><div><font face="monospace, monospace">25 Fibonacci(5, total);</font></div><div><font face="monospace, monospace">26 return total;</font></div><div><font face="monospace, monospace">27 }</font></div></div><div><br></div><div>not running "SROA on function (_Z9FibonacciiRi)" the DExTer trace output is:</div><div><br></div><div><div><font face="monospace, monospace">## BEGIN ##</font></div><div><font face="monospace, monospace">[1, "main", "tests/fibonacci/test.cpp", 24, 6, "BREAKPOINT", "FUNC", {}]</font></div><div><font face="monospace, monospace">[2, "main", "tests/fibonacci/test.cpp", 25, 2, "BREAKPOINT", "FORWARD", {}]</font></div><div><font face="monospace, monospace">. [3, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 10, 6, "BREAKPOINT", "FUNC", {}]</font></div><div><font face="monospace, monospace">. [4, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 11, 6, "BREAKPOINT", "FORWARD", {}]</font></div><div><font face="monospace, monospace">. [5, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 11, "BREAKPOINT", "FORWARD", {}]</font></div><div><font face="monospace, monospace">. [6, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 15, 14, "BREAKPOINT", "FORWARD", {"i": "0", "second": "1", "total": "0", "first": "0"}]</font></div><div><font face="monospace, monospace">. [7, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 16, 12, "BREAKPOINT", "FORWARD", {"i": "0", "second": "1", "total": "0", "first": "0", "next": "1"}]</font></div><div><font face="monospace, monospace">. [8, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 17, 11, "BREAKPOINT", "FORWARD", {"i": "0", "second": "1", "total": "0", "first": "0", "next": "1"}]</font></div><div><font face="monospace, monospace">. [9, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 18, 12, "BREAKPOINT", "FORWARD", {"i": "0", "second": "1", "total": "0", "first": "1", "next": "1"}]</font></div><div><font face="monospace, monospace">. [10, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 29, "STEP", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [11, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 15, 14, "BREAKPOINT", "FORWARD", {"i": "1", "second": "1", "total": "0", "first": "1"}]</font></div><div><font face="monospace, monospace">. [12, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 16, 12, "BREAKPOINT", "FORWARD", {"i": "1", "second": "1", "total": "0", "first": "1", "next": "2"}]</font></div><div><font face="monospace, monospace">. [13, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 17, 11, "BREAKPOINT", "FORWARD", {"i": "1", "second": "1", "total": "1", "first": "1", "next": "2"}]</font></div><div><font face="monospace, monospace">. [14, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 18, 12, "BREAKPOINT", "FORWARD", {"i": "1", "second": "1", "total": "1", "first": "1", "next": "2"}]</font></div><div><font face="monospace, monospace">. [15, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 29, "STEP", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [16, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 15, 14, "BREAKPOINT", "FORWARD", {"i": "2", "second": "2", "total": "1", "first": "1"}]</font></div><div><font face="monospace, monospace">. [17, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 16, 12, "BREAKPOINT", "FORWARD", {"i": "2", "second": "2", "total": "1", "first": "1", "next": "3"}]</font></div><div><font face="monospace, monospace">. [18, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 17, 11, "BREAKPOINT", "FORWARD", {"i": "2", "second": "2", "total": "2", "first": "1", "next": "3"}]</font></div><div><font face="monospace, monospace">. [19, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 18, 12, "BREAKPOINT", "FORWARD", {"i": "2", "second": "2", "total": "2", "first": "2", "next": "3"}]</font></div><div><font face="monospace, monospace">. [20, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 29, "STEP", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [21, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 15, 14, "BREAKPOINT", "FORWARD", {"i": "3", "second": "3", "total": "2", "first": "2"}]</font></div><div><font face="monospace, monospace">. [22, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 16, 12, "BREAKPOINT", "FORWARD", {"i": "3", "second": "3", "total": "2", "first": "2", "next": "5"}]</font></div><div><font face="monospace, monospace">. [23, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 17, 11, "BREAKPOINT", "FORWARD", {"i": "3", "second": "3", "total": "4", "first": "2", "next": "5"}]</font></div><div><font face="monospace, monospace">. [24, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 18, 12, "BREAKPOINT", "FORWARD", {"i": "3", "second": "3", "total": "4", "first": "3", "next": "5"}]</font></div><div><font face="monospace, monospace">. [25, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 29, "STEP", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [26, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 15, 14, "BREAKPOINT", "FORWARD", {"i": "4", "second": "5", "total": "4", "first": "3"}]</font></div><div><font face="monospace, monospace">. [27, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 16, 12, "BREAKPOINT", "FORWARD", {"i": "4", "second": "5", "total": "4", "first": "3", "next": "8"}]</font></div><div><font face="monospace, monospace">. [28, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 17, 11, "BREAKPOINT", "FORWARD", {"i": "4", "second": "5", "total": "7", "first": "3", "next": "8"}]</font></div><div><font face="monospace, monospace">. [29, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 18, 12, "BREAKPOINT", "FORWARD", {"i": "4", "second": "5", "total": "7", "first": "5", "next": "8"}]</font></div><div><font face="monospace, monospace">. [30, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 29, "STEP", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [31, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 20, 1, "BREAKPOINT", "FORWARD", {}]</font></div><div><font face="monospace, monospace">[32, "main", "tests/fibonacci/test.cpp", 26, 9, "BREAKPOINT", "FUNC", {}]</font></div><div><font face="monospace, monospace">## END (32 steps) ##</font></div></div><div><br></div><div>So we do a couple of steps in main, before stepping into Fibonacci(int, int&) at step 3. It's fairly easy to see that we iterate the loop 5 times, stepping on lines 13, 15, 16, 17 and 18 in order each time.</div><div><br></div><div>
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">After "SROA on function (_Z9FibonacciiRi)" we now get:</span><br></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><div><font face="monospace, monospace">## BEGIN ##</font></div><div><font face="monospace, monospace">[1, "main", "tests/fibonacci/test.cpp", 24, 6, "BREAKPOINT", "FUNC", {}]</font></div><div><font face="monospace, monospace">[2, "main", "tests/fibonacci/test.cpp", 25, 2, "BREAKPOINT", "FORWARD", {}]</font></div><div><font face="monospace, monospace">. [3, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 20, "BREAKPOINT", "FUNC", {}]</font></div><div><font face="monospace, monospace">. [4, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 15, 20, "BREAKPOINT", "FORWARD", {"i": "0", "second": "1", "total": "0", "first": "0"}]</font></div><div><font face="monospace, monospace">. [5, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 16, 9, "BREAKPOINT", "FORWARD", {"i": "0", "second": "1", "total": "0", "first": "0", "next": "1"}]</font></div><div><font face="monospace, monospace">. [6, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 29, "STEP", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [7, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 20, "BREAKPOINT", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [8, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 15, 20, "BREAKPOINT", "FORWARD", {"i": "1", "second": "1", "total": "0", "first": "1"}]</font></div><div><font face="monospace, monospace">. [9, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 16, 9, "BREAKPOINT", "FORWARD", {"i": "1", "second": "1", "total": "0", "first": "1", "next": "2"}]</font></div><div><font face="monospace, monospace">. [10, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 29, "STEP", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [11, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 20, "BREAKPOINT", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [12, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 15, 20, "BREAKPOINT", "FORWARD", {"i": "2", "second": "2", "total": "1", "first": "1"}]</font></div><div><font face="monospace, monospace">. [13, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 16, 9, "BREAKPOINT", "FORWARD", {"i": "2", "second": "2", "total": "1", "first": "1", "next": "3"}]</font></div><div><font face="monospace, monospace">. [14, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 29, "STEP", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [15, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 20, "BREAKPOINT", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [16, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 15, 20, "BREAKPOINT", "FORWARD", {"i": "3", "second": "3", "total": "2", "first": "2"}]</font></div><div><font face="monospace, monospace">. [17, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 16, 9, "BREAKPOINT", "FORWARD", {"i": "3", "second": "3", "total": "2", "first": "2", "next": "5"}]</font></div><div><font face="monospace, monospace">. [18, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 29, "STEP", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [19, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 20, "BREAKPOINT", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [20, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 15, 20, "BREAKPOINT", "FORWARD", {"i": "4", "second": "5", "total": "4", "first": "3"}]</font></div><div><font face="monospace, monospace">. [21, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 16, 9, "BREAKPOINT", "FORWARD", {"i": "4", "second": "5", "total": "4", "first": "3", "next": "8"}]</font></div><div><font face="monospace, monospace">. [22, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 29, "STEP", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [23, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 13, 20, "BREAKPOINT", "BACKWARD", {}]</font></div><div><font face="monospace, monospace">. [24, "Fibonacci(int, int&)", "tests/fibonacci/test.cpp", 20, 1, "BREAKPOINT", "FORWARD", {}]</font></div><div><font face="monospace, monospace">[25, "main", "tests/fibonacci/test.cpp", 26, 9, "BREAKPOINT", "FUNC", {}]</font></div><div><font face="monospace, monospace">## END (25 steps) ##</font></div><div><br></div><div>So we've now gained some extra steps at line 13, but at different columns (the "++i" and "i < terms" are now treated as separate steps), but we're now also no longer ever stepping onto lines 17 or 18 at all. Whether these are the expected effects of SROA are not something DExTer is in the business of deciding, but it does score it as a difference because it now, at no point, sees the expression "first" evaluate to a value of 5, or "total" to a value of 8 which it did previously. From the source-level debugging experience, the variables now just get updated between iterations.</div><div><br></div><div>So in short, it seems SROA is having some effect on debugging but it seems that it's not in the form of failing to preserve variable info.</div></span></div><div><br></div><div><br></div><div><br></div></div></div></div>