Assertion `castIsValid(getOpcode(), S, Ty) && "Illegal BitCast"' faile

ok.. you are right. I had not inserted the AllocaInst in the function. Thanks a lot for solving my problem yet again :slight_smile: