[OpenMP] Fix mangling for linear parameters with negative stride
authorMike Rice <michael.p.rice@intel.com>
Wed, 11 May 2022 18:26:07 +0000 (11:26 -0700)
committerMike Rice <michael.p.rice@intel.com>
Wed, 11 May 2022 21:02:09 +0000 (14:02 -0700)
The 'n' character is used in place of '-' in the mangled name.

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

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

index 52f6ca4..f197c33 100644 (file)
@@ -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;
     }
 
index fa0be2a..573dbdb 100644 (file)
@@ -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