Mercurial > hg > CbC > CbC_llvm
comparison unittests/Transforms/Utils/BasicBlockUtils.cpp @ 134:3a76565eade5 LLVM5.0.1
update 5.0.1
author | mir3636 |
---|---|
date | Sat, 17 Feb 2018 09:57:20 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
133:c60214abe0e8 | 134:3a76565eade5 |
---|---|
1 //===- BasicBlockUtils.cpp - Unit tests for BasicBlockUtils ---------------===// | |
2 // | |
3 // The LLVM Compiler Infrastructure | |
4 // | |
5 // This file is distributed under the University of Illinois Open Source | |
6 // License. See LICENSE.TXT for details. | |
7 // | |
8 //===----------------------------------------------------------------------===// | |
9 | |
10 #include "llvm/Transforms/Utils/BasicBlockUtils.h" | |
11 #include "llvm/AsmParser/Parser.h" | |
12 #include "llvm/IR/BasicBlock.h" | |
13 #include "llvm/IR/Dominators.h" | |
14 #include "llvm/IR/LLVMContext.h" | |
15 #include "llvm/Support/SourceMgr.h" | |
16 #include "gtest/gtest.h" | |
17 | |
18 using namespace llvm; | |
19 | |
20 static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) { | |
21 SMDiagnostic Err; | |
22 std::unique_ptr<Module> Mod = parseAssemblyString(IR, Err, C); | |
23 if (!Mod) | |
24 Err.print("BasicBlockUtilsTests", errs()); | |
25 return Mod; | |
26 } | |
27 | |
28 TEST(BasicBlockUtils, SplitBlockPredecessors) { | |
29 LLVMContext C; | |
30 | |
31 std::unique_ptr<Module> M = parseIR( | |
32 C, | |
33 "define i32 @basic_func(i1 %cond) {\n" | |
34 "entry:\n" | |
35 " br i1 %cond, label %bb0, label %bb1\n" | |
36 "bb0:\n" | |
37 " br label %bb1\n" | |
38 "bb1:\n" | |
39 " %phi = phi i32 [ 0, %entry ], [ 1, %bb0 ]" | |
40 " ret i32 %phi\n" | |
41 "}\n" | |
42 "\n" | |
43 ); | |
44 | |
45 auto *F = M->getFunction("basic_func"); | |
46 DominatorTree DT(*F); | |
47 | |
48 // Make sure the dominator tree is properly updated if calling this on the | |
49 // entry block. | |
50 SplitBlockPredecessors(&F->getEntryBlock(), {}, "split.entry", &DT); | |
51 EXPECT_TRUE(DT.verify()); | |
52 } |