Adding condition block at top of function resulting in losing optimizations like stack optimizations

LLVM: Adding condition block at top of function resulting in loosing optimizations like stack optimizations which are done at entry block

I’m tried to add condition block to all the APIs through compiler function pass.

Due to this, I’m observing stack optimization is getting missed as the initialization code moves out of entry block.

is there way to bring back optimizations done by compiler on entry block on the new block? or can we combine entry and continue block someway??

Please share your thoughts on this?

before adding condition block at top of the function

**entry:**
  initialization call instructions

After adding condition block at top of the function

**entry**:
 %1 = call i32 @func1()
 %2 = icmp ne i32 %1, 0, !dbg
  br i1 %2, label %if.then.block, label continue

**continue:**
 ; initialization call instructions
ret void
**if.then.block**
   ; Insert instructions for the "if.then.block"
ret void