diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-06-27 16:52:49 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-06-27 16:52:49 +0000 |
commit | 642d2e78b3b1bbb71df478de3eed9979378c983a (patch) | |
tree | 5c2b4c575b5b213a900bb521d38f820aa16b3c36 /llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp | |
parent | 6666074876eff651e25bd1cd3cfa0848b26f7c28 (diff) | |
download | bcm5719-llvm-642d2e78b3b1bbb71df478de3eed9979378c983a.tar.gz bcm5719-llvm-642d2e78b3b1bbb71df478de3eed9979378c983a.zip |
R600: Don't crash on unhandled instruction in promote alloca
llvm-svn: 211906
Diffstat (limited to 'llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp')
-rw-r--r-- | llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp index 053ea8a90b7..218750d445e 100644 --- a/llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp +++ b/llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp @@ -129,6 +129,22 @@ static Value* GEPToVectorIndex(GetElementPtrInst *GEP) { return GEP->getOperand(2); } +// Not an instruction handled below to turn into a vector. +// +// TODO: Check isTriviallyVectorizable for calls and handle other +// instructions. +static bool canVectorizeInst(Instruction *Inst) { + switch (Inst->getOpcode()) { + case Instruction::Load: + case Instruction::Store: + case Instruction::BitCast: + case Instruction::AddrSpaceCast: + return true; + default: + return false; + } +} + static bool tryPromoteAllocaToVector(AllocaInst *Alloca) { Type *AllocaTy = Alloca->getAllocatedType(); @@ -149,6 +165,9 @@ static bool tryPromoteAllocaToVector(AllocaInst *Alloca) { for (User *AllocaUser : Alloca->users()) { GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(AllocaUser); if (!GEP) { + if (!canVectorizeInst(cast<Instruction>(AllocaUser))) + return false; + WorkList.push_back(AllocaUser); continue; } @@ -164,6 +183,9 @@ static bool tryPromoteAllocaToVector(AllocaInst *Alloca) { GEPVectorIdx[GEP] = Index; for (User *GEPUser : AllocaUser->users()) { + if (!canVectorizeInst(cast<Instruction>(GEPUser))) + return false; + WorkList.push_back(GEPUser); } } @@ -201,12 +223,12 @@ static bool tryPromoteAllocaToVector(AllocaInst *Alloca) { break; } case Instruction::BitCast: + case Instruction::AddrSpaceCast: break; default: Inst->dump(); - llvm_unreachable("Do not know how to replace this instruction " - "with vector op"); + llvm_unreachable("Inconsistency in instructions promotable to vector"); } } return true; |