[PATCH] D11710: [SimplifyCFG] Ignore lifetime intrinsics when looking for empty landing pads

Björn Steinbrink bsteinbr at gmail.com
Sun Aug 2 05:56:34 PDT 2015


dotdash created this revision.
dotdash added a reviewer: reames.
dotdash added a subscriber: llvm-commits.

http://reviews.llvm.org/D11710

Files:
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/Transforms/SimplifyCFG/empty-cleanup.ll

Index: test/Transforms/SimplifyCFG/empty-cleanup.ll
===================================================================
--- /dev/null
+++ test/Transforms/SimplifyCFG/empty-cleanup.ll
@@ -0,0 +1,23 @@
+; RUN: opt -simplifycfg -S  < %s | FileCheck %s
+
+declare i32 @__gxx_personality_v0(...)
+declare void @callee()
+
+declare void @llvm.lifetime.start(i64, i8* nocapture)
+declare void @llvm.lifetime.end(i64, i8* nocapture)
+
+define void @test() personality i32 (...)* @__gxx_personality_v0 {
+  %a = alloca i8
+;CHECK: call void @callee
+  invoke void @callee()
+    to label %normal unwind label %unwind
+
+normal:
+  ret void
+
+unwind:
+  %exn = landingpad {i8*, i32} catch i8* null
+  call void @llvm.lifetime.start(i64 1, i8* %a)
+  call void @llvm.lifetime.end(i64 1, i8* %a)
+  resume { i8*, i32 } %exn
+}
Index: lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2910,11 +2910,17 @@
     // caused control to branch here.
     return false;
 
-  // Check that there are no other instructions except for debug intrinsics.
+  // Check that there are no other instructions except for debug and lifetime
+  // intrinsics.
   BasicBlock::iterator I = LPInst, E = RI;
   while (++I != E)
-    if (!isa<DbgInfoIntrinsic>(I))
+    if (!isa<DbgInfoIntrinsic>(I)) {
+      if (auto *II = dyn_cast<IntrinsicInst>(I))
+        if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
+            II->getIntrinsicID() == Intrinsic::lifetime_end)
+          continue;
       return false;
+    }
 
   // Turn all invokes that unwind here into calls and delete the basic block.
   for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE;) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11710.31204.patch
Type: text/x-patch
Size: 1790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150802/90f323fa/attachment.bin>


More information about the llvm-commits mailing list