Kaitlin Peng 0bb1af478a
[DirectX] Add GlobalDCE pass after finalize linkage pass in DirectX backend (#151071)
Fixes #139023.

This PR essentially removes unused global variables:
- Restores the `GlobalDCE` Legacy pass and adds it to the DirectX
backend after the finalize linkage pass
- Converts external global variables with no usage to internal linkage
in the finalize linkage pass
  - (so they can be removed by `GlobalDCE`)
- Makes the `dxil-finalize-linkage` pass usable using the new pass
manager flag syntax
- Adds tests to `finalize_linkage.ll` that make sure unused global
variables are removed
- Adds a use for variable `@CBV` in `opaque-value_as_metadata.ll` so it
isn't removed
- Changes the `scalar-data.ll` run command to avoid removing its global
variables

---------

Co-authored-by: Farzon Lotfi <farzonlotfi@microsoft.com>
2025-08-15 10:45:34 -07:00
..
2025-04-10 16:40:05 -04:00