[PATCH] D60986: [WebAssembly] Bail out of fastisel earlier when computing PIC addresses
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 22 17:01:07 PDT 2019
sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, hiraditya, jgravelle-google, dschuff.
Herald added a project: LLVM.
sbc100 added a reviewer: dschuff.
sbc100 added a comment.
I have a test case that this fixes, that I'm currently trying to reduce.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60986
Files:
llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
Index: llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
@@ -151,7 +151,7 @@
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 @@
} // 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<Instruction>(Obj)) {
@@ -230,6 +229,8 @@
return false;
if (const auto *GV = dyn_cast<GlobalValue>(Obj)) {
+ if (TLI.isPositionIndependent())
+ return false;
if (Addr.getGlobalValue())
return false;
Addr.setGlobalValue(GV);
@@ -374,13 +375,10 @@
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 @@
Addr.setReg(Reg);
}
}
- return true;
}
void WebAssemblyFastISel::addLoadStoreOperands(const Address &Addr,
@@ -1190,8 +1187,7 @@
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 @@
return false;
}
- if (!materializeLoadStoreOperands(Addr))
- return false;
+ materializeLoadStoreOperands(Addr);
unsigned ValueReg = getRegForValue(Store->getValueOperand());
if (ValueReg == 0)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60986.196160.patch
Type: text/x-patch
Size: 2458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190423/074a2bac/attachment.bin>
More information about the llvm-commits
mailing list