The bitcode reader can create an shuffle with a place holder mask which it will
fix up later. For this special case, allow such a mask to be considered valid.
<rdar://problem/8622574>
llvm-svn: 142992
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index b3a7205..c8dcdc8 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -1576,10 +1576,17 @@
return false;
}
}
- }
- else if (!isa<UndefValue>(Mask) && !isa<ConstantAggregateZero>(Mask))
+ } else if (!isa<UndefValue>(Mask) && !isa<ConstantAggregateZero>(Mask)) {
+ // The bitcode reader can create a place holder for a forward reference
+ // used as the shuffle mask. When this occurs, the shuffle mask will
+ // fall into this case and fail. To avoid this error, do this bit of
+ // ugliness to allow such a mask pass.
+ if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(Mask)) {
+ if (CE->getOpcode() == Instruction::UserOp1)
+ return true;
+ }
return false;
-
+ }
return true;
}