1; This tests that LoopStrengthReduce ignores possible optimizations that are 2; not realizable because they would require rewriting EHPad-class instructions. 3; If this type of optimization is attempted it will hit the 4; "Insertion point must be a normal instruction" assertion. 5; 6; See also https://bugs.llvm.org/show_bug.cgi?id=48708 7; 8; RUN: opt -loop-reduce -S %s 9 10target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:6:2:64-S128" 11 12%"class.std::allocator" = type { i8 } 13%"class.absl::Storage" = type {} 14 15define void @0() personality ptr undef { 16init1: 17 %i14 = invoke ptr undef(ptr null, i8 0) 18 to label %init2 unwind label %unwind 19 20init2: ; preds = %init1 21 %i19 = select i1 undef, ptr null, ptr null 22 br label %loop 23 24loop: ; preds = %loop.increment, %init2 25 %i21 = phi i64 [ %i24, %loop.increment ], [ 0, %init2 ] 26 %i22 = getelementptr %"class.std::allocator", ptr %i19, i64 %i21 27 invoke void undef(ptr null, ptr null, ptr %i22) 28 to label %loop.increment unwind label %loop.unwind 29 30loop.increment: ; preds = %loop 31 %i24 = add i64 %i21, 1 32 br label %loop 33 34loop.unwind: ; preds = %loop 35 %i26 = catchswitch within none [label %loop.catch] unwind label %unwind 36 37loop.catch: ; preds = %loop.unwind 38 %i28 = catchpad within %i26 [] 39 catchret from %i28 to label %caught 40 41caught: ; preds = %loop.catch 42 invoke void undef(ptr null) 43 to label %unreach unwind label %unwind 44 45unreach: ; preds = %caught 46 unreachable 47 48unwind: ; preds = %caught, %loop.unwind, %init1 49 ; This phi node triggers the issue in combination with the optimizable loop 50 ; above. It contains %i19 twice, once from %caught (which doesn't have an 51 ; EHPad) and once from %loop.unwind, which does have one. 52 %i32 = phi ptr [ %i19, %loop.unwind ], [ %i19, %caught ], [ null, %init1 ] 53 %i33 = cleanuppad within none [] 54 cleanupret from %i33 unwind to caller 55} 56