Merging custom metadata

Hello everyone,

I’m trying to tag certain load instructions with specialized metadata and make use of it in an AA pass. However, it seems that metadata is getting lost when instructions are merged together.

Here’s a toy problem with one intentionally duplicated load to illustrate the issue.

http://susepaste.org/3af3a676

The above paste has two before/after IR pairs (the before code gets passed through opt -O3 test.ll | llvm-dis). Regular tbaa tags are still present when loads are merged, however custom ones seem to perish.

Is this expected? If yes, is there any way I can make them persist from within a custom AA pass at all? I tried overwriting copyValue() in the AA pass but it doesn’t seem to get called at all. The main idea is to recognize certain types of loads and have other information in the my.tbaa metadata that regular tbaa doesn’t provide. The only other solution I can think of right now is to encode that extra information in tbaa node strings, but that seems rather gross.

Thanks,

Dimitri.