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

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 23 22:34:03 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()) &&
----------------
chenzheng1030 wrote:

@efriedma-quic sorry for the delay. I've handled the forward declaration case in the new patch. Would you please help to have a look? Thanks very much.

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


More information about the llvm-commits mailing list