[PATCH] D14475: [Sink] Don't move landingpads

Keno Fischer via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 6 19:13:10 PST 2015


loladiro created this revision.
loladiro added a reviewer: majnemer.
loladiro added a subscriber: llvm-commits.
loladiro set the repository for this revision to rL LLVM.

Moving landingpads into successor basic blocks makes the verifier sad. I assume the same is true for cleanuppads. Any other EH related pads that need to be put here? Bugpoint-reduced C++ testcase is included.

Repository:
  rL LLVM

http://reviews.llvm.org/D14475

Files:
  lib/Transforms/Scalar/Sink.cpp
  test/Transforms/Sink/landingpad.ll

Index: test/Transforms/Sink/landingpad.ll
===================================================================
--- /dev/null
+++ test/Transforms/Sink/landingpad.ll
@@ -0,0 +1,39 @@
+; Test that we don't sink landingpads
+; RUN: opt -sink -S < %s | FileCheck %s
+
+define void @_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+  invoke void @_ZNKSt3__19basic_iosIcNS_11char_traitsIcEEE4fillEv()
+          to label %invoke.cont.15 unwind label %lpad.1
+
+invoke.cont.15:                                   ; preds = %entry
+  unreachable
+
+; CHECK: lpad.1:
+; CHECK: %0 = landingpad { i8*, i32 }
+lpad.1:                                           ; preds = %entry
+  %0 = landingpad { i8*, i32 }
+          catch i8* null
+  invoke void @_ZNSt3__18ios_base33__set_badbit_and_consider_rethrowEv()
+          to label %invoke.cont.33 unwind label %lpad.32
+
+; CHECK: invoke.cont.33
+; CHECK-NOT: %0 = landingpad { i8*, i32 }
+invoke.cont.33:                                   ; preds = %lpad.1
+  ret void
+
+lpad.32:                                          ; preds = %lpad.1
+  %1 = landingpad { i8*, i32 }
+          cleanup
+  resume { i8*, i32 } %1
+}
+
+declare i32 @__gxx_personality_v0(...)
+
+; Function Attrs: alwaysinline
+declare hidden void @_ZNKSt3__19basic_iosIcNS_11char_traitsIcEEE4fillEv() #1 align 2
+
+declare void @_ZNSt3__18ios_base33__set_badbit_and_consider_rethrowEv() #0
+
+attributes #0 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="0" "stackrealign" "target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { alwaysinline "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="0" "stackrealign" "target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt" "unsafe-fp-math"="false" "use-soft-float"="false" }
Index: lib/Transforms/Scalar/Sink.cpp
===================================================================
--- lib/Transforms/Scalar/Sink.cpp
+++ lib/Transforms/Scalar/Sink.cpp
@@ -169,7 +169,8 @@
         return false;
   }
 
-  if (isa<TerminatorInst>(Inst) || isa<PHINode>(Inst))
+  if (isa<TerminatorInst>(Inst) || isa<PHINode>(Inst) ||
+      isa<LandingPadInst>(Inst) || isa<CleanupPadInst>(Inst))
     return false;
 
   // Convergent operations cannot be made control-dependent on additional


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14475.39621.patch
Type: text/x-patch
Size: 2897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151107/83c4cc32/attachment.bin>


More information about the llvm-commits mailing list