[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed May 29 10:52:06 PDT 2024


================
@@ -743,6 +743,20 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr &MTA) {
     CallerType.Func = CallerDecl->getType()->getAs<FunctionProtoType>();
   }
 
+  if (Context.getTargetInfo().getTriple().isPPC()) {
+    if (Context.getTargetInfo().getTriple().isOSAIX())
+      return Diag(St->getBeginLoc(), diag::err_aix_musttail_unsupported);
+    else if (!Context.getTargetInfo().hasFeature("pcrelative-memops")) {
+      if (Context.getTargetInfo().hasFeature("longcall"))
+        return Diag(St->getBeginLoc(), diag::err_ppc_impossible_musttail) << 0;
+      else if (!CE->getDirectCallee())
+        return Diag(St->getBeginLoc(), diag::err_ppc_impossible_musttail) << 1;
+      else if (isa_and_nonnull<FunctionDecl>(CE->getCalleeDecl()) &&
----------------
efriedma-quic wrote:

Just use the result of getDirectCallee() here.

I'm not sure isDefined() does what you want, for multiple reasons. One, the definition might be later in the file, and two, weak linkage makes "defining" a function a bit strange (e.g. C++ inline functions, or -fsemantic-interposition).

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


More information about the cfe-commits mailing list