From af4903d6ee447c4dcc06ea6741d097746523b1dd Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 18 Jun 2010 20:44:47 +0000 Subject: [PATCH] Fix X86FastISel's address-mode folding to stay within the original basic block. This avoids trouble with examining instructions in other basic blocks which haven't been assigned registers yet. llvm-svn: 106310 --- llvm/lib/Target/X86/X86FastISel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index 7bbe6ab57517..cbdfd6484290 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -342,6 +342,12 @@ bool X86FastISel::X86SelectAddress(const Value *V, X86AddressMode &AM) { const User *U = NULL; unsigned Opcode = Instruction::UserOp1; if (const Instruction *I = dyn_cast(V)) { + // Don't walk into other basic blocks; it's possible we haven't + // visited them yet, so the instructions may not yet be assigned + // virtual registers. + if (MBBMap[I->getParent()] != MBB) + return false; + Opcode = I->getOpcode(); U = I; } else if (const ConstantExpr *C = dyn_cast(V)) {