[llvm] c2ebb32 - [NFC][SimplifyCFG] Add a test showing invoke->call simplification failure

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 8 10:04:41 PDT 2020


Author: Roman Lebedev
Date: 2020-08-08T20:00:28+03:00
New Revision: c2ebb3246551eb144fb4d684bc597c9495c0d0c0

URL: https://github.com/llvm/llvm-project/commit/c2ebb3246551eb144fb4d684bc597c9495c0d0c0
DIFF: https://github.com/llvm/llvm-project/commit/c2ebb3246551eb144fb4d684bc597c9495c0d0c0.diff

LOG: [NFC][SimplifyCFG] Add a test showing invoke->call simplification failure

Added: 
    llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll b/llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll
new file mode 100644
index 000000000000..5be601234d60
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll
@@ -0,0 +1,107 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -simplifycfg -S | FileCheck %s
+
+declare void @llvm.lifetime.start.p0i8(i64, i8*)
+declare void @llvm.lifetime.end.p0i8(i64, i8*)
+
+declare void @escape(i32*)
+
+declare void @throwing_callee_foo()
+declare void @throwing_callee_bar()
+
+declare i32 @__gxx_personality_v0(...)
+
+define void @caller(i1 %c) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+; CHECK-LABEL: @caller(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[I0:%.*]] = alloca i32, align 4
+; CHECK-NEXT:    [[I1:%.*]] = bitcast i32* [[I0]] to i8*
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull [[I1]])
+; CHECK-NEXT:    call void @escape(i32* [[I0]])
+; CHECK-NEXT:    [[I2:%.*]] = alloca i32, align 4
+; CHECK-NEXT:    [[I3:%.*]] = bitcast i32* [[I2]] to i8*
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull [[I3]])
+; CHECK-NEXT:    call void @escape(i32* [[I2]])
+; CHECK-NEXT:    [[I4:%.*]] = alloca i32, align 4
+; CHECK-NEXT:    [[I5:%.*]] = bitcast i32* [[I4]] to i8*
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull [[I5]])
+; CHECK-NEXT:    call void @escape(i32* [[I4]])
+; CHECK-NEXT:    [[I6:%.*]] = alloca i32, align 4
+; CHECK-NEXT:    [[I7:%.*]] = bitcast i32* [[I6]] to i8*
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull [[I7]])
+; CHECK-NEXT:    call void @escape(i32* [[I6]])
+; CHECK-NEXT:    br i1 [[C:%.*]], label [[V0:%.*]], label [[V1:%.*]]
+; CHECK:       v0:
+; CHECK-NEXT:    invoke void @throwing_callee_foo()
+; CHECK-NEXT:    to label [[INVOKE_CONT:%.*]] unwind label [[LPAD_V0:%.*]]
+; CHECK:       v1:
+; CHECK-NEXT:    invoke void @throwing_callee_bar()
+; CHECK-NEXT:    to label [[INVOKE_CONT]] unwind label [[LPAD_V1:%.*]]
+; CHECK:       invoke.cont:
+; CHECK-NEXT:    unreachable
+; CHECK:       lpad.v0:
+; CHECK-NEXT:    [[I8:%.*]] = landingpad { i8*, i32 }
+; CHECK-NEXT:    cleanup
+; CHECK-NEXT:    call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull [[I1]])
+; CHECK-NEXT:    br label [[END:%.*]]
+; CHECK:       lpad.v1:
+; CHECK-NEXT:    [[I9:%.*]] = landingpad { i8*, i32 }
+; CHECK-NEXT:    cleanup
+; CHECK-NEXT:    call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull [[I3]])
+; CHECK-NEXT:    br label [[END]]
+; CHECK:       end:
+; CHECK-NEXT:    [[I10:%.*]] = phi { i8*, i32 } [ [[I8]], [[LPAD_V0]] ], [ [[I9]], [[LPAD_V1]] ]
+; CHECK-NEXT:    [[I11:%.*]] = phi i8* [ [[I5]], [[LPAD_V0]] ], [ [[I7]], [[LPAD_V1]] ]
+; CHECK-NEXT:    call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull [[I11]])
+; CHECK-NEXT:    resume { i8*, i32 } [[I10]]
+;
+entry:
+  %i0 = alloca i32
+  %i1 = bitcast i32* %i0 to i8*
+  call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %i1)
+  call void @escape(i32* %i0)
+
+  %i2 = alloca i32
+  %i3 = bitcast i32* %i2 to i8*
+  call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %i3)
+  call void @escape(i32* %i2)
+
+  %i4 = alloca i32
+  %i5 = bitcast i32* %i4 to i8*
+  call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %i5)
+  call void @escape(i32* %i4)
+
+  %i6 = alloca i32
+  %i7 = bitcast i32* %i6 to i8*
+  call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %i7)
+  call void @escape(i32* %i6)
+
+  br i1 %c, label %v0, label %v1
+
+v0:
+  invoke void @throwing_callee_foo()
+  to label %invoke.cont unwind label %lpad.v0
+
+v1:
+  invoke void @throwing_callee_bar()
+  to label %invoke.cont unwind label %lpad.v1
+
+invoke.cont:
+  unreachable
+
+lpad.v0:
+  %i8 = landingpad { i8*, i32 } cleanup
+  call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %i1)
+  br label %end
+
+lpad.v1:
+  %i9 = landingpad { i8*, i32 } cleanup
+  call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %i3)
+  br label %end
+
+end:
+  %i10 = phi { i8*, i32 } [ %i8, %lpad.v0 ], [ %i9, %lpad.v1 ]
+  %i11 = phi i8* [ %i5, %lpad.v0 ], [ %i7, %lpad.v1 ]
+  call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %i11)
+  resume { i8*, i32 } %i10
+}


        


More information about the llvm-commits mailing list