Fix PR45442: Bail out when MemorySSA information is not available

This commit is contained in:
Aditya Kumar 2020-08-13 00:06:22 -07:00
parent d54f5979bb
commit 44716856db
2 changed files with 36 additions and 0 deletions

View File

@ -521,6 +521,10 @@ private:
if (NewPt == OldPt)
return true;
// MemoryUseDef information is not available, bail out.
if (!U)
return false;
const BasicBlock *NewBB = NewPt->getParent();
const BasicBlock *OldBB = OldPt->getParent();
const BasicBlock *UBB = U->getBlock();

View File

@ -0,0 +1,32 @@
; RUN: opt < %s -gvn-hoist -S | FileCheck %s
; gvn-hoist shouldn't crash in this case.
; CHECK-LABEL: @func()
; CHECK: entry:
; CHECK-NEXT: br i1
; CHECK: bb1:
; CHECK-NEXT: unreachable
; CHECK: bb2:
; CHECK-NEXT: call
; CHECK-NEXT: call
; CHECK-NEXT: unreachable
define void @v_1_0() #0 {
entry:
ret void
}
define void @func() {
entry:
br i1 undef, label %bb1, label %bb2
bb1:
unreachable
bb2:
call void @v_1_0()
call void @v_1_0()
unreachable
}
attributes #0 = { nounwind readonly }