We already have the inverse verification that we only use globals
that are defined in this module. This essentially catches the
same mistake, but when verifying the module that contains the
definition. There is a moderately annoying corner case caused by
our usage of a parentless ReturnInst to hold prefix/prologue data.
In order to perform correct diagnostics, we need to construct the
inverse map for this on demand. Since that can be expensive, this
inverse mapping is cached in the Verifier class and only constructed
when needed.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/IR/Verifier.cpp | ||
---|---|---|
451 ↗ | (On Diff #43303) | Is there a good way to name a C++ lambda (I know about std::function, but AFAIK that has performance implications, so I tend to avoid it)? |
Address review comments and rebase. Rebasing required changing a few uses() to
materialized_uses(). I hope that's the correct thing.
lib/IR/Verifier.cpp | ||
---|---|---|
455 ↗ | (On Diff #43540) | The user is the only thing this function uses. Can you pass a "Value *User" instead and in the recursive call iterate over users() instead of uses()? |
460 ↗ | (On Diff #43540) | How about having a single callback that takes a Value and do the cast in the callback? |
492 ↗ | (On Diff #43540) | This can also iterate over users, no? |
How about having a single callback that takes a Value and do the cast
in the callback?
My concern was that I already have to check for the type here in order to
see whether to call the callback or recurse, so I thought it was cleaner to
have two callbacks, but I don't feel very strongly about that.
Why not always call the callback? We have a set to avoid a loop.
Cheers, Rafael
Switch uses() -> users() and add a comment to explain what the foreach helper is for.
LGTM with a nit.
lib/IR/Verifier.cpp | ||
---|---|---|
499 ↗ | (On Diff #43626) | Nit: There are many calls to GV.getParent(). Don't you have the module being verified handy somewhere? |