This patch attaches the merged metadata to the load instruction that is newly created in InstCombiner::FoldPHIArgLoadIntoPHI.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Transforms/InstCombine/InstCombinePHI.cpp | ||
---|---|---|
357 ↗ | (On Diff #34272) | On first look, this seems like it's the wrong approach. You're mutating the metadata on an existing load to accumulate the intersection of all of the incoming loads. It's not clear to me that we want to be killing the metadata on the input load. |
I was counting on the fact that the incoming loads will eventually get eliminated as they all have one use, so mutating the metadata is safe. But it's probably better to take an approach that doesn't mutate the metadata of an existing load. In the new patch, the metadata is attached to the newly created load.
lib/Transforms/InstCombine/InstCombinePHI.cpp | ||
---|---|---|
355 ↗ | (On Diff #35029) | Why are you preserving only TBAA? I think that you could also preserve here: MD_alias_scope MD_noalias MD_invariant_load MD_nonnull using combineMetadata. |
lib/Transforms/InstCombine/InstCombinePHI.cpp | ||
---|---|---|
355 ↗ | (On Diff #35029) | Yes, I think you are right. I didn't look at the other metadata since tbaa was the only one that I had to fix for my use case. Is there a reason you left out the other two (range and fpmath) that are combined in combineMetadata? It seems to me that they can be attached to load instructions and should be preserved too. |
lib/Transforms/InstCombine/InstCombinePHI.cpp | ||
---|---|---|
355 ↗ | (On Diff #35029) | I don't think that fpmath applies to loads, but range does, and yes, you should include that too. |
Preserve the following metadata in addition to tbaa:
MD_alias_scope
MD_noalias
MD_invariant_load
MD_nonnull
MD_range