diff options
author | aqjune <aqjune@gmail.com> | 2019-11-07 01:17:49 +0900 |
---|---|---|
committer | aqjune <aqjune@gmail.com> | 2019-11-12 10:49:00 +0900 |
commit | e87d71668e10f51abe4b2f1f3c44591aca783750 (patch) | |
tree | c33db0298cc2ef75a9c7fd30bf082f6e150c527a /llvm/unittests/IR/VerifierTest.cpp | |
parent | c46b3a2abd38d6fecd389c97dfa7df54af77fdb9 (diff) | |
download | bcm5719-llvm-e87d71668e10f51abe4b2f1f3c44591aca783750.tar.gz bcm5719-llvm-e87d71668e10f51abe4b2f1f3c44591aca783750.zip |
[IR] Redefine Freeze instruction
Summary:
This patch redefines freeze instruction from being UnaryOperator to a subclass of UnaryInstruction.
ConstantExpr freeze is removed, as discussed in the previous review.
FreezeOperator is not added because there's no ConstantExpr freeze.
`freeze i8* null` test is added to `test/Bindings/llvm-c/freeze.ll` as well, because the null pointer-related bug in `tools/llvm-c/echo.cpp` is now fixed.
InstVisitor has visitFreeze now because freeze is not unaryop anymore.
Reviewers: whitequark, deadalnix, craig.topper, jdoerfert, lebedev.ri
Reviewed By: craig.topper, lebedev.ri
Subscribers: regehr, nlopes, mehdi_amini, hiraditya, steven_wu, dexonsmith, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69932
Diffstat (limited to 'llvm/unittests/IR/VerifierTest.cpp')
-rw-r--r-- | llvm/unittests/IR/VerifierTest.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp index a85f0a25fc8..4747cea037e 100644 --- a/llvm/unittests/IR/VerifierTest.cpp +++ b/llvm/unittests/IR/VerifierTest.cpp @@ -45,6 +45,54 @@ TEST(VerifierTest, Branch_i1) { EXPECT_TRUE(verifyFunction(*F)); } +TEST(VerifierTest, Freeze) { + LLVMContext C; + Module M("M", C); + FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false); + Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", M); + BasicBlock *Entry = BasicBlock::Create(C, "entry", F); + ReturnInst *RI = ReturnInst::Create(C, Entry); + + IntegerType *ITy = IntegerType::get(C, 32); + ConstantInt *CI = ConstantInt::get(ITy, 0); + + // Valid type : freeze(<2 x i32>) + Constant *CV = ConstantVector::getSplat(2, CI); + FreezeInst *FI_vec = new FreezeInst(CV); + FI_vec->insertBefore(RI); + + EXPECT_FALSE(verifyFunction(*F)); + + FI_vec->eraseFromParent(); + + // Valid type : freeze(float) + Constant *CFP = ConstantFP::get(Type::getDoubleTy(C), 0.0); + FreezeInst *FI_dbl = new FreezeInst(CFP); + FI_dbl->insertBefore(RI); + + EXPECT_FALSE(verifyFunction(*F)); + + FI_dbl->eraseFromParent(); + + // Valid type : freeze(i32*) + PointerType *PT = PointerType::get(ITy, 0); + ConstantPointerNull *CPN = ConstantPointerNull::get(PT); + FreezeInst *FI_ptr = new FreezeInst(CPN); + FI_ptr->insertBefore(RI); + + EXPECT_FALSE(verifyFunction(*F)); + + FI_ptr->eraseFromParent(); + + // Valid type : freeze(int) + FreezeInst *FI = new FreezeInst(CI); + FI->insertBefore(RI); + + EXPECT_FALSE(verifyFunction(*F)); + + FI_ptr->eraseFromParent(); +} + TEST(VerifierTest, InvalidRetAttribute) { LLVMContext C; Module M("M", C); |