Skip to content

Conversation

@llvmbot
Copy link
Member

@llvmbot llvmbot commented Jul 28, 2023

Currently, the precense of the OpenMP target declare metadata requires
that we always codegen a global declaration. This is undesirable in the
case that we could defer or omit this declaration as is common with
unused extern variables. This is important as it allows us, in the
runtime, to rely on static linking semantics to omit unused symbols so
they are not included when the user links it in.

This patch changes the check for always emitting these variables.
Because of this we also need to extend this logic to the generation of
the offloading entries. This has the result of derring the offload entry
generation to the canonical definitoin. So we are effectively assuming
whoever owns the storage for this variable will perform that operation.
This makes an exception for `link` attributes as those require their own
special handling.

Let me know if this is sound in the implementation, I do not have the
largest view of the standards here.

Fixes: llvm/llvm-project#64133

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D156368

(cherry picked from commit 141c4e7)
@llvmbot
Copy link
Member Author

llvmbot commented Jul 28, 2023

@shiltian What do you think about merging this PR to the release branch?

@shiltian
Copy link
Contributor

Yes, we need to back port the patch.

@tru tru merged commit aff99b1 into release/17.x Jul 29, 2023
@tru tru deleted the llvm-issue64133 branch July 29, 2023 06:40
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.

[OpenMP] Unused external variables are emitted when declared on the target

5 participants