[llvm] 5f77e77 - [InstCombine] Fixed crash when setting align attr for memalign
Dávid Bolvanský via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 23 05:05:42 PDT 2021
Author: Dávid Bolvanský
Date: 2021-04-23T14:04:08+02:00
New Revision: 5f77e7708aa76a250d649845acf408b9564b514f
URL: https://github.com/llvm/llvm-project/commit/5f77e7708aa76a250d649845acf408b9564b514f
DIFF: https://github.com/llvm/llvm-project/commit/5f77e7708aa76a250d649845acf408b9564b514f.diff
LOG: [InstCombine] Fixed crash when setting align attr for memalign
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/deref-alloc-fns.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 3932446f34ab5..954c853ab7f0e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2077,10 +2077,12 @@ void InstCombinerImpl::annotateAnyAllocSite(CallBase &Call, const TargetLibraryI
if (Op0C && Op0C->getValue().ult(llvm::Value::MaximumAlignment) &&
isKnownNonZero(Call.getOperand(1), DL, 0, &AC, &Call, &DT)) {
uint64_t AlignmentVal = Op0C->getZExtValue();
- if (llvm::isPowerOf2_64(AlignmentVal))
+ if (llvm::isPowerOf2_64(AlignmentVal)) {
+ Call.removeAttribute(AttributeList::ReturnIndex, Attribute::Alignment);
Call.addAttribute(AttributeList::ReturnIndex,
Attribute::getWithAlignment(Call.getContext(),
Align(AlignmentVal)));
+ }
}
} else if (isReallocLikeFn(&Call, TLI) && Op1C) {
Call.addAttribute(AttributeList::ReturnIndex,
diff --git a/llvm/test/Transforms/InstCombine/deref-alloc-fns.ll b/llvm/test/Transforms/InstCombine/deref-alloc-fns.ll
index b1901a1783df1..a4b48f432ad2f 100644
--- a/llvm/test/Transforms/InstCombine/deref-alloc-fns.ll
+++ b/llvm/test/Transforms/InstCombine/deref-alloc-fns.ll
@@ -10,7 +10,7 @@ declare noalias nonnull i8* @_Znam(i64) ; throwing version of 'new'
declare noalias nonnull i8* @_Znwm(i64) ; throwing version of 'new'
declare noalias i8* @strdup(i8*)
declare noalias i8* @aligned_alloc(i64, i64)
-declare noalias i8* @memalign(i64, i64)
+declare noalias align 16 i8* @memalign(i64, i64)
@.str = private unnamed_addr constant [6 x i8] c"hello\00", align 1
More information about the llvm-commits
mailing list