Hi, all,<div>   We are working on a static analysis phase on LLVM's IR, we want to do a backforward phase through the use-def chain, I knew that LLVM</div><div>had a built-in SSA form which provide the use-def chain for virtual register variables, however, I want to know if you also provide some kinds of use-def chain for memory operations? for example, I have the following source code<br clear="all">
<div><br></div><div>int foo(int *q, int *p) {</div><div>  int x;</div><div>  *p = 1;</div><div>  x = *q;</div><div>  return x;</div><div>}</div><div><br></div><div>the IR after front-end is:</div><div><div><br></div><div>
s1:  store i32* %q, i32** %q_addr</div><div>s2: store i32* %p, i32** %p_addr</div><div><br></div><div>s3:  %1 = load i32** %p_addr, align 8                ; <i32*> [#uses=1]</div><div>s4: store i32 1, i32* %1, align 4</div>
<div><br></div><div>s5:  %2 = load i32** %q_addr, align 8                ; <i32*> [#uses=1]</div><div>s6:  %3 = load i32* %2, align 4                      ; <i32> [#uses=1]</div><div>s7: store i32 %3, i32* %x, align 4</div>
<div><br></div><div>in the source code, I want to find the definition statement of "*q", here since we do not know if p and q are aliased or not, we assume they are may-aliased, So I want to find the statement "*p = 1" as the define statement</div>
<div><br></div><div>in the IR code, s6 is the load instruction for "*p", s4 is the store instruction for "*q", is there existing infrastructure for us to use and find s4 directly?</div><div>I understand that I can traverse back every instruction, and compare the alias result to see if any instruction prior to it is define statement, but I am not sure if there is already better way to do that.</div>
<div><br></div><div>(2) another question</div><div>I am using the gold-plugin to compile large applications, it works very well, then, I want to add a pass into <span class="Apple-style-span" style="font-family: Verdana; font-size: 13px; ">include/llvm/Support/StandardPasses.h:<span class="Apple-style-span" style="font-family: arial; font-size: small; "> createStandardLTOPasses,  Since I want to add a new phase and disable some existing phase, is there any way to pass some flag to do that, now my complication model is:</span></span></div>
<div><span class="Apple-style-span" style="font-family: Verdana; font-size: 13px; "><span class="Apple-style-span" style="font-family: arial; font-size: small; "><div><div>export PREFIX=/home/tianwei/llvm/llvm-gcc-bin/</div>
<div>export CC="$PREFIX/bin/llvm-gcc  -use-gold-plugin"</div><div>export CXX="$PREFIX/bin/llvm-g++ -use-gold-plugin"</div><div>export AR="$PREFIX/bin/ar --plugin /home/tianwei/llvm/llvm-gcc-bin/libexec/gcc/x86_64-unknown-linux-gnu/4.2.1/libLLVMgold.so"</div>
<div>export NM="$PREFIX/bin/nm --plugin /home/tianwei/llvm/llvm-gcc-bin/libexec/gcc/x86_64-unknown-linux-gnu/4.2.1/libLLVMgold.so"</div><div>export RANLIB=/bin/true #ranlib is not needed, and doesn't support .bc files in .a</div>
<div>export CFLAGS="-O2 --emit-llvm"</div><div>export LD_LIBRARY_PATH=/usr/local/lib:/home/tianwei/llvm/llvm-gcc-bin/lib/:$LD_LIBRARY_PATH</div><div>export PATH=/home/tianwei/llvm/llvm-gcc-bin/bin/:/home/tianwei/llvm/bin/bin/:$PATH</div>
<div>alias ar="$PREFIX/bin/ar --plugin /home/tianwei/llvm/llvm-gcc-bin/libexec/gcc/x86_64-unknown-linux-gnu/4.2.1/libLLVMgold.so"</div><div>alias nm="$PREFIX/bin/nm --plugin /home/tianwei/llvm/llvm-gcc-bin/libexec/gcc/x86_64-unknown-linux-gnu/4.2.1/libLLVMgold.so"</div>
<div>alias ranlib=/bin/true</div></div><div><br></div><div>the new ld which enable gold-plugin is installed in the PATH. Using these configuration, I can build apache/httpd successfully with its default make system. The trick here is that add "--emit-llvm" into CFLAGS, the "-c" will only produce llvm bytecode files. Also add "-use-gold-plugin" into CC, this is necessary since the make system usually use llvm-gcc as the link, llvm-gcc will pass "-use-gold-plugin" into final ld. ("-c" with -use-gold-plugin has no bad effect, also ld with --emit-llvm also has no bad effect, so this works).</div>
<div>But I want to how can I pass additional flag into libLTO as opt in this compilation model.</div><div><br></div><div>Thanks very much.</div><div><br></div><div>Tianwei</div><div><br></div></span></span></div></div>-- <br>
Sheng, Tianwei<br>Inst. of High Performance Computing<br>Dept. of Computer Sci. & Tech.<br>Tsinghua Univ.<br>
</div>