File tree 1 file changed +11
-11
lines changed
llvm/tools/sycl-post-link
1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -183,27 +183,27 @@ PreservedAnalyses SpecConstantsPass::run(Module &M,
183
183
int NextID = 0 ;
184
184
StringMap<unsigned > IDMap;
185
185
186
- // Iterate through all calls to
186
+ // Iterate through all declarations of instances of function template
187
187
// template <typename T> T __sycl_getSpecConstantValue(const char *ID)
188
- // intrinsic and lower them depending on the SetValAtRT setting (see below).
188
+ // intrinsic to find its calls and lower them depending on the SetValAtRT
189
+ // setting (see below).
189
190
bool IRModified = false ;
190
191
191
192
for (Function &F : M) {
192
- if (F.isDeclaration ())
193
+ if (! F.isDeclaration ())
193
194
continue ;
194
- SmallVector<CallInst *, 32 > SCIntrCalls;
195
195
196
- for (Instruction &I : instructions (F)) {
197
- auto *CI = dyn_cast<CallInst>(&I);
198
- Function *Callee = nullptr ;
199
- if (!CI || CI->isIndirectCall () || !(Callee = CI->getCalledFunction ()))
200
- continue ;
201
- StringRef Name = Callee->getName ();
196
+ if (!F.getName ().startswith (SYCL_GET_SPEC_CONST_VAL))
197
+ continue ;
202
198
203
- if (!Name.startswith (SYCL_GET_SPEC_CONST_VAL))
199
+ SmallVector<CallInst *, 32 > SCIntrCalls;
200
+ for (auto *U : F.users ()) {
201
+ auto *CI = dyn_cast<CallInst>(U);
202
+ if (!CI)
204
203
continue ;
205
204
SCIntrCalls.push_back (CI);
206
205
}
206
+
207
207
IRModified = IRModified || (SCIntrCalls.size () > 0 );
208
208
209
209
for (auto *CI : SCIntrCalls) {
You can’t perform that action at this time.
0 commit comments