[llvm] 5e40f2c - [CodeMoverUtils] clang-format the test
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 26 16:22:18 PST 2019
Author: Vitaly Buka
Date: 2019-11-26T16:22:06-08:00
New Revision: 5e40f2cf0fec7975ef5d4c8f9fd7fce49c754c9c
URL: https://github.com/llvm/llvm-project/commit/5e40f2cf0fec7975ef5d4c8f9fd7fce49c754c9c
DIFF: https://github.com/llvm/llvm-project/commit/5e40f2cf0fec7975ef5d4c8f9fd7fce49c754c9c.diff
LOG: [CodeMoverUtils] clang-format the test
Added:
Modified:
llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp b/llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
index 0bb32a4d9dda..887c9c955821 100644
--- a/llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
+++ b/llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
@@ -65,39 +65,38 @@ TEST(CodeMoverUtils, BasicTest) {
// }
// }
std::unique_ptr<Module> M = parseIR(
- C,
- "define void @foo(i32* noalias %A, i32* noalias %B, i32* noalias %C\n"
- " , i64 %N) {\n"
- "entry:\n"
- " %X = sdiv i64 1, %N\n"
- " call void @safecall()\n"
- " %cmp1 = icmp slt i64 0, %N\n"
- " call void @unsafecall1()\n"
- " call void @unsafecall2()\n"
- " br i1 %cmp1, label %for.body, label %for.end\n"
- "for.body:\n"
- " %i = phi i64 [ 0, %entry ], [ %inc, %for.body ]\n"
- " %arrayidx_A5 = getelementptr inbounds i32, i32* %A, i64 5\n"
- " store i32 5, i32* %arrayidx_A5, align 4\n"
- " %arrayidx_A = getelementptr inbounds i32, i32* %A, i64 %i\n"
- " store i32 0, i32* %arrayidx_A, align 4\n"
- " %load1 = load i32, i32* %arrayidx_A, align 4\n"
- " %arrayidx_B = getelementptr inbounds i32, i32* %B, i64 %i\n"
- " store i32 %load1, i32* %arrayidx_B, align 4\n"
- " %load2 = load i32, i32* %arrayidx_A, align 4\n"
- " %arrayidx_C = getelementptr inbounds i32, i32* %C, i64 %i\n"
- " store i32 %load2, i32* %arrayidx_C, align 4\n"
- " %arrayidx_A6 = getelementptr inbounds i32, i32* %A, i64 6\n"
- " store i32 6, i32* %arrayidx_A6, align 4\n"
- " %inc = add nsw i64 %i, 1\n"
- " %cmp = icmp slt i64 %inc, %N\n"
- " br i1 %cmp, label %for.body, label %for.end\n"
- "for.end:\n"
- " ret void\n"
- "}\n"
- "declare void @safecall() nounwind nosync willreturn\n"
- "declare void @unsafecall1()\n"
- "declare void @unsafecall2()\n");
+ C, "define void @foo(i32* noalias %A, i32* noalias %B, i32* noalias %C\n"
+ " , i64 %N) {\n"
+ "entry:\n"
+ " %X = sdiv i64 1, %N\n"
+ " call void @safecall()\n"
+ " %cmp1 = icmp slt i64 0, %N\n"
+ " call void @unsafecall1()\n"
+ " call void @unsafecall2()\n"
+ " br i1 %cmp1, label %for.body, label %for.end\n"
+ "for.body:\n"
+ " %i = phi i64 [ 0, %entry ], [ %inc, %for.body ]\n"
+ " %arrayidx_A5 = getelementptr inbounds i32, i32* %A, i64 5\n"
+ " store i32 5, i32* %arrayidx_A5, align 4\n"
+ " %arrayidx_A = getelementptr inbounds i32, i32* %A, i64 %i\n"
+ " store i32 0, i32* %arrayidx_A, align 4\n"
+ " %load1 = load i32, i32* %arrayidx_A, align 4\n"
+ " %arrayidx_B = getelementptr inbounds i32, i32* %B, i64 %i\n"
+ " store i32 %load1, i32* %arrayidx_B, align 4\n"
+ " %load2 = load i32, i32* %arrayidx_A, align 4\n"
+ " %arrayidx_C = getelementptr inbounds i32, i32* %C, i64 %i\n"
+ " store i32 %load2, i32* %arrayidx_C, align 4\n"
+ " %arrayidx_A6 = getelementptr inbounds i32, i32* %A, i64 6\n"
+ " store i32 6, i32* %arrayidx_A6, align 4\n"
+ " %inc = add nsw i64 %i, 1\n"
+ " %cmp = icmp slt i64 %inc, %N\n"
+ " br i1 %cmp, label %for.body, label %for.end\n"
+ "for.end:\n"
+ " ret void\n"
+ "}\n"
+ "declare void @safecall() nounwind nosync willreturn\n"
+ "declare void @unsafecall1()\n"
+ "declare void @unsafecall2()\n");
run(*M, "foo",
[&](Function &F, DominatorTree &DT, PostDominatorTree &PDT,
@@ -106,9 +105,11 @@ TEST(CodeMoverUtils, BasicTest) {
BasicBlock *Entry = &*(FI++);
assert(Entry->getName() == "entry" && "Expecting BasicBlock entry");
Instruction *CI_safecall = Entry->front().getNextNode();
- assert(isa<CallInst>(CI_safecall) && "Expecting CI_safecall to be a CallInst");
+ assert(isa<CallInst>(CI_safecall) &&
+ "Expecting CI_safecall to be a CallInst");
Instruction *CI_unsafecall = CI_safecall->getNextNode()->getNextNode();
- assert(isa<CallInst>(CI_unsafecall) && "Expecting CI_unsafecall to be a CallInst");
+ assert(isa<CallInst>(CI_unsafecall) &&
+ "Expecting CI_unsafecall to be a CallInst");
BasicBlock *ForBody = &*(FI++);
assert(ForBody->getName() == "for.body" &&
"Expecting BasicBlock for.body");
@@ -126,39 +127,48 @@ TEST(CodeMoverUtils, BasicTest) {
assert(LI1->getName() == "load1" && "Expecting LI1 to be load1");
Instruction *LI2 = LI1->getNextNode()->getNextNode()->getNextNode();
assert(LI2->getName() == "load2" && "Expecting LI2 to be load2");
- Instruction *SI_A6 = LI2->getNextNode()->getNextNode()->getNextNode()->getNextNode();
+ Instruction *SI_A6 =
+ LI2->getNextNode()->getNextNode()->getNextNode()->getNextNode();
assert(isa<StoreInst>(SI_A6) &&
SI_A6->getOperand(1)->getName() == "arrayidx_A6" &&
"Expecting store to arrayidx_A6");
- // Can move after CI_safecall, as it does not throw, not synchronize, or must return.
- EXPECT_TRUE(isSafeToMoveBefore(*CI_safecall->getPrevNode(), *CI_safecall->getNextNode(), DT, PDT, DI));
+ // Can move after CI_safecall, as it does not throw, not synchronize, or
+ // must return.
+ EXPECT_TRUE(isSafeToMoveBefore(*CI_safecall->getPrevNode(),
+ *CI_safecall->getNextNode(), DT, PDT,
+ DI));
// Cannot move CI_unsafecall, as it may throw.
- EXPECT_FALSE(isSafeToMoveBefore(*CI_unsafecall->getNextNode(), *CI_unsafecall, DT, PDT, DI));
+ EXPECT_FALSE(isSafeToMoveBefore(*CI_unsafecall->getNextNode(),
+ *CI_unsafecall, DT, PDT, DI));
// Moving instruction to non control flow equivalent places are not
// supported.
- EXPECT_FALSE(isSafeToMoveBefore(*SI_A5, *Entry->getTerminator(), DT, PDT, DI));
+ EXPECT_FALSE(
+ isSafeToMoveBefore(*SI_A5, *Entry->getTerminator(), DT, PDT, DI));
// Moving PHINode is not supported.
- EXPECT_FALSE(isSafeToMoveBefore(PN, *PN.getNextNode()->getNextNode(), DT, PDT, DI));
+ EXPECT_FALSE(isSafeToMoveBefore(PN, *PN.getNextNode()->getNextNode(),
+ DT, PDT, DI));
// Cannot move non-PHINode before PHINode.
EXPECT_FALSE(isSafeToMoveBefore(*PN.getNextNode(), PN, DT, PDT, DI));
// Moving Terminator is not supported.
- EXPECT_FALSE(isSafeToMoveBefore(*Entry->getTerminator(), *PN.getNextNode(), DT,
- PDT, DI));
+ EXPECT_FALSE(isSafeToMoveBefore(*Entry->getTerminator(),
+ *PN.getNextNode(), DT, PDT, DI));
// Cannot move %arrayidx_A after SI, as SI is its user.
- EXPECT_FALSE(isSafeToMoveBefore(*SI->getPrevNode(), *SI->getNextNode(), DT, PDT, DI));
+ EXPECT_FALSE(isSafeToMoveBefore(*SI->getPrevNode(), *SI->getNextNode(),
+ DT, PDT, DI));
// Cannot move SI before %arrayidx_A, as %arrayidx_A is its operand.
EXPECT_FALSE(isSafeToMoveBefore(*SI, *SI->getPrevNode(), DT, PDT, DI));
// Cannot move LI2 after SI_A6, as there is a flow dependence.
- EXPECT_FALSE(isSafeToMoveBefore(*LI2, *SI_A6->getNextNode(), DT, PDT, DI));
+ EXPECT_FALSE(
+ isSafeToMoveBefore(*LI2, *SI_A6->getNextNode(), DT, PDT, DI));
// Cannot move SI after LI1, as there is a anti dependence.
EXPECT_FALSE(isSafeToMoveBefore(*SI, *LI1->getNextNode(), DT, PDT, DI));
More information about the llvm-commits
mailing list