Jlm
EndlessLoopTests.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2021 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
6 #include <gtest/gtest.h>
7 
9 #include <jlm/llvm/ir/print.hpp>
10 
11 #include <llvm/IR/BasicBlock.h>
12 #include <llvm/IR/IRBuilder.h>
13 #include <llvm/IR/Module.h>
14 
15 TEST(EndlessLoopTests, test)
16 {
17  auto setup = [](llvm::LLVMContext & ctx)
18  {
19  using namespace ::llvm;
20 
21  std::unique_ptr<Module> module(new Module("module", ctx));
22 
23  auto int64 = Type::getIntNTy(ctx, 64);
24 
25  auto fcttype = FunctionType::get(int64, {}, false);
26  auto fct = Function::Create(fcttype, GlobalValue::ExternalLinkage, "f", module.get());
27 
28  auto bb1 = BasicBlock::Create(ctx, "", fct);
29  auto bb2 = BasicBlock::Create(ctx, "", fct);
30 
31  IRBuilder<> builder(bb1);
32  builder.CreateBr(bb2);
33  builder.SetInsertPoint(bb2);
34  builder.CreateBr(bb2);
35 
36  return module;
37  };
38 
39  llvm::LLVMContext ctx;
40  auto llvmModule = setup(ctx);
41  llvmModule->print(llvm::errs(), nullptr);
42 
43  auto ipgModule = jlm::llvm::ConvertLlvmModule(*llvmModule);
44  print(*ipgModule, stdout);
45 }
TEST(EndlessLoopTests, test)
void print(const AggregationNode &n, const AnnotationMap &dm, FILE *out)
Definition: print.cpp:120
std::unique_ptr< InterProceduralGraphModule > ConvertLlvmModule(::llvm::Module &llvmModule)