[llvm] db57065 - [Attributor] Use getAllocAlignment where possible [NFC]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 12 16:59:30 PST 2022


Author: Philip Reames
Date: 2022-01-12T16:58:39-08:00
New Revision: db57065b368ab4a078b749ccf14b0f384ab4571f

URL: https://github.com/llvm/llvm-project/commit/db57065b368ab4a078b749ccf14b0f384ab4571f
DIFF: https://github.com/llvm/llvm-project/commit/db57065b368ab4a078b749ccf14b0f384ab4571f.diff

LOG: [Attributor] Use getAllocAlignment where possible [NFC]

Inspired by D116971.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 8779d7dd9bc7a..d9cffa0757761 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5957,9 +5957,8 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
       Align Alignment(1);
       if (MaybeAlign RetAlign = AI.CB->getRetAlign())
         Alignment = max(Alignment, RetAlign);
-      if (AI.Kind == AllocationInfo::AllocationKind::ALIGNED_ALLOC) {
-        Optional<APInt> AlignmentAPI =
-            getAPInt(A, *this, *AI.CB->getArgOperand(0));
+      if (Value *Align = getAllocAlignment(AI.CB, TLI)) {
+        Optional<APInt> AlignmentAPI = getAPInt(A, *this, *Align);
         assert(AlignmentAPI.hasValue() &&
                "Expected an alignment during manifest!");
         Alignment =
@@ -6053,6 +6052,7 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
 ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
   ChangeStatus Changed = ChangeStatus::UNCHANGED;
   const Function *F = getAnchorScope();
+  const auto *TLI = A.getInfoCache().getTargetLibraryInfoForFunction(*F);
 
   const auto &LivenessAA =
       A.getAAFor<AAIsDead>(*this, IRPosition::function(*F), DepClassTy::NONE);
@@ -6268,14 +6268,16 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
       continue;
 
     if (MaxHeapToStackSize == -1) {
-      if (AI.Kind == AllocationInfo::AllocationKind::ALIGNED_ALLOC)
-        if (!getAPInt(A, *this, *AI.CB->getArgOperand(0)).hasValue()) {
+      if (AI.Kind == AllocationInfo::AllocationKind::ALIGNED_ALLOC) {
+        Value *Align = getAllocAlignment(AI.CB, TLI);
+        if (!Align || !getAPInt(A, *this, *Align)) {
           LLVM_DEBUG(dbgs() << "[H2S] Unknown allocation alignment: " << *AI.CB
                             << "\n");
           AI.Status = AllocationInfo::INVALID;
           Changed = ChangeStatus::CHANGED;
           continue;
         }
+      }
     } else {
       Optional<APInt> Size = getSize(A, *this, AI);
       if (!Size.hasValue() || Size.getValue().ugt(MaxHeapToStackSize)) {


        


More information about the llvm-commits mailing list