[PATCH] D55304: [RISCV, WIP] Lower calls through PLT

Lewis Revill via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 5 15:45:32 PST 2018


lewis-revill updated this revision to Diff 176889.
lewis-revill retitled this revision from "[RISCV, WIP] Lower calls through GOT and PLT" to "[RISCV, WIP] Lower calls through PLT".
lewis-revill edited the summary of this revision.
lewis-revill added a comment.

Removed capability of lowering through GOT since there is no apparent need to do so.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55304/new/

https://reviews.llvm.org/D55304

Files:
  lib/Target/RISCV/RISCVISelLowering.cpp
  lib/Target/RISCV/RISCVMCInstLower.cpp
  lib/Target/RISCV/Utils/RISCVBaseInfo.h


Index: lib/Target/RISCV/Utils/RISCVBaseInfo.h
===================================================================
--- lib/Target/RISCV/Utils/RISCVBaseInfo.h
+++ lib/Target/RISCV/Utils/RISCVBaseInfo.h
@@ -54,6 +54,7 @@
   MO_PCREL_LO,
   MO_PCREL_HI,
   MO_GOT_HI,
+  MO_PLT,
 };
 } // namespace RISCVII
 
Index: lib/Target/RISCV/RISCVMCInstLower.cpp
===================================================================
--- lib/Target/RISCV/RISCVMCInstLower.cpp
+++ lib/Target/RISCV/RISCVMCInstLower.cpp
@@ -52,6 +52,9 @@
   case RISCVII::MO_GOT_HI:
     Kind = RISCVMCExpr::VK_RISCV_GOT_HI;
     break;
+  case RISCVII::MO_PLT:
+    Kind = RISCVMCExpr::VK_RISCV_CALL_PLT;
+    break;
   }
 
   const MCExpr *ME =
Index: lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- lib/Target/RISCV/RISCVISelLowering.cpp
+++ lib/Target/RISCV/RISCVISelLowering.cpp
@@ -1462,9 +1462,21 @@
   // TargetGlobalAddress/TargetExternalSymbol node so that legalize won't
   // split it and then direct call can be matched by PseudoCALL.
   if (GlobalAddressSDNode *S = dyn_cast<GlobalAddressSDNode>(Callee)) {
-    Callee = DAG.getTargetGlobalAddress(S->getGlobal(), DL, PtrVT, 0, 0);
+    const GlobalValue *GV = S->getGlobal();
+
+    unsigned OpFlags = 0u;
+    if (!getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV))
+      OpFlags = RISCVII::MO_PLT;
+
+    Callee = DAG.getTargetGlobalAddress(GV, DL, PtrVT, 0, OpFlags);
   } else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) {
-    Callee = DAG.getTargetExternalSymbol(S->getSymbol(), PtrVT, 0);
+    unsigned OpFlags = 0u;
+
+    if (!getTargetMachine().shouldAssumeDSOLocal(*MF.getFunction().getParent(),
+                                                 nullptr))
+      OpFlags = RISCVII::MO_PLT;
+
+    Callee = DAG.getTargetExternalSymbol(S->getSymbol(), PtrVT, OpFlags);
   }
 
   // The first call operand is the chain and the second is the target address.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55304.176889.patch
Type: text/x-patch
Size: 1997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181205/cc738cef/attachment.bin>


More information about the llvm-commits mailing list