[LLVMdev] dead store elimination with external functions

Duncan Sands baldrick at free.fr
Wed Sep 12 07:43:48 PDT 2012


Hi Peng,

> Here is an llvm ir of a module.  It seems that "b1" should be eliminated by dead
> store elimination.  But it did not.
>
> Could anyone explain why and how "b1" can be eliminated?
>
> Thanks,
> -Peng
>
> %0 = type { [3 x [1 x i32]] }
>
> declare %0 @external_fcn3(i32, i32, i32, i32, [3 x [1 x i32]]*)
>
> define i32 @f3(i32 %a) readnone {
> entry:
>    %b1 = alloca [3 x [1 x i32]]
>    %b2 = alloca [3 x [1 x i32]]
>    %c = alloca %0
>    %0 = getelementptr [3 x [1 x i32]]* %b1, i32 0, i32 0, i32 0
>    store i32 0, i32* %0
>    %1 = getelementptr [3 x [1 x i32]]* %b1, i32 0, i32 1, i32 0
>    store i32 1, i32* %1
>    %2 = getelementptr [3 x [1 x i32]]* %b1, i32 0, i32 2, i32 0
>    store i32 2, i32* %2
>    %3 = call %0 @external_fcn3(i32 100, i32 200, i32 %a, i32 200, [3 x [1 x
> i32]]* %b1)

here %b1 is passed to external_fcn3, thus %b1 can't be eliminated.

Ciao, Duncan.



More information about the llvm-dev mailing list