Jlm
Functions
InliningTests.cpp File Reference
#include <gtest/gtest.h>
#include <jlm/llvm/ir/operators/alloca.hpp>
#include <jlm/llvm/ir/operators/call.hpp>
#include <jlm/llvm/ir/operators/FunctionPointer.hpp>
#include <jlm/llvm/ir/operators/IntegerOperations.hpp>
#include <jlm/llvm/ir/operators/lambda.hpp>
#include <jlm/llvm/ir/operators/Store.hpp>
#include <jlm/llvm/ir/RvsdgModule.hpp>
#include <jlm/llvm/opt/inlining.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 InliningTests.cpp:

Go to the source code of this file.

Functions

static std::unique_ptr< jlm::util::StatisticsrunInlining (jlm::llvm::LlvmRvsdgModule &rm)
 
 TEST (FunctionInliningTests, testSimpleInlining)
 
 TEST (FunctionInliningTests, testInliningWithAlloca)
 
 TEST (FunctionInliningTests, testIndirectCall)
 
 TEST (FunctionInliningTests, testFunctionWithDisqualifyingAlloca)
 

Function Documentation

◆ runInlining()

static std::unique_ptr<jlm::util::Statistics> runInlining ( jlm::llvm::LlvmRvsdgModule rm)
static

Runs the inlining pass on the given module, and returns the pass statistics

Parameters
rmthe RVSDG module
Returns
the statistics instance produced by the inlining pass

Definition at line 31 of file InliningTests.cpp.

◆ TEST() [1/4]

TEST ( FunctionInliningTests  ,
testFunctionWithDisqualifyingAlloca   
)

Creates an RVSDG graph with a single function f1. The function contains an alloca inside a theta, which disqualifies it from being inlined

Definition at line 398 of file InliningTests.cpp.

◆ TEST() [2/4]

TEST ( FunctionInliningTests  ,
testIndirectCall   
)

Creates an RVSDG graph with two functions. f1() is a simple no-op function f2() calls f1(), but via an indirect call

Definition at line 314 of file InliningTests.cpp.

◆ TEST() [3/4]

TEST ( FunctionInliningTests  ,
testInliningWithAlloca   
)

Creates an RVSDG that looks like:

import i : ValueType lambda f1(val, io, mem) -> (io, mem) context: i body: count = I32(1) ptr, aMem = AllocaOperation(count) mem2 = Store(ptr, val, mem) return (io, mem2)

lambda f2(ctrl, val, io, m) -> (io, mem) context: f1 body: gamma(ctrl) context: f1, val, io, mem branch 0: (io0, m0) = call f1(val, io, mem)

branch 1: // nop

exits vars: io_out = (io0, io) m_out = (mem0, mem)

return (io_out, m_out)

export: f2

After inlining, the call in f2 should be removed, and be replaced by the store. The inlined alloca should however be hoisted to the root region of f2

Definition at line 179 of file InliningTests.cpp.

◆ TEST() [4/4]

TEST ( FunctionInliningTests  ,
testSimpleInlining   
)

Creates an RVSDG that looks like:

import i : ValueType lambda f1(val, io, mem) -> (ValueType, io, mem) context: i body: t = TestOperation(val) return (t, io, mem)

lambda f2(ctrl, val, io, m) -> (ValueType, io, mem) context: f1 body: gamma(ctrl) context: f1, val, io, mem branch 0: (val0, io0, m0) = call f1(val, io, mem)

branch 1: // nop

exits vars: v_out = (val0, val) io_out = (io0, io) m_out = (mem0, mem)

return (v_out, io_out, m_out)

export: f2

After inlining, the call in f2 should be removed, and be replaced by a TestOperation

Definition at line 42 of file InliningTests.cpp.