refactor generalised LLVM related code