fix minsize detection: minsize attribute implies optimizing for size
[oota-llvm.git] / lib / Target / X86 / X86TargetObjectFile.cpp
index e026608fc85501fa8f7be2954aa20eb3ca0094c8..b4dc6ed149ef7ed4b2d7f1f05f681d033999ff8d 100644 (file)
@@ -139,18 +139,21 @@ static std::string scalarConstantToHexString(const Constant *C) {
     return APIntToHexString(CFP->getValueAPF().bitcastToAPInt());
   } else if (const auto *CI = dyn_cast<ConstantInt>(C)) {
     return APIntToHexString(CI->getValue());
-  } else if (const auto *VTy = dyn_cast<VectorType>(Ty)) {
+  } else {
+    unsigned NumElements;
+    if (isa<VectorType>(Ty))
+      NumElements = Ty->getVectorNumElements();
+    else
+      NumElements = Ty->getArrayNumElements();
     std::string HexString;
-    for (int I = VTy->getNumElements() - 1, E = -1; I != E; --I)
+    for (int I = NumElements - 1, E = -1; I != E; --I)
       HexString += scalarConstantToHexString(C->getAggregateElement(I));
     return HexString;
   }
-  llvm_unreachable("unexpected constant pool element type!");
 }
 
-MCSection *
-X86WindowsTargetObjectFile::getSectionForConstant(SectionKind Kind,
-                                                  const Constant *C) const {
+MCSection *X86WindowsTargetObjectFile::getSectionForConstant(
+    const DataLayout &DL, SectionKind Kind, const Constant *C) const {
   if (Kind.isMergeableConst() && C) {
     const unsigned Characteristics = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
                                      COFF::IMAGE_SCN_MEM_READ |
@@ -167,5 +170,5 @@ X86WindowsTargetObjectFile::getSectionForConstant(SectionKind Kind,
                                          COFF::IMAGE_COMDAT_SELECT_ANY);
   }
 
-  return TargetLoweringObjectFile::getSectionForConstant(Kind, C);
+  return TargetLoweringObjectFile::getSectionForConstant(DL, Kind, C);
 }