diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -2175,30 +2175,6 @@ takeKnownMaximum(Attr.getValueAsInt()); } - // TODO: Provide a helper to determine the implied ABI alignment and check in - // the existing manifest method and a new one for AAAlignImpl that value - // to avoid making the alignment explicit if it did not improve. - - /// See AbstractAttribute::getDeducedAttributes - virtual void - getDeducedAttributes(LLVMContext &Ctx, - SmallVectorImpl &Attrs) const override { - if (getAssumedAlign() > 1) - Attrs.emplace_back(Attribute::getWithAlignment(Ctx, getAssumedAlign())); - } - - /// See AbstractAttribute::getAsStr(). - const std::string getAsStr() const override { - return getAssumedAlign() ? ("align<" + std::to_string(getKnownAlign()) + - "-" + std::to_string(getAssumedAlign()) + ">") - : "unknown-align"; - } -}; - -/// Align attribute for a floating value. -struct AAAlignFloating : AAAlignImpl { - AAAlignFloating(const IRPosition &IRP) : AAAlignImpl(IRP) {} - /// See AbstractAttribute::manifest(...). ChangeStatus manifest(Attributor &A) override { ChangeStatus Changed = ChangeStatus::UNCHANGED; @@ -2225,9 +2201,33 @@ } } - return AAAlignImpl::manifest(A) | Changed; + return AAAlign::manifest(A) | Changed; } + // TODO: Provide a helper to determine the implied ABI alignment and check in + // the existing manifest method and a new one for AAAlignImpl that value + // to avoid making the alignment explicit if it did not improve. + + /// See AbstractAttribute::getDeducedAttributes + virtual void + getDeducedAttributes(LLVMContext &Ctx, + SmallVectorImpl &Attrs) const override { + if (getAssumedAlign() > 1) + Attrs.emplace_back(Attribute::getWithAlignment(Ctx, getAssumedAlign())); + } + + /// See AbstractAttribute::getAsStr(). + const std::string getAsStr() const override { + return getAssumedAlign() ? ("align<" + std::to_string(getKnownAlign()) + + "-" + std::to_string(getAssumedAlign()) + ">") + : "unknown-align"; + } +}; + +/// Align attribute for a floating value. +struct AAAlignFloating : AAAlignImpl { + AAAlignFloating(const IRPosition &IRP) : AAAlignImpl(IRP) {} + /// See AbstractAttribute::updateImpl(...). ChangeStatus updateImpl(Attributor &A) override { const DataLayout &DL = A.getDataLayout(); diff --git a/llvm/test/Transforms/FunctionAttrs/align.ll b/llvm/test/Transforms/FunctionAttrs/align.ll --- a/llvm/test/Transforms/FunctionAttrs/align.ll +++ b/llvm/test/Transforms/FunctionAttrs/align.ll @@ -90,6 +90,8 @@ ;