mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 22:30:13 +00:00
[PM] Sink the module parsing from the fixture to the test as subsequent
tests will want different IR. Wanted this when writing tests for the proposed CG update stuff, and this is an easily separable piece. llvm-svn: 273973
This commit is contained in:
parent
7de0cf3cf7
commit
6c138ce31c
@ -208,53 +208,48 @@ struct TestFunctionPass {
|
||||
int &RunCount;
|
||||
};
|
||||
|
||||
std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
|
||||
std::unique_ptr<Module> parseIR(const char *IR) {
|
||||
// We just use a static context here. This is never called from multiple
|
||||
// threads so it is harmless no matter how it is implemented. We just need
|
||||
// the context to outlive the module which it does.
|
||||
static LLVMContext C;
|
||||
SMDiagnostic Err;
|
||||
return parseAssemblyString(IR, Err, C);
|
||||
}
|
||||
|
||||
class CGSCCPassManagerTest : public ::testing::Test {
|
||||
protected:
|
||||
LLVMContext Context;
|
||||
std::unique_ptr<Module> M;
|
||||
|
||||
public:
|
||||
CGSCCPassManagerTest()
|
||||
: M(parseIR(Context, "define void @f() {\n"
|
||||
"entry:\n"
|
||||
" call void @g()\n"
|
||||
" call void @h1()\n"
|
||||
" ret void\n"
|
||||
"}\n"
|
||||
"define void @g() {\n"
|
||||
"entry:\n"
|
||||
" call void @g()\n"
|
||||
" call void @x()\n"
|
||||
" ret void\n"
|
||||
"}\n"
|
||||
"define void @h1() {\n"
|
||||
"entry:\n"
|
||||
" call void @h2()\n"
|
||||
" ret void\n"
|
||||
"}\n"
|
||||
"define void @h2() {\n"
|
||||
"entry:\n"
|
||||
" call void @h3()\n"
|
||||
" call void @x()\n"
|
||||
" ret void\n"
|
||||
"}\n"
|
||||
"define void @h3() {\n"
|
||||
"entry:\n"
|
||||
" call void @h1()\n"
|
||||
" ret void\n"
|
||||
"}\n"
|
||||
"define void @x() {\n"
|
||||
"entry:\n"
|
||||
" ret void\n"
|
||||
"}\n")) {}
|
||||
};
|
||||
|
||||
TEST_F(CGSCCPassManagerTest, Basic) {
|
||||
TEST(CGSCCPassManagerTest, Basic) {
|
||||
auto M = parseIR("define void @f() {\n"
|
||||
"entry:\n"
|
||||
" call void @g()\n"
|
||||
" call void @h1()\n"
|
||||
" ret void\n"
|
||||
"}\n"
|
||||
"define void @g() {\n"
|
||||
"entry:\n"
|
||||
" call void @g()\n"
|
||||
" call void @x()\n"
|
||||
" ret void\n"
|
||||
"}\n"
|
||||
"define void @h1() {\n"
|
||||
"entry:\n"
|
||||
" call void @h2()\n"
|
||||
" ret void\n"
|
||||
"}\n"
|
||||
"define void @h2() {\n"
|
||||
"entry:\n"
|
||||
" call void @h3()\n"
|
||||
" call void @x()\n"
|
||||
" ret void\n"
|
||||
"}\n"
|
||||
"define void @h3() {\n"
|
||||
"entry:\n"
|
||||
" call void @h1()\n"
|
||||
" ret void\n"
|
||||
"}\n"
|
||||
"define void @x() {\n"
|
||||
"entry:\n"
|
||||
" ret void\n"
|
||||
"}\n");
|
||||
FunctionAnalysisManager FAM(/*DebugLogging*/ true);
|
||||
int FunctionAnalysisRuns = 0;
|
||||
FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); });
|
||||
|
Loading…
Reference in New Issue
Block a user