Question: My pass in LLVM generates an `IR` like this:

```
%5 = icmp eq i32 %4, 0
%7 = or i1 %5, %5
...

```

Since the `or` instruction is actually not needed(dead code), I replaced all occurrences of `%7` with `%5`. Now, the `or` instruction should get deleted. Can I call *Dead Code Elimination* pass of LLVM from my pass, or is there any method to remove that `or` instruction?

Answer: 
A solution that is more aligned with LLVM's design philosophy is, instead of doing the substitution in **your** pass, let [InstCombine](http://llvm.org/docs/Passes.html#instcombine-combine-redundant-instructions) do the job. Then you will not need to worry about running DCE.

For example:

```
>cat foo.ll
define i32 @foo(i32 %a, i32 %b) #0 {
entry:
  %or = or i32 %a, %a
  ret i32 %or
}
> opt -S -instcombine < foo.ll
define i32 @foo(i32 %a, i32 %b) #0 {
entry:
  ret i32 %a
}

```
Why don't you just schedule DCE to run after your pass in the pass manager. Let it do its analysis and decide what it wants to throw away.