fix PR13390: do not loop forever with self-referencing self instructions

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160876 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nuno Lopes 2012-07-27 18:21:15 +00:00
parent 75564e3514
commit e982de7be9
2 changed files with 27 additions and 0 deletions

View File

@ -506,6 +506,10 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitPHINode(PHINode&) {
}
SizeOffsetType ObjectSizeOffsetVisitor::visitSelectInst(SelectInst &I) {
// ignore malformed self-looping selects
if (I.getTrueValue() == &I || I.getFalseValue() == &I)
return unknown();
SizeOffsetType TrueSide = compute(I.getTrueValue());
SizeOffsetType FalseSide = compute(I.getFalseValue());
if (bothKnown(TrueSide) && bothKnown(FalseSide) && TrueSide == FalseSide)
@ -711,6 +715,10 @@ SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitPHINode(PHINode &PHI) {
}
SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitSelectInst(SelectInst &I) {
// ignore malformed self-looping selects
if (I.getTrueValue() == &I || I.getFalseValue() == &I)
return unknown();
SizeOffsetEvalType TrueSide = compute_(I.getTrueValue());
SizeOffsetEvalType FalseSide = compute_(I.getFalseValue());

View File

@ -219,3 +219,22 @@ define i32 @test13(i8** %esc) {
; CHECK: ret i32 8
ret i32 %1
}
; CHECK: @PR13390
define i32 @PR13390(i1 %bool, i8* %a) {
entry:
%cond = or i1 %bool, true
br i1 %cond, label %return, label %xpto
xpto:
%select = select i1 %bool, i8* %select, i8* %a
%select2 = select i1 %bool, i8* %a, i8* %select2
%0 = tail call i32 @llvm.objectsize.i32(i8* %select, i1 true)
%1 = tail call i32 @llvm.objectsize.i32(i8* %select2, i1 true)
%2 = add i32 %0, %1
; CHECK: ret i32 undef
ret i32 %2
return:
ret i32 42
}