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 | ee5d4a7b7328d42996dc34c3b4ef4d0acf564c39 (patch) | |
tree | 6e0498ea0da7bdf3c2b669fa1ed258cada42bf0b /lib/Target | |
parent | b880c129ecf5ea92135a5a208642c96f25073e54 (diff) | |
download | llvm-ee5d4a7b7328d42996dc34c3b4ef4d0acf564c39.tar.gz llvm-ee5d4a7b7328d42996dc34c3b4ef4d0acf564c39.tar.bz2 llvm-ee5d4a7b7328d42996dc34c3b4ef4d0acf564c39.tar.xz |
R600: Don't crash on unhandled instruction in promote alloca
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211906 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/R600/AMDGPUPromoteAlloca.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/Target/R600/AMDGPUPromoteAlloca.cpp b/lib/Target/R600/AMDGPUPromoteAlloca.cpp index 053ea8a90b..218750d445 100644 --- a/lib/Target/R600/AMDGPUPromoteAlloca.cpp +++ b/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; |