[llvm] r235312 - [InlineFunction] Don't add lifetime markers for zero-sized allocas.
Akira Hatanaka
ahatanaka at apple.com
Mon Apr 20 09:11:06 PDT 2015
Author: ahatanak
Date: Mon Apr 20 11:11:05 2015
New Revision: 235312
URL: http://llvm.org/viewvc/llvm-project?rev=235312&view=rev
Log:
[InlineFunction] Don't add lifetime markers for zero-sized allocas.
This commit fixes the code which adds lifetime markers in InlineFunction to skip
zero-sized allocas instead of asserting on them.
rdar://problem/20531155
Added:
llvm/trunk/test/Transforms/Inline/crash-lifetime-marker.ll
Modified:
llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=235312&r1=235311&r2=235312&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Apr 20 11:11:05 2015
@@ -1167,7 +1167,11 @@ bool llvm::InlineFunction(CallSite CS, I
Type *AllocaType = AI->getAllocatedType();
uint64_t AllocaTypeSize = DL.getTypeAllocSize(AllocaType);
uint64_t AllocaArraySize = AIArraySize->getLimitedValue();
- assert(AllocaArraySize > 0 && "array size of AllocaInst is zero");
+
+ // Don't add markers for zero-sized allocas.
+ if (AllocaArraySize == 0)
+ continue;
+
// Check that array size doesn't saturate uint64_t and doesn't
// overflow when it's multiplied by type size.
if (AllocaArraySize != ~0ULL &&
Added: llvm/trunk/test/Transforms/Inline/crash-lifetime-marker.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/crash-lifetime-marker.ll?rev=235312&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Inline/crash-lifetime-marker.ll (added)
+++ llvm/trunk/test/Transforms/Inline/crash-lifetime-marker.ll Mon Apr 20 11:11:05 2015
@@ -0,0 +1,24 @@
+; RUN: opt < %s -inline -S | FileCheck %s
+
+; InlineFunction would assert inside the loop that leaves lifetime markers if
+; there was an zero-sized AllocaInst. Check that it doesn't assert and doesn't
+; leave lifetime markers in that case.
+
+declare i32 @callee2(i8*)
+
+define i32 @callee1(i32 %count) {
+ %a0 = alloca i8, i32 %count, align 4
+ %call0 = call i32 @callee2(i8* %a0)
+ ret i32 %call0
+}
+
+; CHECK-LABEL: define i32 @caller1(
+; CHECK: [[ALLOCA:%[a-z0-9\.]+]] = alloca i8
+; CHECK-NOT: call void @llvm.lifetime.start(
+; CHECK: call i32 @callee2(i8* [[ALLOCA]])
+; CHECK-NOT: call void @llvm.lifetime.end(
+
+define i32 @caller1(i32 %count) {
+ %call0 = call i32 @callee1(i32 0)
+ ret i32 %call0
+}
More information about the llvm-commits
mailing list