Skip to content

Commit 46601da

Browse files
committed
Reinstate getSplat(unsigned NumElts, Constant *V)
Reinstate getSplat(unsigned NumElts, Constant *V) to avoid build errors in the front-end. When the front-end switches fully to getSplat(ElementCount EC, Constant *V) then the deprecated version will be removed. Change-Id: I8af69698a9be0d45a255759e50d2d2444e570874
1 parent d8c450e commit 46601da

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

llvm/include/llvm/IR/Constants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,9 @@ class ConstantVector final : public ConstantAggregate {
519519
/// Return a ConstantVector with the specified constant in each element.
520520
static Constant *getSplat(ElementCount EC, Constant *Elt);
521521

522+
/// \deprecated { Return a ConstantVector with the specified constant in each element. }
523+
static Constant *getSplat(unsigned NumElts, Constant *Elt);
524+
522525
/// Specialize the getType() method to always return a VectorType,
523526
/// which reduces the amount of casting needed in parts of the compiler.
524527
inline VectorType *getType() const {

llvm/lib/IR/Constants.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,17 @@ Constant *ConstantVector::getSplat(ElementCount EC, Constant *V) {
12351235
return ConstantExpr::getShuffleVector(V, UndefV, Zeros);
12361236
}
12371237

1238+
Constant *ConstantVector::getSplat(unsigned NumElts, Constant *V) {
1239+
// If this splat is compatible with ConstantDataVector, use it instead of
1240+
// ConstantVector.
1241+
if ((isa<ConstantFP>(V) || isa<ConstantInt>(V)) &&
1242+
ConstantDataSequential::isElementTypeCompatible(V->getType()))
1243+
return ConstantDataVector::getSplat(NumElts, V);
1244+
1245+
SmallVector<Constant*, 32> Elts(NumElts, V);
1246+
return get(Elts);
1247+
}
1248+
12381249
ConstantTokenNone *ConstantTokenNone::get(LLVMContext &Context) {
12391250
LLVMContextImpl *pImpl = Context.pImpl;
12401251
if (!pImpl->TheNoneToken)

0 commit comments

Comments
 (0)