[llvm-dev] [RFC] Should we add isa_or_null<>?

Don Hinton via llvm-dev llvm-dev at lists.llvm.org
Thu Apr 4 05:37:04 PDT 2019


I'd like to propose adding `isa_or_null<>` to replace the following usage
pattern that's relatively common in conditionals:

  var && isa<T>(var)  =>>  isa_or_null<T>(var)

And in particular when `var` is a method call which might be expensive,
e.g.:

  X->foo() && isa<T>(X->foo())  =>>  isa_or_null<T>(X->foo())

The implementation could be a simple wrapper around isa<>, and while the IR
produced is only slightly more efficient, the elimination of an extra call
could be worthwhile.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190404/cf573877/attachment.html>


More information about the llvm-dev mailing list