[PATCH] D15272: [Verifier] Verifier that a GlobalValue is only used in this Module

Keno Fischer via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 24 11:20:33 PST 2015


Yeah, you can, at the expense of making the callback more messy, and I
liked the version with multiple callbacks better.

On Thu, Dec 24, 2015 at 4:52 PM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> On 24 December 2015 at 09:38, Keno Fischer <kfischer at college.harvard.edu>
> wrote:
> > Say you use a global in a function in some other module. If I understand
> > your patch correctly it would recursively complain about all the
> > instructions which have some use relation to the one that uses the bad
> > global as opposed to just the first one.
>
> I see, but can still use the general user walker by allowing the
> callback to stop the recursion, no:
>
> static void forEachUser(const Value *V, SmallPtrSet<const Value *, 32>
> &Visited,
>                         llvm::function_ref<void(const Value *)> Callback) {
>   if (!Visited.insert(V).second)
>     return;
>   for (const Value *U : V->materialized_users()) {
>     if (Callback(U))
>       forEachUser(U, Visited, Callback);
>   }
> }
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151224/aa50a0b9/attachment.html>


More information about the llvm-commits mailing list