6#include <gtest/gtest.h>
46 <<
"CompareTypes: BitType nbits mismatch: '" <<
type1.debug_string() <<
"' vs '"
47 <<
type2.debug_string() <<
"'";
56 <<
"CompareTypes: StructType element count mismatch: '" <<
type1.debug_string() <<
"' vs '"
57 <<
type2.debug_string() <<
"'";
63 <<
"CompareTypes: StructType packed mismatch: '" <<
type1.debug_string() <<
"' vs '"
64 <<
type2.debug_string() <<
"'";
73 <<
"CompareTypes: ArrayType element count mismatch: '" <<
type1.debug_string() <<
"' vs '"
74 <<
type2.debug_string() <<
"'";
82 <<
"CompareTypes: FunctionType argument count mismatch: '" <<
type1.debug_string()
83 <<
"' vs '" <<
type2.debug_string() <<
"'";
85 <<
"CompareTypes: FunctionType result count mismatch: '" <<
type1.debug_string() <<
"' vs '"
86 <<
type2.debug_string() <<
"'";
87 for (
size_t i = 0;
i <
fnType1->NumArguments(); ++
i)
91 for (
size_t i = 0;
i <
fnType1->NumResults(); ++
i)
100 <<
"' but got '" <<
type2.debug_string() <<
"'";
124 <<
"CompareOperations: Alloca alignment mismatch: '" <<
op1.debug_string() <<
"' vs '"
125 <<
op2.debug_string() <<
"'";
140 <<
"CompareOperations: Free argument count mismatch: '" <<
op1.debug_string() <<
"' vs '"
141 <<
op2.debug_string() <<
"'";
185 <<
"CompareOperations: MemCpyNonVolatile memory state count mismatch: '"
186 <<
op1.debug_string() <<
"' vs '" <<
op2.debug_string() <<
"'";
195 <<
"CompareOperations: MemCpyVolatile memory state count mismatch: '" <<
op1.debug_string()
196 <<
"' vs '" <<
op2.debug_string() <<
"'";
200 FAIL() <<
"CompareOperations: Unknown operation comparison: " <<
op1.debug_string() <<
" vs "
201 <<
op2.debug_string();
217 ASSERT_NE(
lv1.pre,
nullptr) <<
"CompareThetaLoopVars: Theta LoopVar.pre is null in graph 1";
218 ASSERT_NE(
lv2.pre,
nullptr) <<
"CompareThetaLoopVars: Theta LoopVar.pre is null in graph 2";
222 ASSERT_NE(
lv1.post,
nullptr) <<
"CompareThetaLoopVars: Theta LoopVar.post is null in graph 1";
223 ASSERT_NE(
lv2.post,
nullptr) <<
"CompareThetaLoopVars: Theta LoopVar.post is null in graph 2";
227 ASSERT_NE(
lv1.output,
nullptr) <<
"CompareThetaLoopVars: Theta LoopVar.output is null in graph 1";
228 ASSERT_NE(
lv2.output,
nullptr) <<
"CompareThetaLoopVars: Theta LoopVar.output is null in graph 2";
242 <<
"CompareGammaExitVars: Gamma ExitVar branchResult count mismatch";
244 for (
size_t i = 0;
i <
ev1.branchResult.size(); ++
i)
250 ASSERT_NE(
ev1.output,
nullptr) <<
"CompareGammaExitVars: Gamma ExitVar.output is null in graph 1";
251 ASSERT_NE(
ev2.output,
nullptr) <<
"CompareGammaExitVars: Gamma ExitVar.output is null in graph 2";
265 ASSERT_NE(
fv1.recref,
nullptr) <<
"ComparePhiFixVars: Phi FixVar.recref is null in graph 1";
266 ASSERT_NE(
fv2.recref,
nullptr) <<
"ComparePhiFixVars: Phi FixVar.recref is null in graph 2";
272 ASSERT_NE(
fv1.result,
nullptr) <<
"ComparePhiFixVars: Phi FixVar.result is null in graph 1";
273 ASSERT_NE(
fv2.result,
nullptr) <<
"ComparePhiFixVars: Phi FixVar.result is null in graph 2";
277 ASSERT_NE(
fv1.output,
nullptr) <<
"ComparePhiFixVars: Phi FixVar.output is null in graph 1";
278 ASSERT_NE(
fv2.output,
nullptr) <<
"ComparePhiFixVars: Phi FixVar.output is null in graph 2";
294 <<
"CompareNodes: StructuralNode subregion count mismatch";
296 for (
size_t r = 0;
r <
snode1->nsubregions(); ++
r)
302 <<
"CompareNodes: Structural node input count mismatch";
303 for (
size_t i = 0;
i <
snode1->ninputs(); ++
i)
309 <<
"CompareNodes: Structural node output count mismatch";
310 for (
size_t i = 0;
i <
snode1->noutputs(); ++
i)
326 <<
"CompareNodes: Theta node loop variable count mismatch";
348 <<
"CompareNodes: Gamma node exit variable count mismatch";
370 <<
"CompareNodes: Phi node fixpoint variable count mismatch";
390 <<
"CompareNodes: Simple node input count mismatch";
391 for (
size_t i = 0;
i <
simp1->ninputs(); ++
i)
397 <<
"CompareNodes: Simple node output count mismatch";
398 for (
size_t i = 0;
i <
simp1->noutputs(); ++
i)
404 ADD_FAILURE() <<
"CompareNodes: Could not identify node type";
410template<
typename CvList1,
typename CvList2>
415 std::vector<std::pair<const Node *, const Node *>> &
origins)
433 <<
"CollectOriginsFromCvPairs: ContextVar count mismatch";
444static std::vector<std::pair<const Node *, const Node *>>
447 std::vector<std::pair<const Node *, const Node *>>
origins;
479 std::unordered_set<const Node *> & visited,
480 std::queue<std::pair<const Node *, const Node *>> &
nodeQueue)
512 <<
"CompareRegions: Region number of arguments mismatch";
513 for (
size_t i = 0;
i <
region1.narguments(); ++
i)
521 <<
"CompareRegions: Region number of results mismatch";
522 for (
size_t i = 0;
i <
region1.nresults(); ++
i)
529 std::unordered_set<const Node *> visited;
530 std::queue<std::pair<const Node *, const Node *>>
nodeQueue;
533 for (
size_t i = 0;
i <
region1.nresults(); ++
i)
545 ASSERT_NE(
node2,
nullptr) <<
"CompareRegions: Origin1 is a node but Origin2 is not";
548 if (!visited.count(
node1))
550 visited.insert(
node1);
574 for (
size_t j = 0;
j <
node1->ninputs(); ++
j)
584 ASSERT_NE(
next2,
nullptr) <<
"CompareRegions: Input j Origin1 is a node but Origin2 is not";
586 if (!visited.count(
next1))
588 visited.insert(
next1);
626 <<
"CompareModules: Export name mismatch at index " <<
i;
660 std::unique_ptr<mlir::Block>
rootBlock = std::make_unique<mlir::Block>();
666 <<
"TestRvsdgRoundtrip: MLIR-to-JLM conversion produced no module";
683#define ROUNDTRIP_TEST(Name, Fixture) \
684 TEST(RvsdgRoundtripTests, Name) \
687 TestRvsdgRoundtrip(test.module()); \
692#define ROUNDTRIP_TEST_CNE(Name, Fixture) \
693 TEST(RvsdgRoundtripTests, Name) \
696 TestRvsdgRoundtrip(test.module(), true); \
#define ROUNDTRIP_TEST_CNE(Name, Fixture)
#define ROUNDTRIP_TEST(Name, Fixture)
RVSDG module with one of each memory node type.
Common Node Elimination Discovers simple nodes, region arguments and structural node outputs that are...
void Run(rvsdg::RvsdgModule &module, util::StatisticsCollector &statisticsCollector) override
Perform RVSDG transformation.
ConstantPointerNullTest class.
EscapedMemoryTest1 class.
EscapedMemoryTest2 class.
EscapedMemoryTest3 class.
RVSDG module with a static function escaping through another function.
ExternalMemoryTest class.
RVSDG module with a call to free(NULL).
RVSDG module containing a static function that is called with the wrong number of arguments.
RVSDG module with an arbitrary amount of alloca nodes.
FloatConversionTest class.
IntegerConversionTest class.
::mlir::rvsdg::OmegaNode ConvertModule(const llvm::LlvmRvsdgModule &rvsdgModule)
LoadNonVolatileTest class.
MemoryHoistBarrierTest class.
RootRegionNodesTest class.
StoreNonVolatileTest class.
WideMemoryNodesTest class.
Conditional operator / pattern matching.
A phi node represents the fixpoint of mutually recursive definitions.
Represents the argument of a region.
Represent acyclic RVSDG subgraphs.
#define JLM_UNREACHABLE(msg)
Global memory state passed between functions.
static util::StatisticsCollector statisticsCollector
TEST(ControlOperationsTests, foldConstants)
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
A variable routed out of all gamma regions as result.
Description of a recursively defined variable.
Description of a loop-carried variable.