Inliner: Don't mark swifterror allocas with lifetime markers
authorArnold Schwaighofer <aschwaighofer@apple.com>
Fri, 9 Sep 2016 22:40:27 +0000 (22:40 +0000)
committerArnold Schwaighofer <aschwaighofer@apple.com>
Fri, 9 Sep 2016 22:40:27 +0000 (22:40 +0000)
This would create a bitcast use which fails the verifier: swifterror values may
only be used by loads, stores, and as function arguments.

rdar://28233244

llvm-svn: 281114

llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/Transforms/Inline/lifetime.ll

index e001f6d..383010f 100644 (file)
@@ -1789,6 +1789,9 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
     IRBuilder<> builder(&FirstNewBlock->front());
     for (unsigned ai = 0, ae = IFI.StaticAllocas.size(); ai != ae; ++ai) {
       AllocaInst *AI = IFI.StaticAllocas[ai];
+      // Don't mark swifterror allocas. They can't have bitcast uses.
+      if (AI->isSwiftError())
+        continue;
 
       // If the alloca is already scoped to something smaller than the whole
       // function then there's no need to add redundant, less accurate markers.
index 12c433b..fc209cc 100644 (file)
@@ -98,3 +98,20 @@ define void @test_arrays_alloca() {
 ; CHECK: ret void
   ret void
 }
+
+%swift.error = type opaque
+
+define void @helper_swifterror_alloca() {
+entry:
+  %swifterror = alloca swifterror %swift.error*, align 8
+  store %swift.error* null, %swift.error** %swifterror, align 8
+  ret void
+}
+
+define void @test_swifterror_alloca() {
+; CHECK-LABEL: @test_swifterror_alloca(
+; CHECK-NOT: lifetime
+  call void @helper_swifterror_alloca()
+; CHECK: ret void
+  ret void
+}