Jlm
Functions
InvariantValueRedirectionTests.cpp File Reference
#include <gtest/gtest.h>
#include <jlm/llvm/ir/LambdaMemoryState.hpp>
#include <jlm/llvm/ir/operators/alloca.hpp>
#include <jlm/llvm/ir/operators/call.hpp>
#include <jlm/llvm/ir/operators/IntegerOperations.hpp>
#include <jlm/llvm/ir/operators/Load.hpp>
#include <jlm/llvm/ir/operators/MemoryStateOperations.hpp>
#include <jlm/llvm/ir/operators/Store.hpp>
#include <jlm/llvm/ir/RvsdgModule.hpp>
#include <jlm/llvm/opt/alias-analyses/PointsToGraph.hpp>
#include <jlm/llvm/opt/InvariantValueRedirection.hpp>
#include <jlm/llvm/TestRvsdgs.hpp>
#include <jlm/rvsdg/control.hpp>
#include <jlm/rvsdg/gamma.hpp>
#include <jlm/rvsdg/TestOperations.hpp>
#include <jlm/rvsdg/TestType.hpp>
#include <jlm/rvsdg/theta.hpp>
#include <jlm/rvsdg/view.hpp>
#include <jlm/util/Statistics.hpp>
Include dependency graph for InvariantValueRedirectionTests.cpp:

Go to the source code of this file.

Functions

static void RunInvariantValueRedirection (jlm::llvm::LlvmRvsdgModule &rvsdgModule)
 
 TEST (InvariantValueRedirectionTests, TestGamma)
 
 TEST (InvariantValueRedirectionTests, TestTheta)
 
 TEST (InvariantValueRedirectionTests, TestCall)
 
 TEST (InvariantValueRedirectionTests, TestCallWithMemoryStateNodes)
 
 TEST (InvariantValueRedirectionTests, TestCallWithMissingMemoryStateNodes)
 
 TEST (InvariantValueRedirectionTests, TestCallWithDifferentExternalCompression)
 
 TEST (InvariantValueRedirectionTests, TestLambdaCallArgumentMismatch)
 
 TEST (InvariantValueRedirectionTests, testThetaGammaRedirection)
 
 TEST (InvariantValueRedirectionTests, testLoadWithDeadLoadedValue)
 

Function Documentation

◆ RunInvariantValueRedirection()

static void RunInvariantValueRedirection ( jlm::llvm::LlvmRvsdgModule rvsdgModule)
static

Definition at line 28 of file InvariantValueRedirectionTests.cpp.

◆ TEST() [1/9]

TEST ( InvariantValueRedirectionTests  ,
TestCall   
)

Definition at line 139 of file InvariantValueRedirectionTests.cpp.

◆ TEST() [2/9]

TEST ( InvariantValueRedirectionTests  ,
TestCallWithDifferentExternalCompression   
)

This test creates a situation where a caller and callee have compressed some memory nodes into the memory state belonging to the external memory. The caller has compressed memory node 3 into external, while the callees have compressed 2 into external.

// callee0 does something to mem0 callee0 = lambda [io, mem] { mem0, mem1, mem3 = LambdaEntrySplit{0, 1, 3} mem mem00 = TestOperation mem0 memMerged = LambdaExitMerge{0, 1, 3} mem00, mem1, mem3 } [io, memMerged]

// callee3 does something to mem3 callee3 = lambda [io, mem] { mem0, mem1, mem3 = LambdaEntrySplit{0, 1, 3} mem mem03 = TestOperation mem3 memMerged = LambdaExitMerge{0, 1, 3} mem0, mem1, mem03 } [io, memMerged]

caller = lambda [io, mem] { mem0, mem1, mem2 = LambdaEntrySplit{0, 1, 2} mem

// calling callee0 callMergedA = CallEntryMerge{0, 1, 2} mem0, mem1, mem2 io, returnMemA = call callee0 io callMergedA mem00, mem01, mem02 = CallExitSplit{0, 1, 2} returnMemA

// calling callee3 callMergedB = CallEntryMerge{0, 1, 2} mem00, mem01, mem02 io, returnMemB = call callee3 io callMergedB mem10, mem11, mem12 = CallExitSplit{0, 1, 2} returnMemB

memMerged = LambdaExitMerge{0, 1, 2} mem10, mem11, mem12 } [io, memMerged]

After InvariantValueRedirection, memory node 1 should be routed around both calls. Memory node 2 should only be routed around the call to callee3. Memory node 0 should not be routed around anything.

Definition at line 493 of file InvariantValueRedirectionTests.cpp.

◆ TEST() [3/9]

TEST ( InvariantValueRedirectionTests  ,
TestCallWithMemoryStateNodes   
)

Creates an RVSDG that looks like

test1 = lambda [c:CTRL(2), x:ValueType, io, mem] { mem1, mem2 = LambdaEntrySplit{1, 2} mem // A gamma that routes the values through in both regions x2, mem3, mem4 = gamma c x mem1, mem2 [_, x, mem1, mem2] { }[x, mem1, mem2] [_, x, mem1, mem2] { }[x, mem1, mem2] memMerged = LambdaExitMerge{1, 2} mem3, mem4 } [x2, io, memMerged]

test2 = lambda [test1 <- test1, x:ValueType, io, mem] { mem1, mem2 = LambdaEntrySplit{1, 2} mem callMerged = CallEntryMerge{1, 2} mem1, mem2 c = CTRL(0) x2, io, returnMem = call test1 c x io callMerged mem3, mem4 = CallExitSplit{2, 1} returnMem memMerged = LambdaExitMerge{2, 1} mem3, mem4 } [x2, io, memMerged]

After InvariantValueRedirection, the LambdaExitMerge in test2 should be directly connected to the LambdaEntrySplit in test2, with the correct memory node indices matching up.

The test uses memory node indices 1 and 2, since 0 is reserved for the external node.

Definition at line 226 of file InvariantValueRedirectionTests.cpp.

◆ TEST() [4/9]

TEST ( InvariantValueRedirectionTests  ,
TestCallWithMissingMemoryStateNodes   
)

Definition at line 372 of file InvariantValueRedirectionTests.cpp.

◆ TEST() [5/9]

TEST ( InvariantValueRedirectionTests  ,
TestGamma   
)

Definition at line 40 of file InvariantValueRedirectionTests.cpp.

◆ TEST() [6/9]

TEST ( InvariantValueRedirectionTests  ,
TestLambdaCallArgumentMismatch   
)

Definition at line 683 of file InvariantValueRedirectionTests.cpp.

◆ TEST() [7/9]

TEST ( InvariantValueRedirectionTests  ,
testLoadWithDeadLoadedValue   
)

Definition at line 781 of file InvariantValueRedirectionTests.cpp.

◆ TEST() [8/9]

TEST ( InvariantValueRedirectionTests  ,
TestTheta   
)

Definition at line 88 of file InvariantValueRedirectionTests.cpp.

◆ TEST() [9/9]

TEST ( InvariantValueRedirectionTests  ,
testThetaGammaRedirection   
)

Definition at line 702 of file InvariantValueRedirectionTests.cpp.