@@ -3602,10 +3602,11 @@ static void emitGlobalConstantArray(const DataLayout &DL,
36023602
36033603static void emitGlobalConstantLargeInt (const ConstantInt *CI, AsmPrinter &AP);
36043604
3605- static void emitGlobalConstantVector (const DataLayout &DL,
3606- const ConstantVector *CV, AsmPrinter &AP,
3605+ static void emitGlobalConstantVector (const DataLayout &DL, const Constant *CV,
3606+ AsmPrinter &AP,
36073607 AsmPrinter::AliasMapTy *AliasList) {
3608- Type *ElementType = CV->getType ()->getElementType ();
3608+ auto *VTy = cast<FixedVectorType>(CV->getType ());
3609+ Type *ElementType = VTy->getElementType ();
36093610 uint64_t ElementSizeInBits = DL.getTypeSizeInBits (ElementType);
36103611 uint64_t ElementAllocSizeInBits = DL.getTypeAllocSizeInBits (ElementType);
36113612 uint64_t EmittedSize;
@@ -3618,7 +3619,7 @@ static void emitGlobalConstantVector(const DataLayout &DL,
36183619 Type *IntT =
36193620 IntegerType::get (CV->getContext (), DL.getTypeSizeInBits (CV->getType ()));
36203621 ConstantInt *CI = dyn_cast_or_null<ConstantInt>(ConstantFoldConstant (
3621- ConstantExpr::getBitCast (const_cast <ConstantVector *>(CV), IntT), DL));
3622+ ConstantExpr::getBitCast (const_cast <Constant *>(CV), IntT), DL));
36223623 if (!CI) {
36233624 report_fatal_error (
36243625 " Cannot lower vector global with unusual element type" );
@@ -3627,12 +3628,11 @@ static void emitGlobalConstantVector(const DataLayout &DL,
36273628 emitGlobalConstantLargeInt (CI, AP);
36283629 EmittedSize = DL.getTypeStoreSize (CV->getType ());
36293630 } else {
3630- for (unsigned I = 0 , E = CV-> getType () ->getNumElements (); I != E; ++I) {
3631+ for (unsigned I = 0 , E = VTy ->getNumElements (); I != E; ++I) {
36313632 emitGlobalAliasInline (AP, DL.getTypeAllocSize (CV->getType ()) * I, AliasList);
3632- emitGlobalConstantImpl (DL, CV->getOperand (I), AP);
3633+ emitGlobalConstantImpl (DL, CV->getAggregateElement (I), AP);
36333634 }
3634- EmittedSize =
3635- DL.getTypeAllocSize (ElementType) * CV->getType ()->getNumElements ();
3635+ EmittedSize = DL.getTypeAllocSize (ElementType) * VTy->getNumElements ();
36363636 }
36373637
36383638 unsigned Size = DL.getTypeAllocSize (CV->getType ());
@@ -3902,8 +3902,10 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
39023902 return AP.OutStreamer ->emitZeros (Size);
39033903
39043904 if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
3905- const uint64_t StoreSize = DL.getTypeStoreSize (CV->getType ());
3905+ if (isa<VectorType>(CV->getType ()))
3906+ return emitGlobalConstantVector (DL, CV, AP, AliasList);
39063907
3908+ const uint64_t StoreSize = DL.getTypeStoreSize (CV->getType ());
39073909 if (StoreSize <= 8 ) {
39083910 if (AP.isVerbose ())
39093911 AP.OutStreamer ->getCommentOS ()
@@ -3920,8 +3922,12 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
39203922 return ;
39213923 }
39223924
3923- if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV))
3924- return emitGlobalConstantFP (CFP, AP);
3925+ if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
3926+ if (isa<VectorType>(CV->getType ()))
3927+ return emitGlobalConstantVector (DL, CV, AP, AliasList);
3928+ else
3929+ return emitGlobalConstantFP (CFP, AP);
3930+ }
39253931
39263932 if (isa<ConstantPointerNull>(CV)) {
39273933 AP.OutStreamer ->emitIntValue (0 , Size);
@@ -3953,8 +3959,8 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
39533959 }
39543960 }
39553961
3956- if (const ConstantVector *V = dyn_cast <ConstantVector>(CV))
3957- return emitGlobalConstantVector (DL, V , AP, AliasList);
3962+ if (isa <ConstantVector>(CV))
3963+ return emitGlobalConstantVector (DL, CV , AP, AliasList);
39583964
39593965 // Otherwise, it must be a ConstantExpr. Lower it to an MCExpr, then emit it
39603966 // thread the streamer with EmitValue.
0 commit comments