[llvm-commits] [llvm] r110986 - in /llvm/trunk/lib/VMCore: Instructions.cpp Verifier.cpp
Nate Begeman
natebegeman at mac.com
Thu Aug 12 17:16:46 PDT 2010
Author: sampo
Date: Thu Aug 12 19:16:46 2010
New Revision: 110986
URL: http://llvm.org/viewvc/llvm-project?rev=110986&view=rev
Log:
Move some code from Verifier into SVI::isValidOperands. This allows us to catch bad shufflevector operations when they are created, rather than waiting for someone to notice later on.
Modified:
llvm/trunk/lib/VMCore/Instructions.cpp
llvm/trunk/lib/VMCore/Verifier.cpp
Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=110986&r1=110985&r2=110986&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Thu Aug 12 19:16:46 2010
@@ -1430,9 +1430,24 @@
return false;
const VectorType *MaskTy = dyn_cast<VectorType>(Mask->getType());
- if (!isa<Constant>(Mask) || MaskTy == 0 ||
- !MaskTy->getElementType()->isIntegerTy(32))
+ if (MaskTy == 0 || !MaskTy->getElementType()->isIntegerTy(32))
return false;
+
+ // Check to see if Mask is valid.
+ if (const ConstantVector *MV = dyn_cast<ConstantVector>(Mask)) {
+ const VectorType *VTy = cast<VectorType>(V1->getType());
+ for (unsigned i = 0, e = MV->getNumOperands(); i != e; ++i) {
+ if (ConstantInt* CI = dyn_cast<ConstantInt>(MV->getOperand(i))) {
+ if (CI->uge(VTy->getNumElements()*2))
+ return false;
+ } else if (!isa<UndefValue>(MV->getOperand(i))) {
+ return false;
+ }
+ }
+ }
+ else if (!isa<UndefValue>(Mask) && !isa<ConstantAggregateZero>(Mask))
+ return false;
+
return true;
}
Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=110986&r1=110985&r2=110986&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Thu Aug 12 19:16:46 2010
@@ -1322,27 +1322,6 @@
Assert1(ShuffleVectorInst::isValidOperands(SV.getOperand(0), SV.getOperand(1),
SV.getOperand(2)),
"Invalid shufflevector operands!", &SV);
-
- const VectorType *VTy = dyn_cast<VectorType>(SV.getOperand(0)->getType());
- Assert1(VTy, "Operands are not a vector type", &SV);
-
- // Check to see if Mask is valid.
- if (const ConstantVector *MV = dyn_cast<ConstantVector>(SV.getOperand(2))) {
- for (unsigned i = 0, e = MV->getNumOperands(); i != e; ++i) {
- if (ConstantInt* CI = dyn_cast<ConstantInt>(MV->getOperand(i))) {
- Assert1(!CI->uge(VTy->getNumElements()*2),
- "Invalid shufflevector shuffle mask!", &SV);
- } else {
- Assert1(isa<UndefValue>(MV->getOperand(i)),
- "Invalid shufflevector shuffle mask!", &SV);
- }
- }
- } else {
- Assert1(isa<UndefValue>(SV.getOperand(2)) ||
- isa<ConstantAggregateZero>(SV.getOperand(2)),
- "Invalid shufflevector shuffle mask!", &SV);
- }
-
visitInstruction(SV);
}
More information about the llvm-commits
mailing list