llvm-svn: 81293
patch by Richard Osborne, tweaked and extended by your humble servant. llvm-svn: 59464