[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 07:13:24 PDT 2024


================
@@ -9800,3 +9817,45 @@ SDValue SystemZTargetLowering::lowerVECREDUCE_ADD(SDValue Op,
       ISD::EXTRACT_VECTOR_ELT, DL, VT, DAG.getBitcast(OpVT, Op),
       DAG.getConstant(OpVT.getVectorNumElements() - 1, DL, MVT::i32));
 }
+
+// Only consider a function fully internal as long as it has local linkage
+// and is not used in any other way than acting as the called function at
+// call sites.  TODO: Remove this when/if all internal functions adhere to
+// the ABI.
+bool SystemZTargetLowering::isFullyInternal(const Function *Fn) const {
+  if (!Fn->hasLocalLinkage())
+    return false;
+  for (const User *U : Fn->users()) {
+    if (auto *CB = dyn_cast<CallBase>(U)) {
+      if (CB->getCalledFunction() != Fn)
+        return false;
+    } else
+      return false;
+  }
+  return true;
+}
+
+// Verify that narrow integer arguments are extended as required by the ABI.
+void SystemZTargetLowering::
+verifyNarrowIntegerArgs(const SmallVectorImpl<ISD::OutputArg> &Outs,
+                        bool IsInternal) const {
+  if (IsInternal || !Subtarget.isTargetELF())
+    return;
+
+  // Temporarily only do the check when explicitly requested.
+  if (/* !getTargetMachine().Options.VerifyArgABICompliance && */
----------------
nikic wrote:

Should have the TargetOptions check commented in even in this patch?

I think what you want to do is check getNumOccurrences() on the cl::opt and only use the value to override VerifyArgABICompliance if the option was explicitly passed.

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


More information about the cfe-commits mailing list