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 @@ -11939,16 +11939,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. @@ -11960,7 +11960,9 @@ } else { const auto *PVD = cast(cast(E)->getDecl()) ->getCanonicalDecl(); - Pos = ParamPositions[PVD]; + auto It = ParamPositions.find(PVD); + assert(It != ParamPositions.end() && "Function parameter not found"); + Pos = It->second; } ParamAttrs[Pos].Kind = Uniform; } @@ -11976,7 +11978,9 @@ } else { const auto *PVD = cast(cast(E)->getDecl()) ->getCanonicalDecl(); - Pos = ParamPositions[PVD]; + auto It = ParamPositions.find(PVD); + assert(It != ParamPositions.end() && "Function parameter not found"); + Pos = It->second; ParmTy = PVD->getType(); } ParamAttrs[Pos].Alignment = @@ -12000,7 +12004,9 @@ } else { const auto *PVD = cast(cast(E)->getDecl()) ->getCanonicalDecl(); - Pos = ParamPositions[PVD]; + auto It = ParamPositions.find(PVD); + assert(It != ParamPositions.end() && "Function parameter not found"); + Pos = It->second; if (auto *P = dyn_cast(PVD->getType())) PtrRescalingFactor = CGM.getContext() .getTypeSizeInChars(P->getPointeeType()) @@ -12018,8 +12024,10 @@ if (const auto *StridePVD = dyn_cast(DRE->getDecl())) { ParamAttr.Kind = LinearWithVarStride; - ParamAttr.StrideOrArg = llvm::APSInt::getUnsigned( - ParamPositions[StridePVD->getCanonicalDecl()]); + auto It = ParamPositions.find(StridePVD->getCanonicalDecl()); + assert(It != ParamPositions.end() && + "Function parameter not found"); + ParamAttr.StrideOrArg = llvm::APSInt::getUnsigned(It->second); } } } else { 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_"