[llvm] r202106 - [SROA] Add a debugging tool which shuffles the slices sequence prior to

Adrian Prantl aprantl at apple.com
Mon Mar 3 19:08:03 PST 2014

On Mar 3, 2014, at 19:03, Chandler Carruth <chandlerc at gmail.com> wrote:

> On Mon, Mar 3, 2014 at 6:11 PM, Adrian Prantl <aprantl at apple.com> wrote:
> I see. Shouldn’t it be a call to std::stable_sort(), then?
> Well, the whole point is that it *isn't* a call to stable_sort because the order of equal ranges shouldn't matter.
> In practice, we have messed up and made the order matter in several significant cases.
> Right now, the order only matters in that it impacts the name de-duplication and the order of use-def chains created by SROA (much like serializing and deserializing through bitcode does), but I used this to debug a bunch of other more serious issues.
> Even in a no-asserts build, the resulting binary isn't perfectly stable because we have some passes that are sensitive to incoming use-def ordering sadly. =/

I was thinking about something akin to this (possibly less ugly ;-):

#if __cplusplus >= 201103L && !defined(NDEBUG)
  if (SROARandomShuffleSlices) {
    std::mt19937 MT(static_cast<unsigned>(sys::TimeValue::now().msec()));
    std::shuffle(Slices.begin(), Slices.end(), MT);
    std::stable_sort(Slices.begin(), Slices.end());
  } else
  // Sort the uses. This arranges for the offsets to be in ascending order,
  // and the sizes to be in descending order.
  std::sort(Slices.begin(), Slices.end());

-- adrian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140303/0df48234/attachment.html>

More information about the llvm-commits mailing list