Skip to content
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

[clang-linker-wrapper][NFC] Remove dead code #16879

Open
wants to merge 1 commit into
base: sycl
Choose a base branch
from

Conversation

bader
Copy link
Contributor

@bader bader commented Feb 3, 2025

InputFiles variable defined in the function is not used. If statements below define local scope variables with the same name.

InputFiles variable defined in the function is not used. If statements
below define local scope variables with the same name.
@bader bader requested a review from a team as a code owner February 3, 2025 23:54
@@ -2364,14 +2364,6 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles(
HasNonSYCLOffloadKinds = true;
}

// Write any remaining device inputs to an output file.
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be a community code: https://github.com/llvm/llvm-project/blame/main/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp#L939

I would suggest to drop our own copy within HasSYCLOffloadKind instead to reduce divergence with the upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"HasNonSYCLOffloadKinds branch" builds similar vector differently. I think this is the reason to sink InputFiles initialization into if-conditions.

Copy link
Contributor

Choose a reason for hiding this comment

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

"HasNonSYCLOffloadKinds branch" builds similar vector differently. I think this is the reason to sink InputFiles initialization into if-conditions.

It modifies InputFiles, but the code to initialize seems to be absolutely the same. In that case it is not clear to me as to why we can't re-use the community code here.

If your concern is that we have some other if and other scopes below which also define InputFiles and shadow the original variable, then I would say we should fix those. Shadowing variables is not a good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It modifies InputFiles, but the code to initialize seems to be absolutely the same. In that case it is not clear to me as to why we can't re-use the community code here.

They are different. Please compare:
https://github.com/intel/llvm/blob/sycl/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp#L2376-L2383 and https://github.com/intel/llvm/blob/sycl/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp#L2464-L2475.

Shadowing variables is not a good idea

That's the reason I remove it. If we go with your proposal, we still have to use shadowing due to the difference I mentioned above.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's the reason I remove it. If we go with your proposal, we still have to use shadowing due to the difference I mentioned above.

Isn't better to fix shadowing in our own code which was added on top of the upstream instead of dropping the upstream code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you have any suggestions, I'm all ears.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you have any suggestions, I'm all ears.

#16926 is an alternative proposal. I would love to see even more unification, but I can't quickly propose anything as it requires more investigation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your proposal doesn't work. I left a comment in #16926.

@bader bader requested a review from AlexeySachkov February 5, 2025 17:50
Copy link
Contributor

@asudarsa asudarsa left a comment

Choose a reason for hiding this comment

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

Good catch Alexey. I think this variable was missed as the code evolved over time.
Also, there will be considerable cleanup if/when we fully move to using clang-sycl-linker.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants