From f83e1f7f6681e02b8f6d661ade76ddf10d55fd40 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Thu, 11 Sep 2014 08:40:17 +0000 Subject: [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 --- llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp') diff --git a/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp b/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp index 7ab16f13811..06c3dfdf637 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); -- cgit v1.2.3