Skip to content

Conversation

tbaederr
Copy link
Contributor

@tbaederr tbaederr commented Sep 3, 2025

Similar to what the current interpreter does.

Similar to what the current interpreter does.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Sep 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 3, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

Similar to what the current interpreter does.


Full diff: https://github.com/llvm/llvm-project/pull/156669.diff

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (+3)
  • (modified) clang/test/AST/ByteCode/openmp.cpp (+18-2)
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 2860a09ae6e2d..f15cb5ffa63b0 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -213,6 +213,9 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
     if (!Ptr.isZero() && !Ptr.isDereferencable())
       return false;
 
+    if (Ptr.pointsToStringLiteral() && Ptr.isArrayRoot())
+      return false;
+
     if (!Ptr.isZero() && !CheckFinalLoad(S, OpPC, Ptr))
       return false;
 
diff --git a/clang/test/AST/ByteCode/openmp.cpp b/clang/test/AST/ByteCode/openmp.cpp
index e05fbe086625c..15f10a2cd262c 100644
--- a/clang/test/AST/ByteCode/openmp.cpp
+++ b/clang/test/AST/ByteCode/openmp.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both -fopenmp %s
-// RUN: %clang_cc1 -verify=ref,both -fopenmp %s
+// RUN: %clang_cc1 -verify=expected,both -fopenmp -fopenmp-version=60 %s -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -verify=ref,both      -fopenmp -fopenmp-version=60 %s
 
 int test1() {
   int i;
@@ -11,3 +11,19 @@ int test1() {
   for (int i = 0; i < 10; ++i);
 }
 
+extern int omp_get_thread_num(void);
+
+#define N 64
+
+int test2() {
+  int x = 0;
+  int device_result[N] = {0};
+
+  #pragma omp target parallel loop num_threads(strict: N) severity(warning) message("msg")
+  for (int i = 0; i < N; i++) {
+    x = omp_get_thread_num();
+    device_result[i] = i + x;
+  }
+}
+
+

@tbaederr tbaederr merged commit 83ca877 into llvm:main Sep 4, 2025
13 checks passed
@shafik
Copy link
Collaborator

shafik commented Sep 5, 2025

What is an Itor cast?

@tbaederr
Copy link
Contributor Author

tbaederr commented Sep 5, 2025

It's a lowercase L. Short for lvalue-to-rvalue.

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

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants