aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2014-09-11 08:40:17 +0000
committerHal Finkel <hfinkel@anl.gov>2014-09-11 08:40:17 +0000
commitf83e1f7f6681e02b8f6d661ade76ddf10d55fd40 (patch)
treec4a38f33869b8d0767ef47da6b6f720a1d323fc6 /llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
parentfdfa8557c0c93ecc20df958addad5445c2e5580b (diff)
downloadllvm-f83e1f7f6681e02b8f6d661ade76ddf10d55fd40.zip
llvm-f83e1f7f6681e02b8f6d661ade76ddf10d55fd40.tar.gz
llvm-f83e1f7f6681e02b8f6d661ade76ddf10d55fd40.tar.bz2
[AlignmentFromAssumptions] Don't crash just because the target is 32-bit
We used to crash processing any relevant @llvm.assume on a 32-bit target (because we'd ask SE to subtract expressions of differing types). I've copied our 'simple.ll' test, but with the data layout from arm-linux-gnueabihf to get some meaningful test coverage here. llvm-svn: 217574
Diffstat (limited to 'llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp b/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
index 7ab16f1..06c3dfd 100644
--- a/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
+++ b/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
@@ -141,6 +141,10 @@ static unsigned getNewAlignment(const SCEV *AASCEV, const SCEV *AlignSCEV,
const SCEV *PtrSCEV = SE->getSCEV(Ptr);
const SCEV *DiffSCEV = SE->getMinusSCEV(PtrSCEV, AASCEV);
+ // On 32-bit platforms, DiffSCEV might now have type i32 -- we've always
+ // sign-extended OffSCEV to i64, so make sure they agree again.
+ DiffSCEV = SE->getNoopOrSignExtend(DiffSCEV, OffSCEV->getType());
+
// What we really want to know is the overall offset to the aligned
// address. This address is displaced by the provided offset.
DiffSCEV = SE->getMinusSCEV(DiffSCEV, OffSCEV);