efriedma added a comment. In terms of detecting the error, ARMBaseTargetMachine::getSubtargetImpl is probably the right place: that's where we gather the target-cpu and target-features to actually compute the target for a given function. https://reviews.llvm.org/D35569