@@ -57,85 +57,6 @@ bool isModuleUsingTsan(const Module &M) {
5757 return M.getNamedGlobal (" __TsanKernelMetadata" );
5858}
5959
60- // This function traverses over reversed call graph by BFS algorithm.
61- // It means that an edge links some function @func with functions
62- // which contain call of function @func. It starts from
63- // @StartingFunction and lifts up until it reach all reachable functions,
64- // or it reaches some function containing "referenced-indirectly" attribute.
65- // If it reaches "referenced-indirectly" attribute than it returns an empty
66- // Optional.
67- // Otherwise, it returns an Optional containing a list of reached
68- // SPIR kernel function's names.
69- static std::optional<std::vector<StringRef>> traverseCGToFindSPIRKernels (
70- const std::vector<Function *> &StartingFunctionVec) {
71- std::queue<const Function *> FunctionsToVisit;
72- std::unordered_set<const Function *> VisitedFunctions;
73- for (const Function *FPtr : StartingFunctionVec)
74- FunctionsToVisit.push (FPtr);
75- std::vector<StringRef> KernelNames;
76-
77- while (!FunctionsToVisit.empty ()) {
78- const Function *F = FunctionsToVisit.front ();
79- FunctionsToVisit.pop ();
80-
81- auto InsertionResult = VisitedFunctions.insert (F);
82- // It is possible that we insert some particular function several
83- // times in functionsToVisit queue.
84- if (!InsertionResult.second )
85- continue ;
86-
87- for (const auto *U : F->users ()) {
88- const CallInst *CI = dyn_cast<const CallInst>(U);
89- if (!CI)
90- continue ;
91-
92- const Function *ParentF = CI->getFunction ();
93-
94- if (VisitedFunctions.count (ParentF))
95- continue ;
96-
97- if (ParentF->hasFnAttribute (" referenced-indirectly" ))
98- return {};
99-
100- if (ParentF->getCallingConv () == CallingConv::SPIR_KERNEL)
101- KernelNames.push_back (ParentF->getName ());
102-
103- FunctionsToVisit.push (ParentF);
104- }
105- }
106-
107- return {std::move (KernelNames)};
108- }
109-
110- static std::vector<StringRef>
111- getKernelNamesUsingSpecialFunctions (const Module &M,
112- const std::vector<StringRef> &FNames) {
113- std::vector<Function *> SpecialFunctionVec;
114- for (const auto Fn : FNames) {
115- Function *FPtr = M.getFunction (Fn);
116- if (FPtr)
117- SpecialFunctionVec.push_back (FPtr);
118- }
119-
120- if (SpecialFunctionVec.size () == 0 )
121- return {};
122-
123- auto TraverseResult = traverseCGToFindSPIRKernels (SpecialFunctionVec);
124-
125- if (TraverseResult.has_value ())
126- return std::move (*TraverseResult);
127-
128- // Here we reached "referenced-indirectly", so we need to find all kernels and
129- // return them.
130- std::vector<StringRef> SPIRKernelNames;
131- for (const Function &F : M) {
132- if (F.getCallingConv () == CallingConv::SPIR_KERNEL)
133- SPIRKernelNames.push_back (F.getName ());
134- }
135-
136- return SPIRKernelNames;
137- }
138-
13960// Gets 1- to 3-dimension work-group related information for function Func.
14061// Returns an empty vector if not present.
14162template <typename T>
@@ -449,13 +370,6 @@ PropSetRegTy computeModuleProperties(const Module &M,
449370 if (OptLevel != -1 )
450371 PropSet.add (PropSetRegTy::SYCL_MISC_PROP, " optLevel" , OptLevel);
451372 }
452- {
453- std::vector<StringRef> AssertFuncNames{" __devicelib_assert_fail" };
454- std::vector<StringRef> FuncNames =
455- getKernelNamesUsingSpecialFunctions (M, AssertFuncNames);
456- for (const StringRef &FName : FuncNames)
457- PropSet.add (PropSetRegTy::SYCL_ASSERT_USED, FName, true );
458- }
459373 {
460374 std::vector<std::pair<StringRef, int >> ArgPos =
461375 getKernelNamesUsingImplicitLocalMem (M);
0 commit comments