@@ -3643,10 +3643,11 @@ static void emitGlobalConstantArray(const DataLayout &DL,
36433643
36443644static void emitGlobalConstantLargeInt (const ConstantInt *CI, AsmPrinter &AP);
36453645
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,
36483648 AsmPrinter::AliasMapTy *AliasList) {
3649- Type *ElementType = CV->getType ()->getElementType ();
3649+ auto *VTy = cast<FixedVectorType>(CV->getType ());
3650+ Type *ElementType = VTy->getElementType ();
36503651 uint64_t ElementSizeInBits = DL.getTypeSizeInBits (ElementType);
36513652 uint64_t ElementAllocSizeInBits = DL.getTypeAllocSizeInBits (ElementType);
36523653 uint64_t EmittedSize;
@@ -3659,7 +3660,7 @@ static void emitGlobalConstantVector(const DataLayout &DL,
36593660 Type *IntT =
36603661 IntegerType::get (CV->getContext (), DL.getTypeSizeInBits (CV->getType ()));
36613662 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));
36633664 if (!CI) {
36643665 report_fatal_error (
36653666 " Cannot lower vector global with unusual element type" );
@@ -3668,12 +3669,11 @@ static void emitGlobalConstantVector(const DataLayout &DL,
36683669 emitGlobalConstantLargeInt (CI, AP);
36693670 EmittedSize = DL.getTypeStoreSize (CV->getType ());
36703671 } else {
3671- for (unsigned I = 0 , E = CV-> getType () ->getNumElements (); I != E; ++I) {
3672+ for (unsigned I = 0 , E = VTy ->getNumElements (); I != E; ++I) {
36723673 emitGlobalAliasInline (AP, DL.getTypeAllocSize (CV->getType ()) * I, AliasList);
3673- emitGlobalConstantImpl (DL, CV->getOperand (I), AP);
3674+ emitGlobalConstantImpl (DL, CV->getAggregateElement (I), AP);
36743675 }
3675- EmittedSize =
3676- DL.getTypeAllocSize (ElementType) * CV->getType ()->getNumElements ();
3676+ EmittedSize = DL.getTypeAllocSize (ElementType) * VTy->getNumElements ();
36773677 }
36783678
36793679 unsigned Size = DL.getTypeAllocSize (CV->getType ());
@@ -3943,8 +3943,10 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
39433943 return AP.OutStreamer ->emitZeros (Size);
39443944
39453945 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);
39473948
3949+ const uint64_t StoreSize = DL.getTypeStoreSize (CV->getType ());
39483950 if (StoreSize <= 8 ) {
39493951 if (AP.isVerbose ())
39503952 AP.OutStreamer ->getCommentOS ()
@@ -3961,8 +3963,12 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
39613963 return ;
39623964 }
39633965
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+ }
39663972
39673973 if (isa<ConstantPointerNull>(CV)) {
39683974 AP.OutStreamer ->emitIntValue (0 , Size);
@@ -3994,8 +4000,8 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *CV,
39944000 }
39954001 }
39964002
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);
39994005
40004006 // Otherwise, it must be a ConstantExpr. Lower it to an MCExpr, then emit it
40014007 // thread the streamer with EmitValue.
0 commit comments