[clang] [llvm] [SystemZ, Clang] Enable verification of int args extensions by default. (PR #223755)

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 05:17:10 PDT 2026


================
@@ -11451,30 +11451,31 @@ static void printFunctionArgExts(const Function *F, raw_fd_ostream &OS) {
   OS << ")\n";
 }
 
-bool SystemZTargetLowering::isInternal(const Function *Fn) const {
-  std::map<const Function *, bool>::iterator Itr = IsInternalCache.find(Fn);
-  if (Itr == IsInternalCache.end())
-    Itr = IsInternalCache
-              .insert(std::pair<const Function *, bool>(
-                  Fn, (Fn->hasLocalLinkage() && !Fn->hasAddressTaken())))
-              .first;
-  return Itr->second;
+bool SystemZTargetLowering::enableNarrowIntArgsVerification() const {
+  if (!Subtarget.isTargetELF())
+    return false;
+
+  if (EnableIntArgExtCheck.getNumOccurrences())
+    return EnableIntArgExtCheck;
+
+#ifdef NDEBUG
+  return false;
+#endif
+
+  return getTargetMachine().Options.VerifyArgABICompliance;
 }
 
 void SystemZTargetLowering::
 verifyNarrowIntegerArgs_Call(const SmallVectorImpl<ISD::OutputArg> &Outs,
                              const Function *F, SDValue Callee) const {
-  // Temporarily only do the check when explicitly requested, until it can be
-  // enabled by default.
-  if (!EnableIntArgExtCheck)
+  if (!enableNarrowIntArgsVerification())
     return;
-
-  bool IsInternal = false;
   const Function *CalleeFn = nullptr;
   if (auto *G = dyn_cast<GlobalAddressSDNode>(Callee))
-    if ((CalleeFn = dyn_cast<Function>(G->getGlobal())))
-      IsInternal = isInternal(CalleeFn);
-  if (!IsInternal && !verifyNarrowIntegerArgs(Outs)) {
+    CalleeFn = dyn_cast<Function>(G->getGlobal());
+  if (CalleeFn && CalleeFn->getCallingConv() != CallingConv::C)
+    return;
----------------
uweigand wrote:

I think we should use the calling convention at the call site (`CLI.CallingConv`) here.  This is also available for indirect calls.  (For direct calls, if this doesn't match the convention of the callee, we have bigger problems anyway ...)

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


More information about the llvm-commits mailing list