This sounds very similar to IBBF (Inter-procedural Basic Block Folding) which I recently wrote here: IBBF