1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature 2; RUN: opt < %s -passes=ipsccp -S | FileCheck %s 3 4; This test case used to end up like this: 5; 6; While deleting: label %lor.rhs 7; Use still stuck around after Def is destroyed: br i1 undef, label %lor.rhs, label %land.end 8; opt: ../lib/IR/Value.cpp: llvm::Value::~Value(): Assertion `use_empty() && "Uses remain when a value is destroyed!"' failed. 9; 10; due to ConstantFoldTerminator rewriting the switch into 11; 12; br i1 undef, label %lor.rhs, label %land.end 13; 14; while SCCP implementation relied on the terminator to always be folded into 15; an unconditional branch when ConstantFoldTerminator returned true. 16 17define void @f4() { 18; CHECK-LABEL: define {{[^@]+}}@f4() { 19; CHECK-NEXT: entry: 20; CHECK-NEXT: [[CALL:%.*]] = call i16 @f3(i16 undef) 21; CHECK-NEXT: ret void 22; 23entry: 24 %call = call i16 @f3(i16 undef) 25 ret void 26} 27 28define internal i16 @f3(i16 %p1) { 29; CHECK-LABEL: define {{[^@]+}}@f3 30; CHECK-SAME: (i16 [[P1:%.*]]) { 31; CHECK-NEXT: entry: 32; CHECK-NEXT: unreachable 33; 34entry: 35 switch i16 %p1, label %land.end [ 36 i16 0, label %land.end 37 i16 1, label %lor.rhs 38 ] 39 40lor.rhs: 41 br label %land.end 42 43land.end: 44 ret i16 0 45} 46 47