<div dir="ltr">I don't think there's any simple approach to this - there's been some idea that -O1 (or -Og, or that -O1 shuold be -Og) could be made to be this mode, where values are still findable/etc. (though I'm not sure "modifiable" is a goal there - the ability to see the behavior of the program correctly is one thing, but making sure all values are modifiable would be a larger goal and probably really limit the ability to optimize the program)<br><br>- Dave</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Feb 16, 2017 at 7:39 AM Wu Zhao via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial" class="gmail_msg">Hi, I'm curious that whether we can keep debug information of local variable when in the optimization condition (for example -O2, -O3) in LLVM.<br class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg">For example this simple C source code:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">int main()</div><div class="gmail_msg"><div class="gmail_msg">{</div><div class="gmail_msg"> int i = 5;</div><div class="gmail_msg"> if(i > 5) {</div><div class="gmail_msg"> return 1;</div><div class="gmail_msg"> } else {</div><div class="gmail_msg"> return 0;</div><div class="gmail_msg"> }</div><div class="gmail_msg">}</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">If we compile clang -g a.c, we can get our expected result. We can check and update the local variable i in the debugger.<br class="gmail_msg"><br class="gmail_msg">However, when we compile it using clang -O3 -g a.c, we can only check the variable i but we can not update the local variable i.<br class="gmail_msg"><br class="gmail_msg">I know, the design of LLVM opt-debug is that debug can not affect optimization, so this case llvm-opt will turn the llvm.dbg.declare and related alloc / store instruction to llvm.dbg.value, we don't have symbol of local variable i. So we can only check local variable i but we can not update the value of local variable i like set variable i = 7 in the gdb.<br class="gmail_msg"><br class="gmail_msg">I think keep debug information of local variable in some condition is very useful and I want to explore it. However, I find there are many places do this work of local variable debug info. I want to know whether I have one simple way like disabling some passes or modify some llvm code to continue this way.<br class="gmail_msg"><br class="gmail_msg">Thanks in advance. </div></div><br class="gmail_msg"><br class="gmail_msg"><span title="neteasefooter" class="gmail_msg"><p class="gmail_msg"> </p></span>_______________________________________________<br class="gmail_msg">
LLVM Developers mailing list<br class="gmail_msg">
<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="gmail_msg">
</blockquote></div>