LLVM IR supports free form string attributes. Those are used both internally in various passes, or to convey information from the front-end to the middle-end, and externally by third party projects.
This patch normalizes the internal part while still being open to extension for third-party project. The basic idea is to have one immutable object per string attribute, with its hash computed at compile-time. Then instead of referencing attributes per their name, one must reference them by their key.
Pros:
- avoid typos in attribute spelling etc, turn them in compile-time error
- it is possible to list all internal keys in one place, and eventually (not implemented in this patch) to normalize them (we currently have a mixture of underscores and hyphens). And to document them.
- hashes are precomputed, which leads to faster indexing and faster testing for attribute presence
This whole code deserves documentation I think.