@@ -3643,10 +3643,11 @@ static void emitGlobalConstantArray(const DataLayout &DL,
3643
3643
3644
3644
static void emitGlobalConstantLargeInt (const ConstantInt *CI, AsmPrinter &AP);
3645
3645
3646
- static void emitGlobalConstantVector (const DataLayout &DL,
3647
- const ConstantVector *CV, AsmPrinter &AP,
3646
+ static void emitGlobalConstantVector (const DataLayout &DL, const Constant *CV,
3647
+ AsmPrinter &AP,
3648
3648
AsmPrinter::AliasMapTy *AliasList) {
3649
- Type *ElementType = CV->getType ()->getElementType ();
3649
+ auto *VTy = cast<FixedVectorType>(CV->getType ());
3650
+ Type *ElementType = VTy->getElementType ();
3650
3651
uint64_t ElementSizeInBits = DL.getTypeSizeInBits (ElementType);
3651
3652
uint64_t ElementAllocSizeInBits = DL.getTypeAllocSizeInBits (ElementType);
3652
3653
uint64_t EmittedSize;
@@ -3659,7 +3660,7 @@ static void emitGlobalConstantVector(const DataLayout &DL,
3659
3660
Type *IntT =
3660
3661
IntegerType::get (CV->getContext (), DL.getTypeSizeInBits (CV->getType ()));
3661
3662
ConstantInt *CI = dyn_cast_or_null<ConstantInt>(ConstantFoldConstant (
3662
- ConstantExpr::getBitCast (const_cast <ConstantVector *>(CV), IntT), DL));
3663
+ ConstantExpr::getBitCast (const_cast <Constant *>(CV), IntT), DL));
3663
3664
if (!CI) {
3664
3665
report_fatal_error (
3665
3666
" Cannot lower vector global with unusual element type" );
@@ -3668,12 +3669,11 @@ static void emitGlobalConstantVector(const DataLayout &DL,
3668
3669
emitGlobalConstantLargeInt (CI, AP);
3669
3670
EmittedSize = DL.getTypeStoreSize (CV->getType ());
3670
3671
} else {
3671
- for (unsigned I = 0 , E = CV-> getType () ->getNumElements (); I != E; ++I) {
3672
+ for (unsigned I = 0 , E = VTy ->getNumElements (); I != E; ++I) {
3672
3673
emitGlobalAliasInline (AP, DL.getTypeAllocSize (CV->getType ()) * I, AliasList);
3673
- emitGlobalConstantImpl (DL, CV->getOperand (I), AP);
3674
+ emitGlobalConstantImpl (DL, CV->getAggregateElement (I), AP);
3674
3675
}
3675
- EmittedSize =
3676
- DL.getTypeAllocSize (ElementType) * CV->getType ()->getNumElements ();
3676
+ EmittedSize = DL.getTypeAllocSize (ElementType) * VTy->getNumElements ();
3677
3677
}
3678
3678
3679
3679
unsigned Size = DL.getTypeAllocSize (CV->getType ());
@@ -3943,8 +3943,10 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
3943
3943
return AP.OutStreamer ->emitZeros (Size);
3944
3944
3945
3945
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
3946
- const uint64_t StoreSize = DL.getTypeStoreSize (CV->getType ());
3946
+ if (isa<VectorType>(CV->getType ()))
3947
+ return emitGlobalConstantVector (DL, CV, AP, AliasList);
3947
3948
3949
+ const uint64_t StoreSize = DL.getTypeStoreSize (CV->getType ());
3948
3950
if (StoreSize <= 8 ) {
3949
3951
if (AP.isVerbose ())
3950
3952
AP.OutStreamer ->getCommentOS ()
@@ -3961,8 +3963,12 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
3961
3963
return ;
3962
3964
}
3963
3965
3964
- if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV))
3965
- return emitGlobalConstantFP (CFP, AP);
3966
+ if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
3967
+ if (isa<VectorType>(CV->getType ()))
3968
+ return emitGlobalConstantVector (DL, CV, AP, AliasList);
3969
+ else
3970
+ return emitGlobalConstantFP (CFP, AP);
3971
+ }
3966
3972
3967
3973
if (isa<ConstantPointerNull>(CV)) {
3968
3974
AP.OutStreamer ->emitIntValue (0 , Size);
@@ -3994,8 +4000,8 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
3994
4000
}
3995
4001
}
3996
4002
3997
- if (const ConstantVector *V = dyn_cast <ConstantVector>(CV))
3998
- return emitGlobalConstantVector (DL, V , AP, AliasList);
4003
+ if (isa <ConstantVector>(CV))
4004
+ return emitGlobalConstantVector (DL, CV , AP, AliasList);
3999
4005
4000
4006
// Otherwise, it must be a ConstantExpr. Lower it to an MCExpr, then emit it
4001
4007
// thread the streamer with EmitValue.
0 commit comments