Reduce code duplication a bit. NFC.
Update for llvm api change.