Skip to content

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

Closed
llvm/llvm-project-release-prs
#502
@jhuber6

Description

@jhuber6

The following code snippet will cause the external variable a to be emitted in the IR even though it is not used. See also the godbolt link, https://godbolt.org/z/M5MsrnbnM.

extern int a;
#pragma omp declare target to(a) device_type(host)

int main() { return 0; }

The standard semantics maintain that unused extern variables will not be emitted. This is important for linking as linking in a static library that defines a will be extracted even though it's unused.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions