1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -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 void @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 internal i16 @f3( 30; CHECK-NEXT: entry: 31; CHECK-NEXT: br label [[LAND_END:%.*]] 32; CHECK: land.end: 33; CHECK-NEXT: ret i16 undef 34; 35entry: 36 switch i16 %p1, label %land.end [ 37 i16 0, label %land.end 38 i16 1, label %lor.rhs 39 ] 40 41lor.rhs: 42 br label %land.end 43 44land.end: 45 ret i16 0 46} 47 48