Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm] Iterate SmallPtrSet in reverse order to uncover non-determinis…
…m in codegen Summary: Given a flag (-mllvm -reverse-iterate) this patch will enable iteration of SmallPtrSet in reverse order. The idea is to compile the same source with and without this flag and expect the code to not change. If there is a difference in codegen then it would mean that the codegen is sensitive to the iteration order of SmallPtrSet. This is enabled only with LLVM_ENABLE_ABI_BREAKING_CHECKS. Reviewers: chandlerc, dexonsmith, mehdi_amini Subscribers: mgorny, emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D26718 llvm-svn: 289619
- Loading branch information
Mandeep Singh Grang
committed
Dec 14, 2016
1 parent
30e304e
commit f6b069c
Showing
4 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===- llvm/unittest/ADT/ReverseIterationTest.cpp ------------------------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// ReverseIteration unit tests. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "gtest/gtest.h" | ||
#include "llvm/ADT/SmallPtrSet.h" | ||
|
||
#if LLVM_ENABLE_ABI_BREAKING_CHECKS | ||
using namespace llvm; | ||
|
||
TEST(ReverseIterationTest, SmallPtrSetTest) { | ||
|
||
SmallPtrSet<void*, 4> Set; | ||
void *Ptrs[] = { (void*)0x1, (void*)0x2, (void*)0x3, (void*)0x4 }; | ||
void *ReversePtrs[] = { (void*)0x4, (void*)0x3, (void*)0x2, (void*)0x1 }; | ||
|
||
for (auto *Ptr: Ptrs) | ||
Set.insert(Ptr); | ||
|
||
// Check forward iteration. | ||
ReverseIterate<bool>::value = false; | ||
for (const auto &Tuple : zip(Set, Ptrs)) | ||
ASSERT_EQ(std::get<0>(Tuple), std::get<1>(Tuple)); | ||
|
||
// Check reverse iteration. | ||
ReverseIterate<bool>::value = true; | ||
for (const auto &Tuple : zip(Set, ReversePtrs)) | ||
ASSERT_EQ(std::get<0>(Tuple), std::get<1>(Tuple)); | ||
} | ||
#endif |