[PATCH] D20638: [LIR] Fix mis-compilation with unwinding

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 14:28:46 PDT 2016


majnemer added inline comments.

================
Comment at: test/Transforms/LoopIdiom/unwind.ll:4-50
@@ +3,49 @@
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at _ZTIi = external constant i8*
+ at ff = global void ()* @f, align 8
+ at gg = global void (i8*, i32)* @g, align 8
+
+define void @f() {
+entry:
+  %exception = tail call i8* @__cxa_allocate_exception(i64 4) #5
+  %0 = bitcast i8* %exception to i32*
+  store i32 1, i32* %0, align 16
+  tail call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
+  unreachable
+}
+
+declare i8* @__cxa_allocate_exception(i64)
+
+declare void @__cxa_throw(i8*, i8*, i8*)
+
+define void @g(i8* noalias nocapture %base, i32 %size) {
+entry:
+  %cmp4 = icmp eq i32 %size, 0
+  br i1 %cmp4, label %for.cond.cleanup, label %for.body.preheader
+
+for.body.preheader:                               ; preds = %entry
+  br label %for.body
+
+for.cond.cleanup.loopexit:                        ; preds = %for.body
+  br label %for.cond.cleanup
+
+for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry
+  ret void
+
+for.body:                                         ; preds = %for.body.preheader, %for.body
+  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
+  %0 = load void ()*, void ()** @ff, align 8
+  tail call void %0()
+  %arrayidx = getelementptr inbounds i8, i8* %base, i64 %indvars.iv
+  store i8 0, i8* %arrayidx, align 1
+  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
+  %exitcond = icmp eq i32 %lftr.wideiv, %size
+  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body
+; CHECK-LABEL: @g(
+; CHECK-NOT: llvm.memset
+}
+
----------------
haicheng wrote:
> majnemer wrote:
> > There is no need to provide the definition of `f`. You could use my reduced testcase, I'm pretty sure it is minimal.
> Targets like AArch64 do not generate attribute uwtable so that I include the definition of f.
Er, this testcase has an explicit triple.  What does AArch64 have to do with anything?


Repository:
  rL LLVM

http://reviews.llvm.org/D20638





More information about the llvm-commits mailing list