[llvm] [RFC][RISCV] Support the large code model. (PR #70308)

Jessica Clarke via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 03:52:10 PDT 2024


================
@@ -17489,22 +17539,34 @@ SDValue RISCVTargetLowering::LowerCall(CallLoweringInfo &CLI,
   // If the callee is a GlobalAddress/ExternalSymbol node, turn it into a
   // 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)) {
-    const GlobalValue *GV = S->getGlobal();
+  if (getTargetMachine().getCodeModel() == CodeModel::Large) {
+    if (GlobalAddressSDNode *S = dyn_cast<GlobalAddressSDNode>(Callee)) {
+      Callee =
+          getLargeGlobalAddress(S, DL, getPointerTy(DAG.getDataLayout()), DAG);
+    } else if (ExternalSymbolSDNode *S =
+                   dyn_cast<ExternalSymbolSDNode>(Callee)) {
+      Callee =
+          getLargeExternalSymbol(S, DL, getPointerTy(DAG.getDataLayout()), DAG);
+    }
+  } else {
----------------
jrtc27 wrote:

Just use else if and avoid having to touch all the lines below by indenting them?

https://github.com/llvm/llvm-project/pull/70308


More information about the llvm-commits mailing list