1717#include " compat/CallSite.h"
1818#include " support/DefUseChain.h"
1919#include " support/OmpUtil.h"
20+ #include " support/Util.h"
2021
2122#include " llvm/IR/Function.h"
2223#include " llvm/IR/Instructions.h"
@@ -37,31 +38,31 @@ struct OmpContext {
3738 const auto called = c.getCalledFunction ();
3839 if (called != nullptr ) {
3940 // TODO probably not complete (openmp task?, see isOmpTask*())
40- return called->getName (). startswith ( " __kmpc_fork_call" );
41+ return util::starts_with_any_of ( called->getName (), " __kmpc_fork_call" );
4142 }
4243 return false ;
4344 }
4445
4546 static bool isOmpTaskAlloc (const llvm::CallSite& c) {
4647 const auto called = c.getCalledFunction ();
4748 if (called != nullptr ) {
48- return called->getName (). startswith ( " __kmpc_omp_task_alloc" );
49+ return util::starts_with_any_of ( called->getName (), " __kmpc_omp_task_alloc" );
4950 }
5051 return false ;
5152 }
5253
5354 static bool isOmpTaskCall (const llvm::CallSite& c) {
5455 const auto called = c.getCalledFunction ();
5556 if (called != nullptr ) {
56- return called->getName (). endswith ( " __kmpc_omp_task" );
57+ return util::ends_with_any_of ( called->getName (), " __kmpc_omp_task" );
5758 }
5859 return false ;
5960 }
6061
6162 static bool isOmpTaskRelated (const llvm::CallSite& c) {
6263 const auto called = c.getCalledFunction ();
6364 if (called != nullptr ) {
64- return called->getName (). startswith ( " __kmpc_omp_task" );
65+ return util::starts_with_any_of ( called->getName (), " __kmpc_omp_task" );
6566 }
6667 return false ;
6768 }
@@ -71,9 +72,8 @@ struct OmpContext {
7172 if (!is_execute) {
7273 const auto called = c.getCalledFunction ();
7374 if (called != nullptr ) {
74- const auto name = called->getName ();
7575 // TODO extend this if required
76- return name. startswith ( " __kmpc" ) || name. startswith ( " omp_" );
76+ return util::starts_with_any_of (called-> getName (), " __kmpc" , " omp_" );
7777 }
7878 }
7979 return false ;
@@ -142,7 +142,8 @@ struct OmpContext {
142142 llvm::CallSite site (value);
143143 if (site.isCall () || site.isInvoke ()) {
144144 const auto called = site.getCalledFunction ();
145- if (called != nullptr && called->getName ().startswith (" __kmpc_omp_task(" )) {
145+
146+ if (called != nullptr && util::starts_with_any_of (called->getName (), " __kmpc_omp_task(" )) {
146147 found = true ;
147148 return util::DefUseChain::cancel;
148149 }
@@ -171,7 +172,7 @@ struct OmpContext {
171172 if (s.isCall () || s.isInvoke ()) {
172173 if (auto f = s.getCalledFunction ()) {
173174 // once true, the find_all should cancel
174- return f->getName (). startswith ( " __kmpc_omp_task_alloc" );
175+ return util::starts_with_any_of ( f->getName (), " __kmpc_omp_task_alloc" );
175176 }
176177 }
177178 return false ;
0 commit comments