[PATCH] D89050: Add support for !noundef metatdata on loads

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 16:10:38 PDT 2020


aqjune added inline comments.


================
Comment at: llvm/docs/LangRef.rst:9251
+behavior is undefined.
+
 Semantics:
----------------
jdoerfert wrote:
> Why do we need index? and what is index?
An index is the name of the metadata node, and it is used as a placeholder that represents the existence of `!noundef` key. This is analogous to what `!nonnull` does.
```
define void @f() {
  %v = load i32, i32* [[P:%.*]], align 4, !noundef !0
}
!0 = !{}
```
To be precise, the first sentence should end with '... `{}` or a single metadata name `<index>` ...'. I'll update this sentence as well as `!nonnull`'s sentence.

----

About the verbosity of this empty metadata node:
The empty node is necessary because metadata is stored as a key-value store (`MDAttachmentMap`).
This makes textual representation slightly more verbose compared to attaching `!noundef` without value. To remove these, two workarounds are here:

1. When parsing metadata attached to instructions, if there is no value, automatically add empty node
2. Add a special state 'has a key but not value' to `MDAttachmentMap`'s each slot

The first approach causes a discrepancy between IR and bitcode. The second one might be a more viable option, but it breaks invariants that currently holds (e.g., `MDAttachmentMap::getAll`'s returned values are all valid metadata)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89050/new/

https://reviews.llvm.org/D89050



More information about the llvm-commits mailing list