In short, this patch forces MIs with multiple MMOs to be treated as referencing global objects, which forces the MI to add dependencies on all memory references.
I ran into a correctness issue when working on D16369. Specifically, when I began adding multiple MMOs to the unscaled paired instructions I was seeing a case where loads and store to the stack were being incorrectly reordered. The reason was that without D16369 the ldp/stp instructions were treated as referencing global objects due to the conservative assumption of the call to hasOrderedMemoryRef(). However, once the MMOs were added the call to MI->hasOrderedMemoryRef() began returning false (because no MMOs is bad, but multiple MMOs is fine). Unfortunately, the MI scheduler doesn't deal with multiple MMOs well, so I'm forcing the most conservative scheduling for these instructions.
I collected some statistics on AArch64 at -O3 running Spec2006. When building the scheduling graph I collected the total number of loads, stores and global refs.
Without the fix the stats for Spec2006 are:
190680 misched - Global MIs. 880865 misched - Load MIs. 384858 misched - Store MIs.
With this fix the stats for Spec2006 are:
196546 misched - Global MIs. 5866 misched - Global MIs with multiple MMOs. 877209 misched - Load MIs. 382648 misched - Store MIs.
This results in the total number of global refs increasing by 3.08% and the number of loads and stores decreasing by .42% and .57%, respectively. Therefore, I don't believe this conservative approach will cause any serious regressions considering the small fraction of instructions with multiple MMOs.
Please take a look.
Chad