[llvm-branch-commits] [llvm] 554e6db - [test] Rewrite phi-empty.ll into a unittest
Arthur Eubanks via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Dec 8 10:04:28 PST 2020
Author: Arthur Eubanks
Date: 2020-12-08T09:59:31-08:00
New Revision: 554e6db18e0f264481bdab20dca9cc772d90270e
URL: https://github.com/llvm/llvm-project/commit/554e6db18e0f264481bdab20dca9cc772d90270e
DIFF: https://github.com/llvm/llvm-project/commit/554e6db18e0f264481bdab20dca9cc772d90270e.diff
LOG: [test] Rewrite phi-empty.ll into a unittest
phi-empty.ll does not pass under the new PM because the NPM runs
-loop-simplify. Running -loop-simplify ends up not reproing
https://llvm.org/PR48296.
Verified that this test fails when 9eb2c011 is reverted.
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D92807
Added:
Modified:
llvm/unittests/IR/BasicBlockTest.cpp
Removed:
llvm/test/Transforms/LoopRotate/phi-empty.ll
################################################################################
diff --git a/llvm/test/Transforms/LoopRotate/phi-empty.ll b/llvm/test/Transforms/LoopRotate/phi-empty.ll
deleted file mode 100644
index 9337133f8903..000000000000
--- a/llvm/test/Transforms/LoopRotate/phi-empty.ll
+++ /dev/null
@@ -1,39 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -lcssa -loop-rotate < %s | FileCheck %s
-
-; After rotate, the phi has no operands because it has no predecessors.
-; We might want to delete that instruction instead, but we do not
-; fail/assert by assuming that the phi is invalid IR.
-
-define void @PR48296(i1 %cond) {
-; CHECK-LABEL: @PR48296(
-; CHECK-NEXT: entry:
-; CHECK-NEXT: br label [[LOOP:%.*]]
-; CHECK: loop:
-; CHECK-NEXT: br i1 [[COND:%.*]], label [[INC:%.*]], label [[LOOP_BACKEDGE:%.*]]
-; CHECK: loop.backedge:
-; CHECK-NEXT: br label [[LOOP]]
-; CHECK: dead:
-; CHECK-NEXT: unreachable
-; CHECK: inc:
-; CHECK-NEXT: br label [[LOOP_BACKEDGE]]
-; CHECK: return:
-; CHECK-NEXT: [[R:%.*]] = phi i32
-; CHECK-NEXT: ret void
-;
-entry:
- br label %loop
-
-loop:
- br i1 %cond, label %inc, label %loop
-
-dead: ; No predecessors!
- br i1 %cond, label %inc, label %return
-
-inc:
- br label %loop
-
-return:
- %r = phi i32 [ undef, %dead ]
- ret void
-}
diff --git a/llvm/unittests/IR/BasicBlockTest.cpp b/llvm/unittests/IR/BasicBlockTest.cpp
index fcdc9c2c07fb..fa923c90c729 100644
--- a/llvm/unittests/IR/BasicBlockTest.cpp
+++ b/llvm/unittests/IR/BasicBlockTest.cpp
@@ -11,9 +11,11 @@
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/NoFolder.h"
+#include "llvm/IR/Verifier.h"
#include "llvm/Support/SourceMgr.h"
#include "gmock/gmock-matchers.h"
#include "gtest/gtest.h"
@@ -165,6 +167,23 @@ TEST(BasicBlockTest, ComesBefore) {
EXPECT_FALSE(Ret->comesBefore(Ret));
}
+TEST(BasicBlockTest, EmptyPhi) {
+ LLVMContext Ctx;
+
+ Module *M = new Module("MyModule", Ctx);
+ FunctionType *FT = FunctionType::get(Type::getVoidTy(Ctx), {}, false);
+ Function *F = Function::Create(FT, Function::ExternalLinkage, "", M);
+
+ BasicBlock *BB1 = BasicBlock::Create(Ctx, "", F);
+ ReturnInst::Create(Ctx, BB1);
+
+ Type *Ty = Type::getInt32PtrTy(Ctx);
+ BasicBlock *BB2 = BasicBlock::Create(Ctx, "", F);
+ PHINode::Create(Ty, 0, "", BB2);
+ ReturnInst::Create(Ctx, BB2);
+ EXPECT_FALSE(verifyModule(*M, &errs()));
+}
+
class InstrOrderInvalidationTest : public ::testing::Test {
protected:
void SetUp() override {
More information about the llvm-branch-commits
mailing list