[llvm] 04288e9 - Fix 46594 - Alignment assertion failure in instcombine

Guillaume Chatelet via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 6 01:45:21 PDT 2020


Author: Guillaume Chatelet
Date: 2020-07-06T08:45:05Z
New Revision: 04288e93be7bbcdca5707d84149e864923f9ed25

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

LOG: Fix 46594 - Alignment assertion failure in instcombine

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 966b3246f4f5..836af6234ad5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -4540,10 +4540,11 @@ static void annotateAnyAllocSite(CallBase &Call, const TargetLibraryInfo *TLI) {
                           Call.getContext(), Op1C->getZExtValue()));
     // Add alignment attribute if alignment is a power of two constant.
     if (Op0C && Op0C->getValue().ult(llvm::Value::MaximumAlignment)) {
-      if (MaybeAlign AlignmentVal = Op0C->getMaybeAlignValue())
-        Call.addAttribute(
-            AttributeList::ReturnIndex,
-            Attribute::getWithAlignment(Call.getContext(), *AlignmentVal));
+      uint64_t AlignmentVal = Op0C->getZExtValue();
+      if (llvm::isPowerOf2_64(AlignmentVal))
+        Call.addAttribute(AttributeList::ReturnIndex,
+                          Attribute::getWithAlignment(Call.getContext(),
+                                                      Align(AlignmentVal)));
     }
   } else if (isReallocLikeFn(&Call, TLI) && Op1C) {
     Call.addAttribute(AttributeList::ReturnIndex,


        


More information about the llvm-commits mailing list