Maybe I should say b2 should be eliminated.<div><br></div><div>Since b1 and b2 are same type and b1 is not used any more after the function call, b2 can be replaced by b1.  This will save an alloca.</div><div><br></div><div>
In my test, if the function is not external, b1 is eliminated.  But with external function, it did not.</div><div><br></div><div>Since the ir is generated, I cannot manually update b2 with b1.  I would like the optim pass do it.</div>
<div><br></div><span></span><div><br>On Wednesday, September 12, 2012, Duncan Sands  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Peng,<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Here is an llvm ir of a module.  It seems that "b1" should be eliminated by dead<br>
store elimination.  But it did not.<br>
<br>
Could anyone explain why and how "b1" can be eliminated?<br>
<br>
Thanks,<br>
-Peng<br>
<br>
%0 = type { [3 x [1 x i32]] }<br>
<br>
declare %0 @external_fcn3(i32, i32, i32, i32, [3 x [1 x i32]]*)<br>
<br>
define i32 @f3(i32 %a) readnone {<br>
entry:<br>
   %b1 = alloca [3 x [1 x i32]]<br>
   %b2 = alloca [3 x [1 x i32]]<br>
   %c = alloca %0<br>
   %0 = getelementptr [3 x [1 x i32]]* %b1, i32 0, i32 0, i32 0<br>
   store i32 0, i32* %0<br>
   %1 = getelementptr [3 x [1 x i32]]* %b1, i32 0, i32 1, i32 0<br>
   store i32 1, i32* %1<br>
   %2 = getelementptr [3 x [1 x i32]]* %b1, i32 0, i32 2, i32 0<br>
   store i32 2, i32* %2<br>
   %3 = call %0 @external_fcn3(i32 100, i32 200, i32 %a, i32 200, [3 x [1 x<br>
i32]]* %b1)<br>
</blockquote>
<br>
here %b1 is passed to external_fcn3, thus %b1 can't be eliminated.<br>
<br>
Ciao, Duncan.<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a>LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</blockquote></div>