Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 4,076 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
template <class NodeTy> | template <class NodeTy> | ||||
SDValue RISCVTargetLowering::getAddr(NodeTy *N, SelectionDAG &DAG, | SDValue RISCVTargetLowering::getAddr(NodeTy *N, SelectionDAG &DAG, | ||||
bool IsLocal) const { | bool IsLocal) const { | ||||
SDLoc DL(N); | SDLoc DL(N); | ||||
EVT Ty = getPointerTy(DAG.getDataLayout()); | EVT Ty = getPointerTy(DAG.getDataLayout()); | ||||
if (isPositionIndependent()) { | // When HWASAN is used and tagging of global variables is enabled | ||||
// they should be accessed via the GOT, since the tagged address of a global | |||||
// is incompatible with existing code models. This also applies to non-pic | |||||
// mode. | |||||
if (isPositionIndependent() || Subtarget.allowTaggedGlobals()) { | |||||
SDValue Addr = getTargetNode(N, DL, Ty, DAG, 0); | SDValue Addr = getTargetNode(N, DL, Ty, DAG, 0); | ||||
luismarques: Ditto. | |||||
fixed, thanks smd: fixed, thanks | |||||
if (IsLocal) | if (IsLocal && !Subtarget.allowTaggedGlobals()) | ||||
// Use PC-relative addressing to access the symbol. This generates the | // Use PC-relative addressing to access the symbol. This generates the | ||||
// pattern (PseudoLLA sym), which expands to (addi (auipc %pcrel_hi(sym)) | // pattern (PseudoLLA sym), which expands to (addi (auipc %pcrel_hi(sym)) | ||||
// %pcrel_lo(auipc)). | // %pcrel_lo(auipc)). | ||||
return DAG.getNode(RISCVISD::LLA, DL, Ty, Addr); | return DAG.getNode(RISCVISD::LLA, DL, Ty, Addr); | ||||
// Use PC-relative addressing to access the GOT for this symbol, then load | // Use PC-relative addressing to access the GOT for this symbol, then load | ||||
// the address from the GOT. This generates the pattern (PseudoLA sym), | // the address from the GOT. This generates the pattern (PseudoLA sym), | ||||
// which expands to (ld (addi (auipc %got_pcrel_hi(sym)) %pcrel_lo(auipc))). | // which expands to (ld (addi (auipc %got_pcrel_hi(sym)) %pcrel_lo(auipc))). | ||||
▲ Show 20 Lines • Show All 9,019 Lines • Show Last 20 Lines |
Ditto.