This is an archive of the discontinued LLVM Phabricator instance.

Move GlobalTLSAddress handling to WebAssemblyISelLowering. NFC
ClosedPublic

Authored by sbc100 on Nov 13 2020, 8:33 AM.

Details

Summary

I'm not why it was added to DAGToDAG oringally but it seems
to make sense alongside the non-TLS version: LowerGlobalAddress

Diff Detail

Event Timeline

sbc100 created this revision.Nov 13 2020, 8:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 13 2020, 8:34 AM
sbc100 requested review of this revision.Nov 13 2020, 8:34 AM
sbc100 added a subscriber: tlively.Nov 13 2020, 8:39 AM

@tlively IIUC this is preferable?

Some of the APIs used at this level are slightly different but I'm pretty sure this is NFC.

Side note: When looking at this code compared to the PIC symbol references in the code below its interesting to me that we directly generate the global.get for the base address rather than relying on the pattern. i.e. we use DAG.getMachineNode(GlobalGet.. rather than SDValue BaseAddr = DAG.getNode(WebAssemblyISD::Wrapper. Is this bad or something we want to avoid?

Yes, this looks better than what we had before. I think it would be generally better to use TableGen patterns rather than generating the MachineNode directly in C++.

llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
126

I think this has a lowering hook in WebAssemblyISelLowering.cpp as well and could also be moved, although that could be a follow-up patch.

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
1315–1318

I think the pattern used down in the next method is more readable.

llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
355–359

IIUC, these aren't currently used because the lowering generates a MachineNode directly, right?

sbc100 added inline comments.Nov 13 2020, 11:37 AM
llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
355–359

No these are used. I don't generate the Const as MachineNodes, only the global get they get added to.

These two lines require these patterns:

SDValue TLSOffset = DAG.getTargetGlobalAddress(
     GV, DL, PtrVT, GA->getOffset(), WebAssemblyII::MO_TLS_BASE_REL);
 SDValue SymAddr = DAG.getNode(WebAssemblyISD::Wrapper, DL, PtrVT, TLSOffset);
tlively accepted this revision.Nov 13 2020, 12:22 PM
This revision is now accepted and ready to land.Nov 13 2020, 12:22 PM
This revision was landed with ongoing or failed builds.Nov 13 2020, 2:36 PM
This revision was automatically updated to reflect the committed changes.