<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Oct 6, 2013 at 10:03 PM, John Criswell <span dir="ltr"><<a href="mailto:criswell@illinois.edu" target="_blank">criswell@illinois.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div class="im">
<div>On 10/6/13 7:23 AM, Rekha R wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>Hello,<br>
<br>
</div>
I am a beginner in LLVM development with the aim of
writing a new optimization pass. But then before I could
do that, I thought of writing simple passes. I could
successfully implement the Hello pass as given in the
doc. Then I wrote a simple Constant Folding pass -
evaluate instructions of the form c=10+20 and replace
all uses of c with 30. Only later did I realize that
Clang does this optimization while building the IR.
Hence I couldn't check whether my constant folding pass
is "working". I have two questions:<br>
<br>
</div>
1. Is there a way to disable constant folding during IR
development by clang?<br>
</div>
</div>
</div>
</div>
</blockquote>
<br></div>
There are probably multiple ways to do this. One quick way would be
to try different optimization levels (-O1 or -O3, for example).
Another way would be to generate an LLVM assembly file (-S
-emit-llvm) and to assemble that using llvm-as.<div class="im"><br></div></div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div class="im">
</div><div class="im">Yes. I tried both ways. It didn't work. The IR generated by clang has constant expressions folded. Seems clang does this opt during IR generations. Couldn't get the motivation why.<br></div>
<div class="im">
<br>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>2. If not, can someone suggest a simple optimization
(simple in complexity on the lines of constant folding) to
get started?<br>
</div>
</div>
</div>
</blockquote>
<br></div>
Constant propagation is one good candidate, as is dead code
elimination, sparse conditional constant propagation, aggressive
dead code elimination, strength reduction, etc.<br>
<br>
Instrumentation passes can also be good for practice. For example,
instrumenting every load or store with a call to a run-time function
to print the accessed address is pretty simple.<br>
<br></div></blockquote><div>Thanks.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
-- John T.<br>
<br>
</div>
</blockquote></div><br><br clear="all"><br>-- <br>Rekha
</div></div>