HPCC-8361 Improvements to IR generator

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>