[llvm] 30ae859 - [Attributor][FIX] Store alignment only holds for the pointer value
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 16:14:52 PST 2020
Author: Johannes Doerfert
Date: 2020-01-23T18:13:52-06:00
New Revision: 30ae859c696748e1314788367226e4c65669f526
URL: https://github.com/llvm/llvm-project/commit/30ae859c696748e1314788367226e4c65669f526
DIFF: https://github.com/llvm/llvm-project/commit/30ae859c696748e1314788367226e4c65669f526.diff
LOG: [Attributor][FIX] Store alignment only holds for the pointer value
We accidentally used the store alignment for the value operand as well,
which is incorrect and crashed the SPASS application in the test suite.
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/test/Transforms/Attributor/align.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index baa1cb125d74..5eb21a0691b3 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -3420,9 +3420,10 @@ static unsigned int getKnownAlignForUse(Attributor &A,
}
const Value *UseV = U->get();
- if (auto *SI = dyn_cast<StoreInst>(I))
- Alignment = SI->getAlignment();
- else if (auto *LI = dyn_cast<LoadInst>(I))
+ if (auto *SI = dyn_cast<StoreInst>(I)) {
+ if (SI->getPointerOperand() == UseV)
+ Alignment = SI->getAlignment();
+ } else if (auto *LI = dyn_cast<LoadInst>(I))
Alignment = LI->getAlignment();
if (Alignment <= 1)
diff --git a/llvm/test/Transforms/Attributor/align.ll b/llvm/test/Transforms/Attributor/align.ll
index e47141ca16a6..d961a18f642a 100644
--- a/llvm/test/Transforms/Attributor/align.ll
+++ b/llvm/test/Transforms/Attributor/align.ll
@@ -501,6 +501,13 @@ define i64* @int2ptr(i64 %i) {
ret i64* %i2p
}
+; Use the store alignment only for the pointer operand.
+define void @aligned_store(i8* %Value, i8** %Ptr) {
+; ATTRIBUTOR: define void @aligned_store(i8* nofree writeonly %Value, i8** nocapture nofree nonnull writeonly align 32 dereferenceable(8) %Ptr)
+ store i8* %Value, i8** %Ptr, align 32
+ ret void
+}
+
attributes #0 = { nounwind uwtable noinline }
attributes #1 = { uwtable noinline }
attributes #2 = { "null-pointer-is-valid"="true" }
More information about the llvm-commits
mailing list