[clang] [llvm] IR: Store the default subtarget info in named metadata instead of the context. (PR #98673)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 12 11:22:29 PDT 2024
MaskRay wrote:
> This is a WIP. Because I'm adding new metadata, several tests fail, e.g. check-clang:
>
> ```
> Testing Time: 244.38s
>
> Total Discovered Tests: 37911
> Skipped : 31 (0.08%)
> Unsupported : 102 (0.27%)
> Passed : 37689 (99.41%)
> Expectedly Failed: 28 (0.07%)
> Failed : 61 (0.16%)
> ```
>
> I'm uploading this to get agreement on the direction before updating the tests.
Thanks. Once an agreement on the direction is more formal, perhaps update the description to link to the Discourse thread and how this helps `opt`.
I have a shorter summary, which is hopefully useful.
```
If `Function::createWithDefaultAttr` reads from the serialized module flags metadata, we don't want conflict resolution logic because there is no unambiguously "correct" set of target attributes when merging two modules with different attributes.
In addition, when a translation unit has unexpected attributes, it could be benign in the non-LTO case as long as the code is unreachable.
However, conflict resolution logic could make the merged attributes unexpected.
<https://github.com/llvm/llvm-project/pull/96721> implemented a strategy by storing the target features in `LLVMContext`, which is not serialized.
`Function::createWithDefaultAttr` will load the target features from `LLVMContext`.
While 96721 works well, there is a drawback that the generate module from the LTO pre-link compilation does not contain sufficient information.
Running `opt` without the correct target features would not mimick Clang .
To address this drawback, we can use module flags metadata that is dropped during merging.
```
https://github.com/llvm/llvm-project/pull/98673
More information about the cfe-commits
mailing list