diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -11968,16 +11968,16 @@ llvm::Function *Fn) { ASTContext &C = CGM.getContext(); FD = FD->getMostRecentDecl(); - // Map params to their positions in function decl. - llvm::DenseMap ParamPositions; - if (isa(FD)) - ParamPositions.try_emplace(FD, 0); - unsigned ParamPos = ParamPositions.size(); - for (const ParmVarDecl *P : FD->parameters()) { - ParamPositions.try_emplace(P->getCanonicalDecl(), ParamPos); - ++ParamPos; - } while (FD) { + // Map params to their positions in function decl. + llvm::DenseMap ParamPositions; + if (isa(FD)) + ParamPositions.try_emplace(FD, 0); + unsigned ParamPos = ParamPositions.size(); + for (const ParmVarDecl *P : FD->parameters()) { + ParamPositions.try_emplace(P->getCanonicalDecl(), ParamPos); + ++ParamPos; + } for (const auto *Attr : FD->specific_attrs()) { llvm::SmallVector ParamAttrs(ParamPositions.size()); // Mark uniform parameters. @@ -11989,6 +11989,7 @@ } else { const auto *PVD = cast(cast(E)->getDecl()) ->getCanonicalDecl(); + assert(ParamPositions.find(PVD) != ParamPositions.end()); Pos = ParamPositions[PVD]; } ParamAttrs[Pos].Kind = Uniform; @@ -12005,6 +12006,7 @@ } else { const auto *PVD = cast(cast(E)->getDecl()) ->getCanonicalDecl(); + assert(ParamPositions.find(PVD) != ParamPositions.end()); Pos = ParamPositions[PVD]; ParmTy = PVD->getType(); } @@ -12030,6 +12032,7 @@ } else { const auto *PVD = cast(cast(E)->getDecl()) ->getCanonicalDecl(); + assert(ParamPositions.find(PVD) != ParamPositions.end()); Pos = ParamPositions[PVD]; if (auto *P = dyn_cast(PVD->getType())) PtrRescalingFactor = CGM.getContext() @@ -12048,6 +12051,8 @@ if (const auto *StridePVD = dyn_cast(DRE->getDecl())) { ParamAttr.Kind = LinearWithVarStride; + assert(ParamPositions.find(StridePVD->getCanonicalDecl()) != + ParamPositions.end()); ParamAttr.StrideOrArg = llvm::APSInt::getUnsigned( ParamPositions[StridePVD->getCanonicalDecl()]); } diff --git a/clang/test/OpenMP/declare_simd_codegen.cpp b/clang/test/OpenMP/declare_simd_codegen.cpp --- a/clang/test/OpenMP/declare_simd_codegen.cpp +++ b/clang/test/OpenMP/declare_simd_codegen.cpp @@ -153,6 +153,23 @@ // CHECK-DAG: "_ZGVdN4v__Z5add_1Pf" // CHECK-DAG: "_ZGVeN8v__Z5add_1Pf" +// CHECK-NOT: _ZGVbN2vv__Z5add_1Pf +// CHECK-NOT: _ZGVcN4vv__Z5add_1Pf +// CHECK-NOT: _ZGVdN4vv__Z5add_1Pf +// CHECK-NOT: _ZGVeN8vv__Z5add_1Pf +// CHECK-NOT: _ZGVbM32vv__Z5add_1Pf +// CHECK-NOT: _ZGVcM32vv__Z5add_1Pf +// CHECK-NOT: _ZGVdM32vv__Z5add_1Pf +// CHECK-NOT: _ZGVeM32vv__Z5add_1Pf +// CHECK-NOT: _ZGVbN4l32v__Z5add_1Pf +// CHECK-NOT: _ZGVcN8l32v__Z5add_1Pf +// CHECK-NOT: _ZGVdN8l32v__Z5add_1Pf +// CHECK-NOT: _ZGVeN16l32v__Z5add_1Pf +// CHECK-NOT: _ZGVbM4l32v__Z5add_1Pf +// CHECK-NOT: _ZGVcM8l32v__Z5add_1Pf +// CHECK-NOT: _ZGVdM8l32v__Z5add_1Pf +// CHECK-NOT: _ZGVeM16l32v__Z5add_1Pf + // CHECK-DAG: "_ZGVbM2va16va16vv__Z1hIiEvPT_S1_S1_S1_" // CHECK-DAG: "_ZGVbN2va16va16vv__Z1hIiEvPT_S1_S1_S1_" // CHECK-DAG: "_ZGVcM4va16va16vv__Z1hIiEvPT_S1_S1_S1_"