Skip to content

Conversation

@erichkeane
Copy link
Collaborator

The 'routine' construct just adds a acc.routine element to the global module, which contains all of the information about the directive. it contains a reference to the function, which also contains a reference to the acc.routine, which this generates.

This handles both the implicit-func version (where the routine is
spelled without parens, and just applies to the next function) and
the explicit-func version (where the routine is spelled with the func
name in parens).

The AST stores the directive in an OpenACCRoutineDeclAttr in the implicit case, so we can emit that when we hit the function declaration. The explicit case is held in an OpenACCRoutineAnnotAttr on the function, however, when we emit the function we haven't necessarily seen the construct yet, so we can't depend on that attribute. Instead, we save up the list in Sema so that we can emit them all at the end.

This results in the tests getting really hard to read (because ordering is a little awkward based on spelling, with no way to fix it), so we instead split the tests up based on topic.

One last thing: Flang spends some time determining if the clause lists of two routines on the same function are identical, and omits the duplicates. However, it seems to do a poor job on this when the ordering isn't the same, or references are slightly different. This patch doesn't bother trying that, and instead emits all, trusting the ACC dialect to remove duplicates/handle duplicates gracefully.

Note; This doesn't cause emission of functions that would otherwise not be emitted, but DOES emit routine references based on which function they are attached to.

The 'routine' construct just adds a acc.routine element to the global
module, which contains all of the information about the directive. it
contains a reference to the function, which also contains a reference to
the acc.routine, which this generates.

This handles both the implicit-func version (where the routine is
    spelled without parens, and just applies to the next function) and
the explicit-func version (where the routine is spelled with the func
    name in parens).

The AST stores the directive in an OpenACCRoutineDeclAttr in the
implicit case, so we can emit that when we hit the function declaration.
The explicit case is held in an OpenACCRoutineAnnotAttr on the
function, however, when we emit the function we haven't necessarily seen
the construct yet, so we can't depend on that attribute.  Instead, we
save up the list in Sema so that we can emit them all at the end.

This results in the tests getting really hard to read (because ordering
is a little awkward based on spelling, with no way to fix it), so we
instead split the tests up based on topic.

One last thing: Flang spends some time determining if the clause lists
of two routines on the same function are identical, and omits the
duplicates. However, it seems to do a poor job on this when the ordering
isn't the same, or references are slightly different.  This patch
doesn't bother trying that, and instead emits all, trusting the ACC
dialect to remove duplicates/handle duplicates gracefully.

Note; This doesn't cause emission of functions that would otherwise not
be emitted, but DOES emit routine references based on which function
they are attached to.
@llvmbot llvmbot added clang:frontend Language frontend issues, e.g. anything involving "Sema" mlir mlir:openacc openacc ClangIR Anything related to the ClangIR project labels Dec 1, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 1, 2025

@llvm/pr-subscribers-openacc
@llvm/pr-subscribers-clangir
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-openacc

Author: Erich Keane (erichkeane)

Changes

The 'routine' construct just adds a acc.routine element to the global module, which contains all of the information about the directive. it contains a reference to the function, which also contains a reference to the acc.routine, which this generates.

This handles both the implicit-func version (where the routine is
spelled without parens, and just applies to the next function) and
the explicit-func version (where the routine is spelled with the func
name in parens).

The AST stores the directive in an OpenACCRoutineDeclAttr in the implicit case, so we can emit that when we hit the function declaration. The explicit case is held in an OpenACCRoutineAnnotAttr on the function, however, when we emit the function we haven't necessarily seen the construct yet, so we can't depend on that attribute. Instead, we save up the list in Sema so that we can emit them all at the end.

This results in the tests getting really hard to read (because ordering is a little awkward based on spelling, with no way to fix it), so we instead split the tests up based on topic.

One last thing: Flang spends some time determining if the clause lists of two routines on the same function are identical, and omits the duplicates. However, it seems to do a poor job on this when the ordering isn't the same, or references are slightly different. This patch doesn't bother trying that, and instead emits all, trusting the ACC dialect to remove duplicates/handle duplicates gracefully.

Note; This doesn't cause emission of functions that would otherwise not be emitted, but DOES emit routine references based on which function they are attached to.


Patch is 36.58 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/170207.diff

20 Files Affected:

  • (modified) clang/include/clang/AST/ASTConsumer.h (+126-117)
  • (modified) clang/include/clang/CIR/CIRGenerator.h (+3)
  • (modified) clang/include/clang/Sema/SemaOpenACC.h (+9)
  • (modified) clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp (+75-2)
  • (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+9)
  • (modified) clang/lib/CIR/CodeGen/CIRGenModule.h (+6)
  • (modified) clang/lib/CIR/CodeGen/CIRGenerator.cpp (+12)
  • (modified) clang/lib/CIR/FrontendAction/CIRGenAction.cpp (+5)
  • (modified) clang/lib/Sema/Sema.cpp (+3)
  • (modified) clang/lib/Sema/SemaOpenACC.cpp (+17-6)
  • (removed) clang/test/CIR/CodeGenOpenACC/openacc-not-implemented-global.cpp (-6)
  • (added) clang/test/CIR/CodeGenOpenACC/routine-anon-ns.cpp (+27)
  • (added) clang/test/CIR/CodeGenOpenACC/routine-globals.cpp (+35)
  • (added) clang/test/CIR/CodeGenOpenACC/routine-globals2.cpp (+44)
  • (added) clang/test/CIR/CodeGenOpenACC/routine-locals.cpp (+24)
  • (added) clang/test/CIR/CodeGenOpenACC/routine-members.cpp (+55)
  • (added) clang/test/CIR/CodeGenOpenACC/routine-ns.cpp (+28)
  • (added) clang/test/CIR/CodeGenOpenACC/routine-templ.cpp (+16)
  • (modified) mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td (+3)
  • (modified) mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp (+6)
diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h
index 447f2592d2359..a0ef851226d77 100644
--- a/clang/include/clang/AST/ASTConsumer.h
+++ b/clang/include/clang/AST/ASTConsumer.h
@@ -27,123 +27,132 @@ namespace clang {
   class VarDecl;
   class FunctionDecl;
   class ImportDecl;
-
-/// ASTConsumer - This is an abstract interface that should be implemented by
-/// clients that read ASTs.  This abstraction layer allows the client to be
-/// independent of the AST producer (e.g. parser vs AST dump file reader, etc).
-class ASTConsumer {
-  /// Whether this AST consumer also requires information about
-  /// semantic analysis.
-  bool SemaConsumer = false;
-
-  friend class SemaConsumer;
-
-public:
-  ASTConsumer() = default;
-
-  virtual ~ASTConsumer() {}
-
-  /// Initialize - This is called to initialize the consumer, providing the
-  /// ASTContext.
-  virtual void Initialize(ASTContext &Context) {}
-
-  /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
-  /// called by the parser to process every top-level Decl*.
-  ///
-  /// \returns true to continue parsing, or false to abort parsing.
-  virtual bool HandleTopLevelDecl(DeclGroupRef D);
-
-  /// This callback is invoked each time an inline (method or friend)
-  /// function definition in a class is completed.
-  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
-
-  /// HandleInterestingDecl - Handle the specified interesting declaration. This
-  /// is called by the AST reader when deserializing things that might interest
-  /// the consumer. The default implementation forwards to HandleTopLevelDecl.
-  virtual void HandleInterestingDecl(DeclGroupRef D);
-
-  /// HandleTranslationUnit - This method is called when the ASTs for entire
-  /// translation unit have been parsed.
-  virtual void HandleTranslationUnit(ASTContext &Ctx) {}
-
-  /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
-  /// (e.g. struct, union, enum, class) is completed.  This allows the client to
-  /// hack on the type, which can occur at any point in the file (because these
-  /// can be defined in declspecs).
-  virtual void HandleTagDeclDefinition(TagDecl *D) {}
-
-  /// This callback is invoked the first time each TagDecl is required to
-  /// be complete.
-  virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {}
-
-  /// Invoked when a function is implicitly instantiated.
-  /// Note that at this point it does not have a body, its body is
-  /// instantiated at the end of the translation unit and passed to
-  /// HandleTopLevelDecl.
-  virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {}
-
-  /// Handle the specified top-level declaration that occurred inside
-  /// and ObjC container.
-  /// The default implementation ignored them.
-  virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
-
-  /// Handle an ImportDecl that was implicitly created due to an
-  /// inclusion directive.
-  /// The default implementation passes it to HandleTopLevelDecl.
-  virtual void HandleImplicitImportDecl(ImportDecl *D);
-
-  /// CompleteTentativeDefinition - Callback invoked at the end of a translation
-  /// unit to notify the consumer that the given tentative definition should be
-  /// completed.
-  ///
-  /// The variable declaration itself will be a tentative
-  /// definition. If it had an incomplete array type, its type will
-  /// have already been changed to an array of size 1. However, the
-  /// declaration remains a tentative definition and has not been
-  /// modified by the introduction of an implicit zero initializer.
-  virtual void CompleteTentativeDefinition(VarDecl *D) {}
-
-  /// CompleteExternalDeclaration - Callback invoked at the end of a translation
-  /// unit to notify the consumer that the given external declaration should be
-  /// completed.
-  virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {}
-
-  /// Callback invoked when an MSInheritanceAttr has been attached to a
-  /// CXXRecordDecl.
-  virtual void AssignInheritanceModel(CXXRecordDecl *RD) {}
-
-  /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
-  // variable has been instantiated.
-  virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {}
-
-  /// Callback involved at the end of a translation unit to
-  /// notify the consumer that a vtable for the given C++ class is
-  /// required.
-  ///
-  /// \param RD The class whose vtable was used.
-  virtual void HandleVTable(CXXRecordDecl *RD) {}
-
-  /// If the consumer is interested in entities getting modified after
-  /// their initial creation, it should return a pointer to
-  /// an ASTMutationListener here.
-  virtual ASTMutationListener *GetASTMutationListener() { return nullptr; }
-
-  /// If the consumer is interested in entities being deserialized from
-  /// AST files, it should return a pointer to a ASTDeserializationListener here
-  virtual ASTDeserializationListener *GetASTDeserializationListener() {
-    return nullptr;
-  }
-
-  /// PrintStats - If desired, print any statistics.
-  virtual void PrintStats() {}
-
-  /// This callback is called for each function if the Parser was
-  /// initialized with \c SkipFunctionBodies set to \c true.
-  ///
-  /// \return \c true if the function's body should be skipped. The function
-  /// body may be parsed anyway if it is needed (for instance, if it contains
-  /// the code completion point or is constexpr).
-  virtual bool shouldSkipFunctionBody(Decl *D) { return true; }
+  class OpenACCRoutineDecl;
+
+  /// ASTConsumer - This is an abstract interface that should be implemented by
+  /// clients that read ASTs.  This abstraction layer allows the client to be
+  /// independent of the AST producer (e.g. parser vs AST dump file reader,
+  /// etc).
+  class ASTConsumer {
+    /// Whether this AST consumer also requires information about
+    /// semantic analysis.
+    bool SemaConsumer = false;
+
+    friend class SemaConsumer;
+
+  public:
+    ASTConsumer() = default;
+
+    virtual ~ASTConsumer() {}
+
+    /// Initialize - This is called to initialize the consumer, providing the
+    /// ASTContext.
+    virtual void Initialize(ASTContext &Context) {}
+
+    /// HandleTopLevelDecl - Handle the specified top-level declaration.  This
+    /// is called by the parser to process every top-level Decl*.
+    ///
+    /// \returns true to continue parsing, or false to abort parsing.
+    virtual bool HandleTopLevelDecl(DeclGroupRef D);
+
+    /// This callback is invoked each time an inline (method or friend)
+    /// function definition in a class is completed.
+    virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
+
+    /// HandleInterestingDecl - Handle the specified interesting declaration.
+    /// This is called by the AST reader when deserializing things that might
+    /// interest the consumer. The default implementation forwards to
+    /// HandleTopLevelDecl.
+    virtual void HandleInterestingDecl(DeclGroupRef D);
+
+    /// HandleTranslationUnit - This method is called when the ASTs for entire
+    /// translation unit have been parsed.
+    virtual void HandleTranslationUnit(ASTContext &Ctx) {}
+
+    /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
+    /// (e.g. struct, union, enum, class) is completed.  This allows the client
+    /// to hack on the type, which can occur at any point in the file (because
+    /// these can be defined in declspecs).
+    virtual void HandleTagDeclDefinition(TagDecl *D) {}
+
+    /// This callback is invoked the first time each TagDecl is required to
+    /// be complete.
+    virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {}
+
+    /// Invoked when a function is implicitly instantiated.
+    /// Note that at this point it does not have a body, its body is
+    /// instantiated at the end of the translation unit and passed to
+    /// HandleTopLevelDecl.
+    virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {}
+
+    /// Handle the specified top-level declaration that occurred inside
+    /// and ObjC container.
+    /// The default implementation ignored them.
+    virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
+
+    /// Handle an ImportDecl that was implicitly created due to an
+    /// inclusion directive.
+    /// The default implementation passes it to HandleTopLevelDecl.
+    virtual void HandleImplicitImportDecl(ImportDecl *D);
+
+    /// CompleteTentativeDefinition - Callback invoked at the end of a
+    /// translation unit to notify the consumer that the given tentative
+    /// definition should be completed.
+    ///
+    /// The variable declaration itself will be a tentative
+    /// definition. If it had an incomplete array type, its type will
+    /// have already been changed to an array of size 1. However, the
+    /// declaration remains a tentative definition and has not been
+    /// modified by the introduction of an implicit zero initializer.
+    virtual void CompleteTentativeDefinition(VarDecl *D) {}
+
+    /// CompleteExternalDeclaration - Callback invoked at the end of a
+    /// translation unit to notify the consumer that the given external
+    /// declaration should be completed.
+    virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {}
+
+    /// Callback invoked when an MSInheritanceAttr has been attached to a
+    /// CXXRecordDecl.
+    virtual void AssignInheritanceModel(CXXRecordDecl *RD) {}
+
+    /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
+    // variable has been instantiated.
+    virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {}
+
+    /// Callback to handle the end-of-translation unit attachment of OpenACC
+    /// routine declaration information.
+    virtual void HandleOpenACCRoutineReference(const FunctionDecl *FD,
+                                               const OpenACCRoutineDecl *RD) {}
+
+    /// Callback involved at the end of a translation unit to
+    /// notify the consumer that a vtable for the given C++ class is
+    /// required.
+    ///
+    /// \param RD The class whose vtable was used.
+    virtual void HandleVTable(CXXRecordDecl *RD) {}
+
+    /// If the consumer is interested in entities getting modified after
+    /// their initial creation, it should return a pointer to
+    /// an ASTMutationListener here.
+    virtual ASTMutationListener *GetASTMutationListener() { return nullptr; }
+
+    /// If the consumer is interested in entities being deserialized from
+    /// AST files, it should return a pointer to a ASTDeserializationListener
+    /// here
+    virtual ASTDeserializationListener *GetASTDeserializationListener() {
+      return nullptr;
+    }
+
+    /// PrintStats - If desired, print any statistics.
+    virtual void PrintStats() {}
+
+    /// This callback is called for each function if the Parser was
+    /// initialized with \c SkipFunctionBodies set to \c true.
+    ///
+    /// \return \c true if the function's body should be skipped. The function
+    /// body may be parsed anyway if it is needed (for instance, if it contains
+    /// the code completion point or is constexpr).
+    virtual bool shouldSkipFunctionBody(Decl *D) { return true; }
 };
 
 } // end namespace clang.
diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h
index 5ea11463ffa9f..31dead2d7b585 100644
--- a/clang/include/clang/CIR/CIRGenerator.h
+++ b/clang/include/clang/CIR/CIRGenerator.h
@@ -81,6 +81,9 @@ class CIRGenerator : public clang::ASTConsumer {
   void HandleTagDeclDefinition(clang::TagDecl *d) override;
   void HandleTagDeclRequiredDefinition(const clang::TagDecl *D) override;
   void HandleCXXStaticMemberVarInstantiation(clang::VarDecl *D) override;
+  void
+  HandleOpenACCRoutineReference(const clang::FunctionDecl *FD,
+                                const clang::OpenACCRoutineDecl *RD) override;
   void CompleteTentativeDefinition(clang::VarDecl *d) override;
   void HandleVTable(clang::CXXRecordDecl *rd) override;
 
diff --git a/clang/include/clang/Sema/SemaOpenACC.h b/clang/include/clang/Sema/SemaOpenACC.h
index f751e985ae0ff..b5e3ecab36d22 100644
--- a/clang/include/clang/Sema/SemaOpenACC.h
+++ b/clang/include/clang/Sema/SemaOpenACC.h
@@ -37,8 +37,16 @@ class Scope;
 class SemaOpenACC : public SemaBase {
 public:
   using DeclGroupPtrTy = OpaquePtr<DeclGroupRef>;
+  using RoutineRefListTy = std::pair<FunctionDecl *, OpenACCRoutineDecl *>;
 
 private:
+  // We save a list of routine clauses that refer to a different function(that
+  // is, routine-with-a-name) so that we can do the emission at the 'end'.  We
+  // have to do this, since functions can be emitted before they are referenced,
+  // and the OpenACCRoutineDecl isn't necessarily emitted, as it might be in a
+  // function/etc. So we do these emits at the end of the TU.
+  llvm::SmallVector<RoutineRefListTy> RoutineRefList;
+
   struct ComputeConstructInfo {
     /// Which type of compute construct we are inside of, which we can use to
     /// determine whether we should add loops to the above collection.  We can
@@ -752,6 +760,7 @@ class SemaOpenACC : public SemaBase {
   };
 
   SemaOpenACC(Sema &S);
+  void ActOnEndOfTranslationUnit(TranslationUnitDecl *TU);
 
   // Called when we encounter a 'while' statement, before looking at its 'body'.
   void ActOnWhileStmt(SourceLocation WhileLoc);
diff --git a/clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp b/clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp
index d52986db49ea6..2a7bba4ca32e0 100644
--- a/clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp
@@ -287,9 +287,82 @@ void CIRGenModule::emitGlobalOpenACCDeclareDecl(const OpenACCDeclareDecl *d) {
 }
 
 void CIRGenFunction::emitOpenACCRoutine(const OpenACCRoutineDecl &d) {
-  getCIRGenModule().errorNYI(d.getSourceRange(), "OpenACC Routine Construct");
+  // Do nothing here. The OpenACCRoutineDeclAttr handles the implicit name
+  // cases, and the end-of-TU handling manages the named cases. This is
+  // necessary because these references aren't necessarily emitted themselves,
+  // but can be named anywhere.
 }
 
 void CIRGenModule::emitGlobalOpenACCRoutineDecl(const OpenACCRoutineDecl *d) {
-  errorNYI(d->getSourceRange(), "OpenACC Global Routine Construct");
+  // Do nothing here. The OpenACCRoutineDeclAttr handles the implicit name
+  // cases, and the end-of-TU handling manages the named cases. This is
+  // necessary because these references aren't necessarily emitted themselves,
+  // but can be named anywhere.
+}
+
+namespace {
+class OpenACCRoutineClauseEmitter final
+    : public OpenACCClauseVisitor<OpenACCRoutineClauseEmitter> {
+  CIRGen::CIRGenBuilderTy &builder;
+  mlir::acc::RoutineOp routineOp;
+  llvm::SmallVector<mlir::acc::DeviceType> lastDeviceTypeValues;
+
+public:
+  OpenACCRoutineClauseEmitter(CIRGen::CIRGenBuilderTy &builder,
+                              mlir::acc::RoutineOp routineOp)
+      : builder(builder), routineOp(routineOp) {}
+
+  void emitClauses(ArrayRef<const OpenACCClause *> clauses) {
+    this->VisitClauseList(clauses);
+  }
+
+  void VisitClause(const OpenACCClause &clause) {
+    llvm_unreachable("Invalid OpenACC clause on routine");
+  }
+
+  void VisitSeqClause(const OpenACCSeqClause &clause) {
+    routineOp.addSeq(builder.getContext(), lastDeviceTypeValues);
+  }
+};
+} // namespace
+
+void CIRGenModule::emitOpenACCRoutineDecl(
+    const clang::FunctionDecl *funcDecl, cir::FuncOp func,
+    SourceLocation pragmaLoc, ArrayRef<const OpenACCClause *> clauses) {
+  mlir::OpBuilder::InsertionGuard guardCase(builder);
+  // These need to appear at the global module.
+  builder.setInsertionPointToEnd(&getModule().getBodyRegion().front());
+
+  mlir::Location routineLoc = getLoc(pragmaLoc);
+
+  std::stringstream routineNameSS;
+  // This follows the same naming format as Flang.
+  routineNameSS << "acc_routine_" << routineCounter++;
+  std::string routineName = routineNameSS.str();
+
+  // There isn't a good constructor for RoutineOp that just takes a location +
+  // name + function, so we use one that creates an otherwise RoutineOp and
+  // count on the visitor/emitter to fill these in.
+  auto routineOp = mlir::acc::RoutineOp::create(
+      builder, routineLoc, routineName,
+      mlir::SymbolRefAttr::get(builder.getContext(), func.getName()), {}, {},
+      {}, {}, {}, {}, {}, /*hasNoHost=*/false, /*implicit=*/false, {}, {}, {});
+
+  // We have to add a pointer going the other direction via an acc.routine_info,
+  // from the func to the routine.
+  llvm::SmallVector<mlir::SymbolRefAttr> funcRoutines;
+  if (auto routineInfo =
+          func.getOperation()->getAttrOfType<mlir::acc::RoutineInfoAttr>(
+              mlir::acc::getRoutineInfoAttrName()))
+    funcRoutines.append(routineInfo.getAccRoutines().begin(),
+                        routineInfo.getAccRoutines().end());
+
+  funcRoutines.push_back(
+      mlir::SymbolRefAttr::get(builder.getContext(), routineName));
+  func.getOperation()->setAttr(
+      mlir::acc::getRoutineInfoAttrName(),
+      mlir::acc::RoutineInfoAttr::get(func.getContext(), funcRoutines));
+
+  OpenACCRoutineClauseEmitter emitter{builder, routineOp};
+  emitter.emitClauses(clauses);
 }
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 809c24f8aa670..df8b053f07915 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -2234,6 +2234,15 @@ CIRGenModule::createCIRFunction(mlir::Location loc, StringRef name,
 
     if (!cgf)
       theModule.push_back(func);
+
+    if (this->getLangOpts().OpenACC) {
+      // We only have to handle this attribute, since OpenACCAnnotAttrs are
+      // handled via the end-of-TU work.
+      for (const auto *attr :
+           funcDecl->specific_attrs<OpenACCRoutineDeclAttr>())
+        emitOpenACCRoutineDecl(funcDecl, func, attr->getLocation(),
+                               attr->Clauses);
+    }
   }
   return func;
 }
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.h b/clang/lib/CIR/CodeGen/CIRGenModule.h
index 6600d086f8f61..d7aee8ebf4d7a 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.h
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.h
@@ -461,6 +461,12 @@ class CIRGenModule : public CIRGenTypeCache {
                                             OpenACCModifierKind modifiers,
                                             bool structured, bool implicit,
                                             bool requiresDtor);
+  // Each of the acc.routine operations must have a unique name, so we just use
+  // an integer counter.  This is how Flang does it, so it seems reasonable.
+  unsigned routineCounter = 0;
+  void emitOpenACCRoutineDecl(const clang::FunctionDecl *funcDecl,
+                              cir::FuncOp func, SourceLocation pragmaLoc,
+                              ArrayRef<const OpenACCClause *> clauses);
 
   // C++ related functions.
   void emitDeclContext(const DeclContext *dc);
diff --git a/clang/lib/CIR/CodeGen/CIRGenerator.cpp b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
index aa4d9eba35c04..0208eeea7146a 100644
--- a/clang/lib/CIR/CodeGen/CIRGenerator.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
@@ -166,6 +166,18 @@ void CIRGenerator::HandleCXXStaticMemberVarInstantiation(VarDecl *D) {
   cgm->handleCXXStaticMemberVarInstantiation(D);
 }
 
+void CIRGenerator::HandleOpenACCRoutineReference(const FunctionDecl *FD,
+                                                 const OpenACCRoutineDecl *RD) {
+  llvm::StringRef mangledName = cgm->getMangledName(FD);
+  cir::FuncOp entry =
+      mlir::dyn_cast_if_present<cir::FuncOp>(cgm->getGlobalValue(mangledName));
+
+  // if this wasn't generated, don't force it to be.
+  if (!entry)
+    return;
+  cgm->emitOpenACCRoutineDecl(FD, entry, RD->getBeginLoc(), RD->clauses());
+}
+
 void CIRGenerator::CompleteTentativeDefinition(VarDecl *d) {
   if (diags.hasErrorOccurred())
     return;
diff --git a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
index 67bb5657d4001..daec8ae409e0f 100644
--- a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
+++ b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
@@ -88,6 +88,11 @@ class CIRGenConsumer : public clang::ASTConsumer {
     Gen->HandleCXXStaticMemberVarInstantiation(V...
[truncated]

FD->addAttr(RAA);
}
// the attribute to all declarations after the 'found' one.
for (auto *CurFD : FD->redecls())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what sort of nonsense I was trying at before. But this should do what I ACTUALLY meant to do.

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions h,cpp -- clang/test/CIR/CodeGenOpenACC/routine-anon-ns.cpp clang/test/CIR/CodeGenOpenACC/routine-globals.cpp clang/test/CIR/CodeGenOpenACC/routine-globals2.cpp clang/test/CIR/CodeGenOpenACC/routine-locals.cpp clang/test/CIR/CodeGenOpenACC/routine-members.cpp clang/test/CIR/CodeGenOpenACC/routine-ns.cpp clang/test/CIR/CodeGenOpenACC/routine-templ.cpp clang/include/clang/AST/ASTConsumer.h clang/include/clang/CIR/CIRGenerator.h clang/include/clang/Sema/SemaOpenACC.h clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp clang/lib/CIR/CodeGen/CIRGenModule.cpp clang/lib/CIR/CodeGen/CIRGenModule.h clang/lib/CIR/CodeGen/CIRGenerator.cpp clang/lib/CIR/FrontendAction/CIRGenAction.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaOpenACC.cpp mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h
index a1ef187ee..002ba8aab 100644
--- a/clang/include/clang/AST/ASTConsumer.h
+++ b/clang/include/clang/AST/ASTConsumer.h
@@ -29,128 +29,131 @@ namespace clang {
   class ImportDecl;
   class OpenACCRoutineDecl;
 
-/// ASTConsumer - This is an abstract interface that should be implemented by
-/// clients that read ASTs.  This abstraction layer allows the client to be
-/// independent of the AST producer (e.g. parser vs AST dump file reader, etc).
-class ASTConsumer {
-  /// Whether this AST consumer also requires information about
-  /// semantic analysis.
-  bool SemaConsumer = false;
-
-  friend class SemaConsumer;
-
-public:
-  ASTConsumer() = default;
-
-  virtual ~ASTConsumer() {}
-
-  /// Initialize - This is called to initialize the consumer, providing the
-  /// ASTContext.
-  virtual void Initialize(ASTContext &Context) {}
-
-  /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
-  /// called by the parser to process every top-level Decl*.
-  ///
-  /// \returns true to continue parsing, or false to abort parsing.
-  virtual bool HandleTopLevelDecl(DeclGroupRef D);
-
-  /// This callback is invoked each time an inline (method or friend)
-  /// function definition in a class is completed.
-  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
-
-  /// HandleInterestingDecl - Handle the specified interesting declaration. This
-  /// is called by the AST reader when deserializing things that might interest
-  /// the consumer. The default implementation forwards to HandleTopLevelDecl.
-  virtual void HandleInterestingDecl(DeclGroupRef D);
-
-  /// HandleTranslationUnit - This method is called when the ASTs for entire
-  /// translation unit have been parsed.
-  virtual void HandleTranslationUnit(ASTContext &Ctx) {}
-
-  /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
-  /// (e.g. struct, union, enum, class) is completed.  This allows the client to
-  /// hack on the type, which can occur at any point in the file (because these
-  /// can be defined in declspecs).
-  virtual void HandleTagDeclDefinition(TagDecl *D) {}
-
-  /// This callback is invoked the first time each TagDecl is required to
-  /// be complete.
-  virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {}
-
-  /// Invoked when a function is implicitly instantiated.
-  /// Note that at this point it does not have a body, its body is
-  /// instantiated at the end of the translation unit and passed to
-  /// HandleTopLevelDecl.
-  virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {}
-
-  /// Handle the specified top-level declaration that occurred inside
-  /// and ObjC container.
-  /// The default implementation ignored them.
-  virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
-
-  /// Handle an ImportDecl that was implicitly created due to an
-  /// inclusion directive.
-  /// The default implementation passes it to HandleTopLevelDecl.
-  virtual void HandleImplicitImportDecl(ImportDecl *D);
-
-  /// CompleteTentativeDefinition - Callback invoked at the end of a translation
-  /// unit to notify the consumer that the given tentative definition should be
-  /// completed.
-  ///
-  /// The variable declaration itself will be a tentative
-  /// definition. If it had an incomplete array type, its type will
-  /// have already been changed to an array of size 1. However, the
-  /// declaration remains a tentative definition and has not been
-  /// modified by the introduction of an implicit zero initializer.
-  virtual void CompleteTentativeDefinition(VarDecl *D) {}
-
-  /// CompleteExternalDeclaration - Callback invoked at the end of a translation
-  /// unit to notify the consumer that the given external declaration should be
-  /// completed.
-  virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {}
-
-  /// Callback invoked when an MSInheritanceAttr has been attached to a
-  /// CXXRecordDecl.
-  virtual void AssignInheritanceModel(CXXRecordDecl *RD) {}
-
-  /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
-  // variable has been instantiated.
-  virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {}
-
-  /// Callback to handle the end-of-translation unit attachment of OpenACC
-  /// routine declaration information.
-  virtual void HandleOpenACCRoutineReference(const FunctionDecl *FD,
-                                             const OpenACCRoutineDecl *RD) {}
-
-  /// Callback involved at the end of a translation unit to
-  /// notify the consumer that a vtable for the given C++ class is
-  /// required.
-  ///
-  /// \param RD The class whose vtable was used.
-  virtual void HandleVTable(CXXRecordDecl *RD) {}
-
-  /// If the consumer is interested in entities getting modified after
-  /// their initial creation, it should return a pointer to
-  /// an ASTMutationListener here.
-  virtual ASTMutationListener *GetASTMutationListener() { return nullptr; }
-
-  /// If the consumer is interested in entities being deserialized from
-  /// AST files, it should return a pointer to a ASTDeserializationListener here
-  virtual ASTDeserializationListener *GetASTDeserializationListener() {
-    return nullptr;
-  }
-
-  /// PrintStats - If desired, print any statistics.
-  virtual void PrintStats() {}
-
-  /// This callback is called for each function if the Parser was
-  /// initialized with \c SkipFunctionBodies set to \c true.
-  ///
-  /// \return \c true if the function's body should be skipped. The function
-  /// body may be parsed anyway if it is needed (for instance, if it contains
-  /// the code completion point or is constexpr).
-  virtual bool shouldSkipFunctionBody(Decl *D) { return true; }
-};
+  /// ASTConsumer - This is an abstract interface that should be implemented by
+  /// clients that read ASTs.  This abstraction layer allows the client to be
+  /// independent of the AST producer (e.g. parser vs AST dump file reader,
+  /// etc).
+  class ASTConsumer {
+    /// Whether this AST consumer also requires information about
+    /// semantic analysis.
+    bool SemaConsumer = false;
+
+    friend class SemaConsumer;
+
+  public:
+    ASTConsumer() = default;
+
+    virtual ~ASTConsumer() {}
+
+    /// Initialize - This is called to initialize the consumer, providing the
+    /// ASTContext.
+    virtual void Initialize(ASTContext &Context) {}
+
+    /// HandleTopLevelDecl - Handle the specified top-level declaration.  This
+    /// is called by the parser to process every top-level Decl*.
+    ///
+    /// \returns true to continue parsing, or false to abort parsing.
+    virtual bool HandleTopLevelDecl(DeclGroupRef D);
+
+    /// This callback is invoked each time an inline (method or friend)
+    /// function definition in a class is completed.
+    virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
+
+    /// HandleInterestingDecl - Handle the specified interesting declaration.
+    /// This is called by the AST reader when deserializing things that might
+    /// interest the consumer. The default implementation forwards to
+    /// HandleTopLevelDecl.
+    virtual void HandleInterestingDecl(DeclGroupRef D);
+
+    /// HandleTranslationUnit - This method is called when the ASTs for entire
+    /// translation unit have been parsed.
+    virtual void HandleTranslationUnit(ASTContext &Ctx) {}
+
+    /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
+    /// (e.g. struct, union, enum, class) is completed.  This allows the client
+    /// to hack on the type, which can occur at any point in the file (because
+    /// these can be defined in declspecs).
+    virtual void HandleTagDeclDefinition(TagDecl *D) {}
+
+    /// This callback is invoked the first time each TagDecl is required to
+    /// be complete.
+    virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {}
+
+    /// Invoked when a function is implicitly instantiated.
+    /// Note that at this point it does not have a body, its body is
+    /// instantiated at the end of the translation unit and passed to
+    /// HandleTopLevelDecl.
+    virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {}
+
+    /// Handle the specified top-level declaration that occurred inside
+    /// and ObjC container.
+    /// The default implementation ignored them.
+    virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
+
+    /// Handle an ImportDecl that was implicitly created due to an
+    /// inclusion directive.
+    /// The default implementation passes it to HandleTopLevelDecl.
+    virtual void HandleImplicitImportDecl(ImportDecl *D);
+
+    /// CompleteTentativeDefinition - Callback invoked at the end of a
+    /// translation unit to notify the consumer that the given tentative
+    /// definition should be completed.
+    ///
+    /// The variable declaration itself will be a tentative
+    /// definition. If it had an incomplete array type, its type will
+    /// have already been changed to an array of size 1. However, the
+    /// declaration remains a tentative definition and has not been
+    /// modified by the introduction of an implicit zero initializer.
+    virtual void CompleteTentativeDefinition(VarDecl *D) {}
+
+    /// CompleteExternalDeclaration - Callback invoked at the end of a
+    /// translation unit to notify the consumer that the given external
+    /// declaration should be completed.
+    virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {}
+
+    /// Callback invoked when an MSInheritanceAttr has been attached to a
+    /// CXXRecordDecl.
+    virtual void AssignInheritanceModel(CXXRecordDecl *RD) {}
+
+    /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
+    // variable has been instantiated.
+    virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {}
+
+    /// Callback to handle the end-of-translation unit attachment of OpenACC
+    /// routine declaration information.
+    virtual void HandleOpenACCRoutineReference(const FunctionDecl *FD,
+                                               const OpenACCRoutineDecl *RD) {}
+
+    /// Callback involved at the end of a translation unit to
+    /// notify the consumer that a vtable for the given C++ class is
+    /// required.
+    ///
+    /// \param RD The class whose vtable was used.
+    virtual void HandleVTable(CXXRecordDecl *RD) {}
+
+    /// If the consumer is interested in entities getting modified after
+    /// their initial creation, it should return a pointer to
+    /// an ASTMutationListener here.
+    virtual ASTMutationListener *GetASTMutationListener() { return nullptr; }
+
+    /// If the consumer is interested in entities being deserialized from
+    /// AST files, it should return a pointer to a ASTDeserializationListener
+    /// here
+    virtual ASTDeserializationListener *GetASTDeserializationListener() {
+      return nullptr;
+    }
+
+    /// PrintStats - If desired, print any statistics.
+    virtual void PrintStats() {}
+
+    /// This callback is called for each function if the Parser was
+    /// initialized with \c SkipFunctionBodies set to \c true.
+    ///
+    /// \return \c true if the function's body should be skipped. The function
+    /// body may be parsed anyway if it is needed (for instance, if it contains
+    /// the code completion point or is constexpr).
+    virtual bool shouldSkipFunctionBody(Decl *D) { return true; }
+  };
 
 } // end namespace clang.
 

@erichkeane
Copy link
Collaborator Author

I'm not going to fix that clang-format failure, clang-format wants me to re-format that entire file, which I very much should not be doing. Please disregard it :)

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

🐧 Linux x64 Test Results

  • 119683 tests passed
  • 4685 tests skipped

✅ The build succeeded and all tests passed.

Copy link
Contributor

@razvanlupusoru razvanlupusoru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me!

Regarding the testing, one aspect I noticed, is that all of the tests exercise with "seq" only. I wanted to point out that omission of "seq" when the user does not specify it is important (and your current implementation seems correct since it only emits this in explicit cases). Lack of seq (or any other explicit parallelism marking) is useful to ensure that compiler can automatically determine parallelism.

routineNameSS << "acc_routine_" << routineCounter++;
std::string routineName = routineNameSS.str();

// There isn't a good constructor for RoutineOp that just takes a location +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome to add it! :) Seems useful to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I'll do so! I'll have to see what infra is around to do that.

@erichkeane
Copy link
Collaborator Author

Looks great to me!

Regarding the testing, one aspect I noticed, is that all of the tests exercise with "seq" only. I wanted to point out that omission of "seq" when the user does not specify it is important (and your current implementation seems correct since it only emits this in explicit cases). Lack of seq (or any other explicit parallelism marking) is useful to ensure that compiler can automatically determine parallelism.

Yes, I've only emitted 'seq' so far. The standard requires exactly 1 of gang, worker, vector or seq, which the CFE requires (which is why I required 1 here), so we'll set ONE of those.

As far as automatically determine parallelism, we can relax the Sema check in the future, at which point this would set nothing.

@erichkeane
Copy link
Collaborator Author

@razvanlupusoru : I've implemented the overload for RoutineOp::create, let me know what you think!

@razvanlupusoru
Copy link
Contributor

@razvanlupusoru : I've implemented the overload for RoutineOp::create, let me know what you think!

Looks great - thank you!

Copy link
Contributor

@andykaylor andykaylor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@erichkeane erichkeane merged commit 6dd639e into llvm:main Dec 2, 2025
9 of 10 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 2, 2025

LLVM Buildbot has detected a new failure on builder clang-m68k-linux-cross running on suse-gary-m68k-cross while building clang,mlir at step 4 "build stage 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/19746

Here is the relevant piece of the build log for the reference
Step 4 (build stage 1) failure: 'ninja' (failure)
...
[36/456] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ASTMerge.cpp.o
[37/456] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/FrontendActions.cpp.o
[38/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateDeductionGuide.cpp.o
[39/456] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ASTUnit.cpp.o
[40/456] Building CXX object tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/IndexBody.cpp.o
[41/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaType.cpp.o
[42/456] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/InterfaceStubFunctionsConsumer.cpp.o
[43/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaSYCL.cpp.o
[44/456] Building CXX object tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/IndexingContext.cpp.o
[45/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateInstantiate.cpp.o
FAILED: tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateInstantiate.cpp.o 
/usr/bin/c++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/lib/Sema -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/lib/Sema -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-dangling-reference -Wno-redundant-move -Wno-pessimizing-move -Wno-array-bounds -Wno-stringop-overread -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateInstantiate.cpp.o -MF tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateInstantiate.cpp.o.d -o tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateInstantiate.cpp.o -c /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/lib/Sema/SemaTemplateInstantiate.cpp
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
[46/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/Execution.cpp.o
[47/456] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/PrecompiledPreamble.cpp.o
[48/456] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/TextDiagnostics.cpp.o
[49/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/GuessTargetAndModeCompilationDatabase.cpp.o
[50/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclObjC.cpp.o
[51/456] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/FrontendAction.cpp.o
[52/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/AllTUsExecution.cpp.o
[53/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/CommonOptionsParser.cpp.o
[54/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/ExpandResponseFilesCompilationDatabase.cpp.o
[55/456] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/PlistDiagnostics.cpp.o
[56/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/CompilationDatabase.cpp.o
[57/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/JSONCompilationDatabase.cpp.o
[58/456] Building CXX object tools/clang/lib/ASTMatchers/CMakeFiles/obj.clangASTMatchers.dir/ASTMatchFinder.cpp.o
[59/456] Building CXX object tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/IndexTypeSourceInfo.cpp.o
[60/456] Building CXX object tools/clang/lib/CrossTU/CMakeFiles/obj.clangCrossTU.dir/CrossTranslationUnit.cpp.o
[61/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/Refactoring.cpp.o
[62/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/StandaloneExecution.cpp.o
[63/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/Tooling.cpp.o
[64/456] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CompilerInstance.cpp.o
[65/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/LocateToolCompilationDatabase.cpp.o
[66/456] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/RefactoringCallbacks.cpp.o
[67/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDecl.cpp.o
[68/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateDeduction.cpp.o
[69/456] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ChainedIncludesSource.cpp.o
[70/456] Building CXX object tools/clang/lib/Tooling/Refactoring/CMakeFiles/obj.clangToolingRefactoring.dir/AtomicChange.cpp.o
[71/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateInstantiateDecl.cpp.o
[72/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclCXX.cpp.o
[73/456] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
[74/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaConcept.cpp.o
[75/456] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplate.cpp.o
In file included from /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/lib/Sema/TreeTransform.h:48,
                 from /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/lib/Sema/SemaTemplate.cpp:11:
In constructor ‘clang::LocalInstantiationScope::LocalInstantiationScope(clang::Sema&, bool, bool)’,
    inlined from ‘bool clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::TemplateParameterList*, clang::SourceLocation, clang::TemplateArgumentListInfo&, const clang::DefaultArguments&, bool, CheckTemplateArgumentInfo&, bool, bool*)’ at /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/lib/Sema/SemaTemplate.cpp:6189:48:
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include/clang/Sema/Template.h:442:41: warning: storing the address of local variable ‘InstScope’ in ‘*this.clang::Sema::CurrentInstantiationScope’ [-Wdangling-pointer=]

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 2, 2025

LLVM Buildbot has detected a new failure on builder clang-x86_64-linux-abi-test running on sie-linux-worker2 while building clang,mlir at step 6 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/8/builds/24255

Here is the relevant piece of the build log for the reference
Step 6 (build-unified-tree) failure: build (failure)
...
262.072 [2913/10/4524] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGOpenCLRuntime.cpp.o
262.150 [2912/10/4525] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGOpenMPRuntime.cpp.o
262.222 [2911/10/4526] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGOpenMPRuntimeGPU.cpp.o
262.290 [2910/10/4527] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGPointerAuth.cpp.o
262.361 [2909/10/4528] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGRecordLayoutBuilder.cpp.o
262.436 [2908/10/4529] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGStmt.cpp.o
262.510 [2907/10/4530] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGStmtOpenMP.cpp.o
262.571 [2906/10/4531] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGVTT.cpp.o
262.628 [2905/10/4532] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGVTables.cpp.o
262.703 [2904/10/4533] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenABITypes.cpp.o
command timed out: 1200 seconds without output running [b'ninja'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=2789.697653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" ClangIR Anything related to the ClangIR project mlir:openacc mlir openacc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants