[PATCH] D92807: [test] Rewrite phi-empty.ll into a unittest
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 10:00:32 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG554e6db18e0f: [test] Rewrite phi-empty.ll into a unittest (authored by aeubanks).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92807/new/
https://reviews.llvm.org/D92807
Files:
llvm/test/Transforms/LoopRotate/phi-empty.ll
llvm/unittests/IR/BasicBlockTest.cpp
Index: llvm/unittests/IR/BasicBlockTest.cpp
===================================================================
--- llvm/unittests/IR/BasicBlockTest.cpp
+++ 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 @@
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 {
Index: llvm/test/Transforms/LoopRotate/phi-empty.ll
===================================================================
--- 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
-}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92807.310256.patch
Type: text/x-patch
Size: 2589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201208/5ac2d846/attachment.bin>
More information about the llvm-commits
mailing list