[llvm] r330320 - [IR/BasicBlockTest] Fix asan failure introduced in rL330316.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 19 05:06:27 PDT 2018
Author: fhahn
Date: Thu Apr 19 05:06:26 2018
New Revision: 330320
URL: http://llvm.org/viewvc/llvm-project?rev=330320&view=rev
Log:
[IR/BasicBlockTest] Fix asan failure introduced in rL330316.
The argument has to be deleted after the module containing the function
gets deleted.
Added:
llvm/trunk/test/Transforms/NewGVN/pr35074.ll
Modified:
llvm/trunk/unittests/IR/BasicBlockTest.cpp
Added: llvm/trunk/test/Transforms/NewGVN/pr35074.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/NewGVN/pr35074.ll?rev=330320&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/NewGVN/pr35074.ll (added)
+++ llvm/trunk/test/Transforms/NewGVN/pr35074.ll Thu Apr 19 05:06:26 2018
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -newgvn -S | FileCheck %s
+
+define void @sort(i64 %.16) {
+; CHECK-LABEL: @sort(
+; CHECK-NEXT: Entry:
+; CHECK-NEXT: [[TMP0:%.*]] = extractvalue { i64, i1 } undef, 0
+; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[TMP0]], 2
+; CHECK-NEXT: br i1 undef, label [[DIVZEROFAIL2_I:%.*]], label [[WHILEBODY_LR_PH:%.*]]
+; CHECK: DivZeroFail2.i:
+; CHECK-NEXT: unreachable
+; CHECK: WhileBody.lr.ph:
+; CHECK-NEXT: [[TMP2:%.*]] = udiv i64 [[DOT16:%.*]], [[TMP1]]
+; CHECK-NEXT: br label [[WHILEBODY:%.*]]
+; CHECK: WhileBody:
+; CHECK-NEXT: [[ITERATOR:%.*]] = phi i64 [ 0, [[WHILEBODY_LR_PH]] ], [ [[TMP6:%.*]], [[BOUNDSCHECKOK276:%.*]] ]
+; CHECK-NEXT: [[TMP3:%.*]] = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 [[ITERATOR]], i64 [[TMP2]])
+; CHECK-NEXT: [[TMP4:%.*]] = extractvalue { i64, i1 } [[TMP3]], 0
+; CHECK-NEXT: [[TMP5:%.*]] = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 [[TMP4]], i64 1)
+; CHECK-NEXT: [[TMP6]] = extractvalue { i64, i1 } [[TMP5]], 0
+; CHECK-NEXT: br i1 false, label [[BOUNDSCHECKFAIL275:%.*]], label [[BOUNDSCHECKOK276]]
+; CHECK: WhileEnd:
+; CHECK-NEXT: ret void
+; CHECK: BoundsCheckFail275:
+; CHECK-NEXT: unreachable
+; CHECK: BoundsCheckOk276:
+; CHECK-NEXT: [[TMP7:%.*]] = icmp ult i64 [[TMP6]], [[DOT16]]
+; CHECK-NEXT: br i1 [[TMP7]], label [[WHILEBODY]], label [[WHILEEND:%.*]]
+;
+Entry:
+ %0 = extractvalue { i64, i1 } undef, 0
+ %1 = lshr i64 %0, 2
+ br i1 undef, label %DivZeroFail2.i, label %WhileBody.lr.ph
+
+DivZeroFail2.i: ; preds = %Entry
+ unreachable
+
+WhileBody.lr.ph: ; preds = %Entry
+ %2 = udiv i64 %.16, %1
+ br label %WhileBody
+
+WhileBody: ; preds = %BoundsCheckOk276, %WhileBody.lr.ph
+ %iterator = phi i64 [ 0, %WhileBody.lr.ph ], [ %6, %BoundsCheckOk276 ]
+ %3 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %iterator, i64 %2)
+ %4 = extractvalue { i64, i1 } %3, 0
+ %5 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %4, i64 1)
+ %6 = extractvalue { i64, i1 } %5, 0
+ %7 = icmp ugt i64 %iterator, %.16
+ br i1 %7, label %BoundsCheckFail275, label %BoundsCheckOk276
+
+WhileEnd: ; preds = %BoundsCheckOk276
+ ret void
+
+BoundsCheckFail275: ; preds = %WhileBody
+ unreachable
+
+BoundsCheckOk276: ; preds = %WhileBody
+ %8 = icmp ult i64 %6, %.16
+ br i1 %8, label %WhileBody, label %WhileEnd
+}
+
+declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64)
Modified: llvm/trunk/unittests/IR/BasicBlockTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/BasicBlockTest.cpp?rev=330320&r1=330319&r2=330320&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/BasicBlockTest.cpp (original)
+++ llvm/trunk/unittests/IR/BasicBlockTest.cpp Thu Apr 19 05:06:26 2018
@@ -83,19 +83,19 @@ TEST(BasicBlockTest, PhiRange) {
for (auto Pair : zip(Range1, Range2)) \
EXPECT_EQ(&std::get<0>(Pair), std::get<1>(Pair));
-TEST(BasicBlockTest, TestSkipInsts) {
+TEST(BasicBlockTest, TestInstructionsWithoutDebug) {
LLVMContext Ctx;
- std::unique_ptr<Module> M(new Module("MyModule", Ctx));
+ Module *M = new Module("MyModule", Ctx);
Type *ArgTy1[] = {Type::getInt32PtrTy(Ctx)};
FunctionType *FT = FunctionType::get(Type::getVoidTy(Ctx), ArgTy1, false);
- auto *V = new Argument(Type::getInt32Ty(Ctx));
- Function *F = Function::Create(FT, Function::ExternalLinkage, "", M.get());
+ Argument *V = new Argument(Type::getInt32Ty(Ctx));
+ Function *F = Function::Create(FT, Function::ExternalLinkage, "", M);
- Value *DbgAddr = Intrinsic::getDeclaration(M.get(), Intrinsic::dbg_addr);
+ Value *DbgAddr = Intrinsic::getDeclaration(M, Intrinsic::dbg_addr);
Value *DbgDeclare =
- Intrinsic::getDeclaration(M.get(), Intrinsic::dbg_declare);
- Value *DbgValue = Intrinsic::getDeclaration(M.get(), Intrinsic::dbg_value);
+ Intrinsic::getDeclaration(M, Intrinsic::dbg_declare);
+ Value *DbgValue = Intrinsic::getDeclaration(M, Intrinsic::dbg_value);
Value *DIV = MetadataAsValue::get(Ctx, (Metadata *)nullptr);
SmallVector<Value *, 3> Args = {DIV, DIV, DIV};
@@ -114,6 +114,9 @@ TEST(BasicBlockTest, TestSkipInsts) {
SmallVector<Instruction *, 4> Exp = {Var, AddInst, MulInst, SubInst};
CHECK_ITERATORS(BB1->instructionsWithoutDebug(), Exp);
CHECK_ITERATORS(BBConst->instructionsWithoutDebug(), Exp);
+
+ delete M;
+ delete V;
}
} // End anonymous namespace.
More information about the llvm-commits
mailing list