Author: Morris Hafner
Date: 2026-10-09T11:35:41+02:00
New Revision: 4bad635155fae1a5dfefc2ab97e52cba7a8cb2a0

URL: 
https://github.com/llvm/llvm-project/commit/4bad635155fae1a5dfefc2ab97e52cba7a8cb2a0
DIFF: 
https://github.com/llvm/llvm-project/commit/4bad635155fae1a5dfefc2ab97e52cba7a8cb2a0.diff

LOG: [CIR] Fix -fopenacc crash on functions without a declaration (#230338)

Functions that CIRGen create such as the atomic functions coming from
`createRuntimeFunction` have no declaration. These cannot have an
OpenACC routine decl. Check for the existence of a declaration first.

Co-authored-by: Claude Opus 5.5 <[email protected]>

Added: 
    

Modified: 
    clang/lib/CIR/CodeGen/CIRGenModule.cpp
    clang/test/CIR/CodeGen/builtin-atomic-is-lock-free.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 4d1a5ccaa0563..1f80f4e0ebf08 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -3744,7 +3744,7 @@ CIRGenModule::createCIRFunction(mlir::Location loc, 
StringRef name,
     // library entity.
     setFuncInfoAttr(func, funcDecl);
 
-    if (this->getLangOpts().OpenACC) {
+    if (funcDecl && this->getLangOpts().OpenACC) {
       // We only have to handle this attribute, since OpenACCAnnotAttrs are
       // handled via the end-of-TU work.
       for (const auto *attr :

diff  --git a/clang/test/CIR/CodeGen/builtin-atomic-is-lock-free.c 
b/clang/test/CIR/CodeGen/builtin-atomic-is-lock-free.c
index 2d13ec37a4c2a..5416f275eae8d 100644
--- a/clang/test/CIR/CodeGen/builtin-atomic-is-lock-free.c
+++ b/clang/test/CIR/CodeGen/builtin-atomic-is-lock-free.c
@@ -4,6 +4,8 @@
 // RUN: FileCheck --check-prefixes=LLVM,LLVMCIR --input-file=%t-cir.ll %s
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
 // RUN: FileCheck --check-prefixes=LLVM,OGCG --input-file=%t.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenacc -fclangir 
-emit-cir %s -o %t-acc.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t-acc.cir %s
 
 typedef struct { char buf[24]; } Big;
 


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to