invoke-cleanup.ll 910 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. ; RUN: opt %s -inline -S | FileCheck %s
  2. declare void @external_func()
  3. @exception_type1 = external global i8
  4. @exception_type2 = external global i8
  5. define internal void @inner() personality i8* null {
  6. invoke void @external_func()
  7. to label %cont unwind label %lpad
  8. cont:
  9. ret void
  10. lpad:
  11. %lp = landingpad i32
  12. catch i8* @exception_type1
  13. resume i32 %lp
  14. }
  15. ; Test that the "cleanup" clause is kept when inlining @inner() into
  16. ; this call site (PR17872), otherwise C++ destructors will not be
  17. ; called when they should be.
  18. define void @outer() personality i8* null {
  19. invoke void @inner()
  20. to label %cont unwind label %lpad
  21. cont:
  22. ret void
  23. lpad:
  24. %lp = landingpad i32
  25. cleanup
  26. catch i8* @exception_type2
  27. resume i32 %lp
  28. }
  29. ; CHECK: define void @outer
  30. ; CHECK: landingpad
  31. ; CHECK-NEXT: cleanup
  32. ; CHECK-NEXT: catch i8* @exception_type1
  33. ; CHECK-NEXT: catch i8* @exception_type2