This is an archive of the discontinued LLVM Phabricator instance.

[Verifier] Verify scoped noalias metadata
ClosedPublic

Authored by nikic on Sep 18 2021, 12:29 PM.

Details

Summary

Verify that !noalias, !alias.scope and llvm.experimental.noalias.scope arguments have the format specified in https://llvm.org/docs/LangRef.html#noalias-and-alias-scope-metadata. I've fixed up a lot of broken metadata used by tests in advance. Especially using a scope instead of the expected scope list is a commonly made mistake.

Diff Detail

Event Timeline

nikic created this revision.Sep 18 2021, 12:29 PM
nikic requested review of this revision.Sep 18 2021, 12:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 18 2021, 12:29 PM

LGTM

llvm/lib/IR/Verifier.cpp
4350

Did you run clang-format ?

This revision is now accepted and ready to land.Sep 20 2021, 12:17 AM
This revision was landed with ongoing or failed builds.Sep 20 2021, 9:30 AM
This revision was automatically updated to reflect the committed changes.

@Meinersbur I partially fixed the alias metadata generated by polly in https://github.com/llvm/llvm-project/commit/53720f74e4e32fe11a1688282f7d09dc1828b83a. However, another fix for the "second level" metadata is needed. This code is doing something very odd in https://github.com/llvm/llvm-project/blob/53720f74e4e32fe11a1688282f7d09dc1828b83a/polly/lib/CodeGen/IRBuilder.cpp#L207 where it apparently creates an alias scope with another alias scope used as a domain. It wasn't obvious to me what the right way to adjust this code is.

@nikic Thanks for fixing Polly. Regarding the "second level" metadata, it represents another source known non-aliasing from internal "Inter iteration alias-free" annotations which were added as part of a GSoC. I am going to have a look on what it is trying to achieve.

@nikic I ended up removing the second level metadata in https://github.com/llvm/llvm-project/commit/cad9f98a2ad98fecf663e9ce39502b8e43676fc9. Thanks again for fixing the fixing the array-based noalias metadata.

hgreving added a subscriber: hgreving.EditedSep 21 2021, 8:25 AM

Seems like that this patch now contradicts the methods MDBuilder.h:createAnonymousAliasScopeDomain and createAnonymousAliasScope. If you actually give it a string, it won't verify. I wonder if you should amend this changing the methods as well?

nikic added a comment.Sep 21 2021, 8:55 AM

Seems like that this patch now contradicts the methods MDBuilder.h:createAnonymousAliasScopeDomain and createAnonymousAliasScope. If you actually give it a string, it won't verify. I wonder if you should amend this changing the methods as well?

These methods are intended to be supported and are used in-tree and do verify there. Could you provide an example that would fail? Please keep in mind that scoped alias metadata always deals in scope lists, while createAnonymousAliasScope() only creates an isolated scope. You cannot pass the result of createAnonymousAliasScope() directly to !noalias, !alias.scope, etc.

Seems like that this patch now contradicts the methods MDBuilder.h:createAnonymousAliasScopeDomain and createAnonymousAliasScope. If you actually give it a string, it won't verify. I wonder if you should amend this changing the methods as well?

These methods are intended to be supported and are used in-tree and do verify there. Could you provide an example that would fail? Please keep in mind that scoped alias metadata always deals in scope lists, while createAnonymousAliasScope() only creates an isolated scope. You cannot pass the result of createAnonymousAliasScope() directly to !noalias, !alias.scope, etc.

Yes. But MDB.createAnonymousAliasScopeDomain("mystring") noew creates e.g. the domain !33 = distinct !{!33, !"mystring"}, which leads to the verifier error "second scope operand must be MDNode". This seems inconsistent. Same happens for createAnonymousAliasScope().

Seems like that this patch now contradicts the methods MDBuilder.h:createAnonymousAliasScopeDomain and createAnonymousAliasScope. If you actually give it a string, it won't verify. I wonder if you should amend this changing the methods as well?

These methods are intended to be supported and are used in-tree and do verify there. Could you provide an example that would fail? Please keep in mind that scoped alias metadata always deals in scope lists, while createAnonymousAliasScope() only creates an isolated scope. You cannot pass the result of createAnonymousAliasScope() directly to !noalias, !alias.scope, etc.

Yes. But MDB.createAnonymousAliasScopeDomain("mystring") noew creates e.g. the domain !33 = distinct !{!33, !"mystring"}, which leads to the verifier error "second scope operand must be MDNode". This seems inconsistent. Same happens for createAnonymousAliasScope().

I take it back. My confusion came from the fact that we were not creating lists as you pointed out above! Thanks for the tip, I think the methods are fine.