summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2020-01-02 16:41:17 -0600
committerJohannes Doerfert <johannes@jdoerfert.de>2020-01-03 10:43:40 -0600
commitc90681b681a7a45cf5bf515d1904e2015f7ed524 (patch)
tree2f2717ada6978074a6759d5907948b6dabb8ba7d
parent412a0101a99e5330d5bbe4954cd421af81d0dc64 (diff)
downloadbcm5719-llvm-c90681b681a7a45cf5bf515d1904e2015f7ed524.tar.gz
bcm5719-llvm-c90681b681a7a45cf5bf515d1904e2015f7ed524.zip
[Attributor][FIX] Don't crash on ptr2int/int2ptr instructions
An integer isn't allowed in getAlignmentForValue so we need to stop at a ptr2int instruction during exploration.
-rw-r--r--llvm/lib/Transforms/IPO/Attributor.cpp3
-rw-r--r--llvm/test/Transforms/Attributor/align.ll10
2 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 2655930aec5..46664d62769 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -3466,7 +3466,8 @@ static unsigned int getKnownAlignForUse(Attributor &A,
// We need to follow common pointer manipulation uses to the accesses they
// feed into.
if (isa<CastInst>(I)) {
- TrackUse = true;
+ // Follow all but ptr2int casts.
+ TrackUse = !isa<PtrToIntInst>(I);
return 0;
}
if (auto *GEP = dyn_cast<GetElementPtrInst>(I)) {
diff --git a/llvm/test/Transforms/Attributor/align.ll b/llvm/test/Transforms/Attributor/align.ll
index 6f955be467b..f01ae28431d 100644
--- a/llvm/test/Transforms/Attributor/align.ll
+++ b/llvm/test/Transforms/Attributor/align.ll
@@ -398,5 +398,15 @@ define void @test12-6(i32* align 4 %p) {
ret void
}
+; Don't crash on ptr2int/int2ptr uses.
+define i64 @ptr2int(i32* %p) {
+ %p2i = ptrtoint i32* %p to i64
+ ret i64 %p2i
+}
+define i64* @int2ptr(i64 %i) {
+ %i2p = inttoptr i64 %i to i64*
+ ret i64* %i2p
+}
+
attributes #0 = { nounwind uwtable noinline }
attributes #1 = { uwtable noinline }
OpenPOWER on IntegriCloud