[PATCH] D26718: [llvm] Iterate SmallPtrSet in reverse order to uncover non-determinism in codegen

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 11:50:22 PST 2016


On Mon, Nov 28, 2016 at 11:47 AM Mehdi Amini <mehdi.amini at apple.com> wrote:

> On Nov 28, 2016, at 11:40 AM, Chandler Carruth <chandlerc at gmail.com>
> wrote:
>
> Hash functions of *pointers* cannot be consistent in the face of ASLR.
>
>
> I was answering the fact that “it cannot be tested”. So I meant, for the
> purpose of writing a unittest that checks if you can pass a flag that
> reverse the iteration order, I don’t expect that you need *valid* pointers.
>
> What I had in mind is something along these lines (I haven’t looked at the
> patch either):
>
> SmallPtrSet<void *, 4> Set;
> void *Ptrs[] = { (void *)0x1, (void *)0x2, (void *)0x3,(void *)0x4 };
> void *ExpectedExperimentalOrder[] = { (void *)0x4, (void *)0x2, (void
> *)0x3,(void *)0x1 };
>
> for (auto *Ptr : Ptrs)
>   Set.insert(Ptr);
>
> for (auto &Tuple : zip(Set, ExpectedExperimentalOrder))
>   ASSERT_EQ(std::get<0>(Tuple), std::get<1>(Tuple));
>
> Set.setReverseIterationOrder();
>
> for (auto &Tuple : zip(Set, reverse_order(ExpectedExperimentalOrder)))
>   ASSERT_EQ(std::get<0>(Tuple), std::get<1>(Tuple));
>

I see. Sorry for introducing noise. I don't feel strongly either way, happy
to let you and Dave sort this out.

-Chandler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161128/4c1bf601/attachment.html>


More information about the llvm-commits mailing list