[all-commits] [llvm/llvm-project] 5f565c: [IR] Support efficient AssertingVH/PoisoningVH lookup

Nikita Popov via All-commits all-commits at lists.llvm.org
Sun Jun 14 13:05:06 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 5f565c04194bedb6535ce002fb53aa2134d9ff25
      https://github.com/llvm/llvm-project/commit/5f565c04194bedb6535ce002fb53aa2134d9ff25
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2020-06-14 (Sun, 14 Jun 2020)

  Changed paths:
    M llvm/include/llvm/IR/ValueHandle.h
    M llvm/unittests/IR/ValueHandleTest.cpp

  Log Message:
  -----------
  [IR] Support efficient AssertingVH/PoisoningVH lookup

Currently, there doesn't seem to be any way to look up a Value*
in a map/set indexed by AssertingVH/PoisoningVH, without creating
a value handle -- which is fairly expensive, because it involves
adding the value handle to the use list and immediately removing
it again. Using find_as(Value *) does not work (and is in fact
worse than just using find(Value *)), because it will end up
creating multiple value handles during the lookup itself.

For AssertingVH, address this by simply using DenseMapInfo<T *>
instead of manually implementing something. The AssertingVH<T>
will now get coerced to T*, rather than the other way around.

For PoisoningVH, add extra overloads of getHashValue() and
isEqual() that accept a T* argument.

This allows using find_as(Value *) to perform efficient lookups
in assertion-enabled builds.

Differential Revision: https://reviews.llvm.org/D81793




More information about the All-commits mailing list