aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-06-02 21:29:13 +0000
committerDan Gohman <gohman@apple.com>2009-06-02 21:29:13 +0000
commit53dce4208418b8df00622e155e1866142f914c9a (patch)
treeb7138cc7197e2f084ffe51c3859f72b0803f7b8d /lib/Transforms/Scalar/CodeGenPrepare.cpp
parent2041d9a0ce2dc227707ea060e8fdce0553caa797 (diff)
downloadexternal_llvm-53dce4208418b8df00622e155e1866142f914c9a.zip
external_llvm-53dce4208418b8df00622e155e1866142f914c9a.tar.gz
external_llvm-53dce4208418b8df00622e155e1866142f914c9a.tar.bz2
Fix CodeGenPrepare's address-mode sinking to handle unusual
addresses, involving Base values which do not have Pointer type. This fixes PR4297. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72739 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/CodeGenPrepare.cpp')
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 342b1e5..42978e7 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -624,8 +624,11 @@ bool CodeGenPrepare::OptimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
// Add in the base register.
if (AddrMode.BaseReg) {
Value *V = AddrMode.BaseReg;
- if (V->getType() != IntPtrTy)
+ if (isa<PointerType>(V->getType()))
V = new PtrToIntInst(V, IntPtrTy, "sunkaddr", InsertPt);
+ if (V->getType() != IntPtrTy)
+ V = CastInst::CreateIntegerCast(V, IntPtrTy, /*isSigned=*/true,
+ "sunkaddr", InsertPt);
if (Result)
Result = BinaryOperator::CreateAdd(Result, V, "sunkaddr", InsertPt);
else