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.
6 ; See also https://bugs.llvm.org/show_bug.cgi?id=48708
8 ; RUN: opt -loop-reduce -S %s
10 target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:6:2:64-S128"
12 %"class.std::allocator" = type { i8 }
13 %"class.absl::Storage" = type {}
15 define void @0() personality ptr undef {
17 %i14 = invoke ptr undef(ptr null, i8 0)
18 to label %init2 unwind label %unwind
20 init2: ; preds = %init1
21 %i19 = select i1 undef, ptr null, ptr null
24 loop: ; 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
30 loop.increment: ; preds = %loop
31 %i24 = add i64 %i21, 1
34 loop.unwind: ; preds = %loop
35 %i26 = catchswitch within none [label %loop.catch] unwind label %unwind
37 loop.catch: ; preds = %loop.unwind
38 %i28 = catchpad within %i26 []
39 catchret from %i28 to label %caught
41 caught: ; preds = %loop.catch
42 invoke void undef(ptr null)
43 to label %unreach unwind label %unwind
45 unreach: ; preds = %caught
48 unwind: ; 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