[llvm-branch-commits] [llvm-branch] r271592 - Merging r259546:
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jun 2 14:01:44 PDT 2016
Author: tstellar
Date: Thu Jun 2 16:01:44 2016
New Revision: 271592
URL: http://llvm.org/viewvc/llvm-project?rev=271592&view=rev
Log:
Merging r259546:
------------------------------------------------------------------------
r259546 | Matthew.Arsenault | 2016-02-02 11:18:53 -0800 (Tue, 02 Feb 2016) | 5 lines
AMDGPU: Whitelist handled intrinsics
We shouldn't crash on unhandled intrinsics.
Also simplify failure handling in loop.
------------------------------------------------------------------------
Added:
llvm/branches/release_38/test/CodeGen/AMDGPU/promote-alloca-unhandled-intrinsic.ll
Modified:
llvm/branches/release_38/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
Modified: llvm/branches/release_38/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp?rev=271592&r1=271591&r2=271592&view=diff
==============================================================================
--- llvm/branches/release_38/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp (original)
+++ llvm/branches/release_38/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp Thu Jun 2 16:01:44 2016
@@ -256,15 +256,37 @@ static bool tryPromoteAllocaToVector(All
return true;
}
+static bool isCallPromotable(CallInst *CI) {
+ // TODO: We might be able to handle some cases where the callee is a
+ // constantexpr bitcast of a function.
+ if (!CI->getCalledFunction())
+ return false;
+
+ IntrinsicInst *II = dyn_cast<IntrinsicInst>(CI);
+ if (!II)
+ return false;
+
+ switch (II->getIntrinsicID()) {
+ case Intrinsic::memcpy:
+ case Intrinsic::memset:
+ case Intrinsic::lifetime_start:
+ case Intrinsic::lifetime_end:
+ case Intrinsic::invariant_start:
+ case Intrinsic::invariant_end:
+ case Intrinsic::invariant_group_barrier:
+ return true;
+ default:
+ return false;
+ }
+}
+
static bool collectUsesWithPtrTypes(Value *Val, std::vector<Value*> &WorkList) {
- bool Success = true;
for (User *User : Val->users()) {
- if(std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end())
+ if (std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end())
continue;
+
if (CallInst *CI = dyn_cast<CallInst>(User)) {
- // TODO: We might be able to handle some cases where the callee is a
- // constantexpr bitcast of a function.
- if (!CI->getCalledFunction())
+ if (!isCallPromotable(CI))
return false;
WorkList.push_back(User);
@@ -286,10 +308,11 @@ static bool collectUsesWithPtrTypes(Valu
continue;
WorkList.push_back(User);
-
- Success &= collectUsesWithPtrTypes(User, WorkList);
+ if (!collectUsesWithPtrTypes(User, WorkList))
+ return false;
}
- return Success;
+
+ return true;
}
void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
@@ -392,6 +415,11 @@ void AMDGPUPromoteAlloca::visitAlloca(Al
IntrinsicInst *Intr = dyn_cast<IntrinsicInst>(Call);
if (!Intr) {
+ // FIXME: What is this for? It doesn't make sense to promote arbitrary
+ // function calls. If the call is to a defined function that can also be
+ // promoted, we should be able to do this once that function is also
+ // rewritten.
+
std::vector<Type*> ArgTypes;
for (unsigned ArgIdx = 0, ArgEnd = Call->getNumArgOperands();
ArgIdx != ArgEnd; ++ArgIdx) {
Added: llvm/branches/release_38/test/CodeGen/AMDGPU/promote-alloca-unhandled-intrinsic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/test/CodeGen/AMDGPU/promote-alloca-unhandled-intrinsic.ll?rev=271592&view=auto
==============================================================================
--- llvm/branches/release_38/test/CodeGen/AMDGPU/promote-alloca-unhandled-intrinsic.ll (added)
+++ llvm/branches/release_38/test/CodeGen/AMDGPU/promote-alloca-unhandled-intrinsic.ll Thu Jun 2 16:01:44 2016
@@ -0,0 +1,24 @@
+; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck %s
+
+; This is just an arbitrary intrinisic that shouldn't ever need to be
+; handled to ensure it doesn't crash.
+
+declare void @eh.sjlj.functioncontext(i8*) #2
+
+; CHECK-LABEL: @try_promote_unhandled_intrinsic(
+; CHECK: alloca
+; CHECK: call void @eh.sjlj.functioncontext(i8* %tmp1)
+define void @try_promote_unhandled_intrinsic(i32 addrspace(1)* %arg) #2 {
+bb:
+ %tmp = alloca i32, align 4
+ %tmp1 = bitcast i32* %tmp to i8*
+ %tmp2 = getelementptr inbounds i32, i32 addrspace(1)* %arg, i64 1
+ %tmp3 = load i32, i32 addrspace(1)* %tmp2
+ store i32 %tmp3, i32* %tmp
+ call void @eh.sjlj.functioncontext(i8* %tmp1)
+ ret void
+}
+
+attributes #0 = { argmemonly nounwind }
+attributes #1 = { nounwind readnone }
+attributes #2 = { nounwind }
More information about the llvm-branch-commits
mailing list