From: Sam Clegg Date: Tue, 23 Apr 2019 03:43:26 +0000 (+0000) Subject: [WebAssembly] Bail out of fastisel earlier when computing PIC addresses X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=140d73388b16c16bf226e8a41c83f51e4b29c009;p=llvm [WebAssembly] Bail out of fastisel earlier when computing PIC addresses This change partially reverts https://reviews.llvm.org/D54647 in favor of bailing out during computeAddress instead. This catches the condition earlier and handles more cases. Differential Revision: https://reviews.llvm.org/D60986 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358948 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/WebAssembly/WebAssemblyFastISel.cpp b/lib/Target/WebAssembly/WebAssemblyFastISel.cpp index 2d9aae7a698..535a925c033 100644 --- a/lib/Target/WebAssembly/WebAssemblyFastISel.cpp +++ b/lib/Target/WebAssembly/WebAssemblyFastISel.cpp @@ -151,7 +151,7 @@ private: return MVT::INVALID_SIMPLE_VALUE_TYPE; } bool computeAddress(const Value *Obj, Address &Addr); - bool materializeLoadStoreOperands(Address &Addr); + void materializeLoadStoreOperands(Address &Addr); void addLoadStoreOperands(const Address &Addr, const MachineInstrBuilder &MIB, MachineMemOperand *MMO); unsigned maskI1Value(unsigned Reg, const Value *V); @@ -207,7 +207,6 @@ public: } // end anonymous namespace bool WebAssemblyFastISel::computeAddress(const Value *Obj, Address &Addr) { - const User *U = nullptr; unsigned Opcode = Instruction::UserOp1; if (const auto *I = dyn_cast(Obj)) { @@ -230,6 +229,8 @@ bool WebAssemblyFastISel::computeAddress(const Value *Obj, Address &Addr) { return false; if (const auto *GV = dyn_cast(Obj)) { + if (TLI.isPositionIndependent()) + return false; if (Addr.getGlobalValue()) return false; Addr.setGlobalValue(GV); @@ -374,13 +375,10 @@ bool WebAssemblyFastISel::computeAddress(const Value *Obj, Address &Addr) { return Addr.getReg() != 0; } -bool WebAssemblyFastISel::materializeLoadStoreOperands(Address &Addr) { +void WebAssemblyFastISel::materializeLoadStoreOperands(Address &Addr) { if (Addr.isRegBase()) { unsigned Reg = Addr.getReg(); if (Reg == 0) { - const GlobalValue *GV = Addr.getGlobalValue(); - if (GV && TLI.isPositionIndependent()) - return false; Reg = createResultReg(Subtarget->hasAddr64() ? &WebAssembly::I64RegClass : &WebAssembly::I32RegClass); unsigned Opc = Subtarget->hasAddr64() ? WebAssembly::CONST_I64 @@ -390,7 +388,6 @@ bool WebAssemblyFastISel::materializeLoadStoreOperands(Address &Addr) { Addr.setReg(Reg); } } - return true; } void WebAssemblyFastISel::addLoadStoreOperands(const Address &Addr, @@ -1190,8 +1187,7 @@ bool WebAssemblyFastISel::selectLoad(const Instruction *I) { return false; } - if (!materializeLoadStoreOperands(Addr)) - return false; + materializeLoadStoreOperands(Addr); unsigned ResultReg = createResultReg(RC); auto MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc), @@ -1243,8 +1239,7 @@ bool WebAssemblyFastISel::selectStore(const Instruction *I) { return false; } - if (!materializeLoadStoreOperands(Addr)) - return false; + materializeLoadStoreOperands(Addr); unsigned ValueReg = getRegForValue(Store->getValueOperand()); if (ValueReg == 0)