[Re: [Regarding Inter Procedural Constant Propagation]]

Hi,
I used the following commands on the program attached below:

llvm-gcc --emit-llvm main.c -c -o main.bc
opt -ipconstprop main.bc -o main1.bc
diff main.bc main1.bc

no difference was o/p :frowning:

The Program Segment is as shown below:
#include <stdio.h>
void f1(int a)
{
   a=a+1;
   printf("%d",a);
}

void f2()
{
        int b;
   b=1;
        f1(b);
}

int main()
{
  int a=1;
   f2();
   f1(a);
}

Also,when i use the following command:
opt -print-after-all main.bc

The dumps generated dont include IPCP or Intraprocedural Const Propagation
dumps.Why so?

Is there any other way to see the effect of a pass on the i/p bitcode file?
Kindly let me know where i am going wrong.

Netra,

Hi Netra,

I used the following commands on the program attached below:

  llvm-gcc --emit-llvm main.c -c -o main.bc
  opt -ipconstprop main.bc -o main1.bc

almost all LLVM optimization passes work poorly if you haven't run the
mem2reg pass first, so try at least
   opt -mem2reg -ipconstprop main.bc -o main1.bc

  Also,when i use the following command:
  opt -print-after-all main.bc

The dumps generated dont include IPCP or Intraprocedural Const Propagation
dumps.Why so?

Because you didn't tell opt to run that pass.

Ciao, Duncan.