[clang] 772b0c4 - [OpenMP] Fix mangling for linear parameters with negative stride

Mike Rice via cfe-commits cfe-commits at lists.llvm.org
Wed May 11 14:02:56 PDT 2022


Author: Mike Rice
Date: 2022-05-11T14:02:09-07:00
New Revision: 772b0c44a4296a34cbc072c2a7cf294410d07a1a

URL: https://github.com/llvm/llvm-project/commit/772b0c44a4296a34cbc072c2a7cf294410d07a1a
DIFF: https://github.com/llvm/llvm-project/commit/772b0c44a4296a34cbc072c2a7cf294410d07a1a.diff

LOG: [OpenMP] Fix mangling for linear parameters with negative stride

The 'n' character is used in place of '-' in the mangled name.

Differential Revision: https://reviews.llvm.org/D125406

Added: 
    

Modified: 
    clang/lib/CodeGen/CGOpenMPRuntime.cpp
    clang/test/OpenMP/declare_simd_codegen.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 52f6ca4cfb3d0..f197c331e6cfc 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -11506,7 +11506,9 @@ static std::string mangleVectorParameters(ArrayRef<ParamAttrTy> ParamAttrs) {
              ParamAttr.Kind == LinearUVal || ParamAttr.Kind == LinearVal) {
       // Don't print the step value if it is not present or if it is
       // equal to 1.
-      if (ParamAttr.StrideOrArg != 1)
+      if (ParamAttr.StrideOrArg < 0)
+        Out << 'n' << -ParamAttr.StrideOrArg;
+      else if (ParamAttr.StrideOrArg != 1)
         Out << ParamAttr.StrideOrArg;
     }
 

diff  --git a/clang/test/OpenMP/declare_simd_codegen.cpp b/clang/test/OpenMP/declare_simd_codegen.cpp
index fa0be2acc192f..573dbdbfd69e9 100644
--- a/clang/test/OpenMP/declare_simd_codegen.cpp
+++ b/clang/test/OpenMP/declare_simd_codegen.cpp
@@ -155,6 +155,14 @@ double Five(int a, short &b, short &c, short &d, short &e, short &f, short &g,
   return a + int(b);
 }
 
+// Test negative strides
+#pragma omp declare simd simdlen(4) linear(a:-2) linear(b:-8) \
+                                    linear(uval(c):-4) linear(ref(d):-16) \
+                                    linear(e:-1) linear(f:-1) linear(g:0)
+double Six(int a, float *b, int &c, int *&d, char e, char *f, short g) {
+ return a + int(*b) + c + *d + e + *f + g;
+}
+
 // CHECK-DAG: define {{.+}}@_Z5add_1Pf(
 // CHECK-DAG: define {{.+}}@_Z1hIiEvPT_S1_S1_S1_(
 // CHECK-DAG: define {{.+}}@_Z1hIfEvPT_S1_S1_S1_(
@@ -178,6 +186,7 @@ double Five(int a, short &b, short &c, short &d, short &e, short &f, short &g,
 // CHECK-DAG: define {{.+}}@_Z5ThreeRiS_
 // CHECK-DAG: define {{.+}}@_Z4FourRiS_
 // CHECK-DAG: define {{.+}}@_Z4FiveiRsS_S_S_S_S_S_S_
+// CHECK-DAG: define {{.+}}@_Z3SixiPfRiRPicPcs
 
 // CHECK-DAG: "_ZGVbM4l32__Z5add_1Pf"
 // CHECK-DAG: "_ZGVbN4l32__Z5add_1Pf"
@@ -399,6 +408,8 @@ double Five(int a, short &b, short &c, short &d, short &e, short &f, short &g,
 // CHECK-DAG: "_ZGVbN4R8R4__Z4FourRiS_"
 // CHECK-DAG: "_ZGVbM4uL2Ls0L4Ls0U8Us0R32Rs0__Z4FiveiRsS_S_S_S_S_S_S_"
 // CHECK-DAG: "_ZGVbN4uL2Ls0L4Ls0U8Us0R32Rs0__Z4FiveiRsS_S_S_S_S_S_S_"
+// CHECK-DAG: "_ZGVbM4ln2ln32Un4Rn128ln1ln1l0__Z3SixiPfRiRPicPcs"
+// CHECK-DAG: "_ZGVbN4ln2ln32Un4Rn128ln1ln1l0__Z3SixiPfRiRPicPcs"
 
 // CHECK-NOT: "_ZGV{{.+}}__Z1fRA_i
 


        


More information about the cfe-commits mailing list