diff options
Diffstat (limited to 'lib/Transforms/Utils')
| -rw-r--r-- | lib/Transforms/Utils/FunctionImportUtils.cpp | 18 | ||||
| -rw-r--r-- | lib/Transforms/Utils/LoopUtils.cpp | 19 | 
2 files changed, 29 insertions, 8 deletions
| diff --git a/lib/Transforms/Utils/FunctionImportUtils.cpp b/lib/Transforms/Utils/FunctionImportUtils.cpp index a9772e31da50..81d63ee80394 100644 --- a/lib/Transforms/Utils/FunctionImportUtils.cpp +++ b/lib/Transforms/Utils/FunctionImportUtils.cpp @@ -249,6 +249,8 @@ void FunctionImportGlobalProcessing::processGlobalForThinLTO(GlobalValue &GV) {    bool DoPromote = false;    if (GV.hasLocalLinkage() &&        ((DoPromote = shouldPromoteLocalToGlobal(&GV)) || isPerformingImport())) { +    // Save the original name string before we rename GV below. +    auto Name = GV.getName().str();      // Once we change the name or linkage it is difficult to determine      // again whether we should promote since shouldPromoteLocalToGlobal needs      // to locate the summary (based on GUID from name and linkage). Therefore, @@ -257,6 +259,12 @@ void FunctionImportGlobalProcessing::processGlobalForThinLTO(GlobalValue &GV) {      GV.setLinkage(getLinkage(&GV, DoPromote));      if (!GV.hasLocalLinkage())        GV.setVisibility(GlobalValue::HiddenVisibility); + +    // If we are renaming a COMDAT leader, ensure that we record the COMDAT +    // for later renaming as well. This is required for COFF. +    if (const auto *C = GV.getComdat()) +      if (C->getName() == Name) +        RenamedComdats.try_emplace(C, M.getOrInsertComdat(GV.getName()));    } else      GV.setLinkage(getLinkage(&GV, /* DoPromote */ false)); @@ -281,6 +289,16 @@ void FunctionImportGlobalProcessing::processGlobalsForThinLTO() {      processGlobalForThinLTO(SF);    for (GlobalAlias &GA : M.aliases())      processGlobalForThinLTO(GA); + +  // Replace any COMDATS that required renaming (because the COMDAT leader was +  // promoted and renamed). +  if (!RenamedComdats.empty()) +    for (auto &GO : M.global_objects()) +      if (auto *C = GO.getComdat()) { +        auto Replacement = RenamedComdats.find(C); +        if (Replacement != RenamedComdats.end()) +          GO.setComdat(Replacement->second); +      }  }  bool FunctionImportGlobalProcessing::run() { diff --git a/lib/Transforms/Utils/LoopUtils.cpp b/lib/Transforms/Utils/LoopUtils.cpp index a93d1aeb62ef..112e80d27e34 100644 --- a/lib/Transforms/Utils/LoopUtils.cpp +++ b/lib/Transforms/Utils/LoopUtils.cpp @@ -217,7 +217,10 @@ static Optional<bool> getOptionalBoolLoopAttribute(const Loop *TheLoop,      // When the value is absent it is interpreted as 'attribute set'.      return true;    case 2: -    return mdconst::extract_or_null<ConstantInt>(MD->getOperand(1).get()); +    if (ConstantInt *IntMD = +            mdconst::extract_or_null<ConstantInt>(MD->getOperand(1).get())) +      return IntMD->getZExtValue(); +    return true;    }    llvm_unreachable("unexpected number of options");  } @@ -376,17 +379,17 @@ TransformationMode llvm::hasVectorizeTransformation(Loop *L) {    Optional<int> InterleaveCount =        getOptionalIntLoopAttribute(L, "llvm.loop.interleave.count"); -  if (Enable == true) { -    // 'Forcing' vector width and interleave count to one effectively disables -    // this tranformation. -    if (VectorizeWidth == 1 && InterleaveCount == 1) -      return TM_SuppressedByUser; -    return TM_ForcedByUser; -  } +  // 'Forcing' vector width and interleave count to one effectively disables +  // this tranformation. +  if (Enable == true && VectorizeWidth == 1 && InterleaveCount == 1) +    return TM_SuppressedByUser;    if (getBooleanLoopAttribute(L, "llvm.loop.isvectorized"))      return TM_Disable; +  if (Enable == true) +    return TM_ForcedByUser; +    if (VectorizeWidth == 1 && InterleaveCount == 1)      return TM_Disable; | 
