I've landed a reduced and regrouped version of the patch as r209889 -- so it's easier to work on further stuff. Please tell me if you think I should improve anything in particular and strongly feel we need to do that for test flags. http://reviews.llvm.org/D3952