[PATCH] D28822: Add a test case for LICM when promoting locals that may be read after the throw within the loop. NFCI.

Xin Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 13:37:48 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL292261: Add a test case for LICM when promoting locals that may be read after the throw… (authored by trentxintong).

Changed prior to commit:
  https://reviews.llvm.org/D28822?vs=84740&id=84741#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28822

Files:
  llvm/trunk/test/Transforms/LICM/scalar-promote-unwind.ll


Index: llvm/trunk/test/Transforms/LICM/scalar-promote-unwind.ll
===================================================================
--- llvm/trunk/test/Transforms/LICM/scalar-promote-unwind.ll
+++ llvm/trunk/test/Transforms/LICM/scalar-promote-unwind.ll
@@ -69,4 +69,82 @@
   ret void
 }
 
+ at _ZTIi = external constant i8*
+
+; In this test, the loop is within a try block. There is an explicit unwind edge out of the loop.
+; Make sure this edge is treated as a loop exit, and that the loads and stores are promoted as
+; expected
+define void @loop_within_tryblock() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+  %a = alloca i32, align 4
+  store i32 0, i32* %a, align 4
+  br label %for.cond
+
+for.cond:
+  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
+  %cmp = icmp slt i32 %i.0, 1024
+  br i1 %cmp, label %for.body, label %for.end
+
+; CHECK: for.body:
+; CHECK-NOT: load
+; CHECK-NOT: store 
+; CHECK: invoke
+for.body:
+  %0 = load i32, i32* %a, align 4
+  %add = add nsw i32 %0, 1
+  store i32 %add, i32* %a, align 4
+  invoke void @boo()
+          to label %invoke.cont unwind label %lpad
+
+invoke.cont:
+  br label %for.inc
+
+for.inc:
+  %inc = add nsw i32 %i.0, 1
+  br label %for.cond
+
+; CHECK: lpad:
+; CHECK: store
+; CHECK: br
+lpad:
+  %1 = landingpad { i8*, i32 }
+          catch i8* bitcast (i8** @_ZTIi to i8*)
+  %2 = extractvalue { i8*, i32 } %1, 0
+  %3 = extractvalue { i8*, i32 } %1, 1
+  br label %catch.dispatch
+
+catch.dispatch:
+  %4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #3
+  %matches = icmp eq i32 %3, %4
+  br i1 %matches, label %catch, label %eh.resume
+
+catch:
+  %5 = call i8* @__cxa_begin_catch(i8* %2) #3
+  %6 = bitcast i8* %5 to i32*
+  %7 = load i32, i32* %6, align 4
+  call void @__cxa_end_catch() #3
+  br label %try.cont
+
+try.cont:
+  ret void
+
+for.end:
+  br label %try.cont
+
+eh.resume:
+  %lpad.val = insertvalue { i8*, i32 } undef, i8* %2, 0
+  %lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %3, 1
+  resume { i8*, i32 } %lpad.val3
+}
+
+declare void @boo()
+
+declare i32 @__gxx_personality_v0(...)
+
+declare i32 @llvm.eh.typeid.for(i8*)
+
+declare i8* @__cxa_begin_catch(i8*)
+
+declare void @__cxa_end_catch()
+
 declare void @f() uwtable


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28822.84741.patch
Type: text/x-patch
Size: 2274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170117/e8f74945/attachment.bin>


More information about the llvm-commits mailing list