56 lines · plain
1; This tests that LoopStrengthReduce ignores possible optimizations that are2; not realizable because they would require rewriting EHPad-class instructions.3; If this type of optimization is attempted it will hit the4; "Insertion point must be a normal instruction" assertion.5;6; See also https://bugs.llvm.org/show_bug.cgi?id=487087;8; RUN: opt -loop-reduce -S %s9 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 %unwind19 20init2: ; preds = %init121 %i19 = select i1 undef, ptr null, ptr null22 br label %loop23 24loop: ; preds = %loop.increment, %init225 %i21 = phi i64 [ %i24, %loop.increment ], [ 0, %init2 ]26 %i22 = getelementptr %"class.std::allocator", ptr %i19, i64 %i2127 invoke void undef(ptr null, ptr null, ptr %i22)28 to label %loop.increment unwind label %loop.unwind29 30loop.increment: ; preds = %loop31 %i24 = add i64 %i21, 132 br label %loop33 34loop.unwind: ; preds = %loop35 %i26 = catchswitch within none [label %loop.catch] unwind label %unwind36 37loop.catch: ; preds = %loop.unwind38 %i28 = catchpad within %i26 []39 catchret from %i28 to label %caught40 41caught: ; preds = %loop.catch42 invoke void undef(ptr null)43 to label %unreach unwind label %unwind44 45unreach: ; preds = %caught46 unreachable47 48unwind: ; preds = %caught, %loop.unwind, %init149 ; This phi node triggers the issue in combination with the optimizable loop50 ; above. It contains %i19 twice, once from %caught (which doesn't have an51 ; 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 caller55}56