Skip to content

[ESIMD] Fix removal of "llvm.used" global in sycl-post-link #5853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions llvm/tools/sycl-post-link/sycl-post-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,10 +859,11 @@ static bool removeSYCLKernelsConstRefArray(GlobalVariable *GV) {
for (auto It = IOperands.begin(); It != IOperands.end(); It++) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (auto It = IOperands.begin(); It != IOperands.end(); It++) {
for (auto *It = IOperands.begin(); It != IOperands.end(); It++) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggested change is NFC, both syntax variants mean the same here.
I prefer 'auto It = ...'. It is also way more typical syntax (about 2000 cases in sources vs 54 cases of 'auto *It = ' )

assert(llvm::isSafeToDestroyConstant(*It) &&
"Cannot remove an element of initializer of llvm.used global");
auto F = cast<Function>((*It)->getOperand(0));
auto Op = (*It)->getOperand(0);
(*It)->destroyConstant();
// Remove unused kernel declarations to avoid LLVM IR check fails.
if (F->isDeclaration())
auto *F = dyn_cast<Function>(Op);
if (F && F->isDeclaration())
F->eraseFromParent();
}
return true;
Expand Down