1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[IR/BasicBlockTest] Fix asan failure introduced in rL330316.

The argument has to be deleted after the module containing the function
gets deleted.

llvm-svn: 330320
This commit is contained in:
Florian Hahn 2018-04-19 12:06:26 +00:00
parent d277495bcf
commit 396677905f
2 changed files with 72 additions and 7 deletions

View File

@ -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)

View File

@ -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.