[Mlir-commits] [mlir] [mlir] Migrate away from PointerUnion::dyn_cast (NFC) (PR #123693)

Andrzej WarzyƄski llvmlistbot at llvm.org
Tue Jan 21 07:28:04 PST 2025


banach-space wrote:

> > > > // FIXME: Replace the uses of is(), get() and dyn_cast() with
> > > > // isa, cast and the llvm::dyn_cast
> > > 
> > > 
> > > In this case, why do we replace it with `dyn_cast_if_present`, but not `dyn_cast`?
> > 
> > 
> > That's because `PointerUnion::dyn_cast` is implemented with `dyn_cast_if_present` like so:
> > https://github.com/llvm/llvm-project/blob/97d691b4b3f5ba446d6827fc29fbe15e44a7adac/llvm/include/llvm/ADT/PointerUnion.h#L166-L170
> 
> I see, thanks! I tracked back to the [previous commit](https://github.com/llvm/llvm-project/commit/716b9f7a1a3ce7db89993c15855d8b89a35fc4fc) and found that it was replaced with `dyn_cast_if_present` because it seems like (based on the call sites) the semantics of the member dyn_cast are actually dyn_cast_if_present.
> 
> In this case, it looks good to me.

This is a very helpful context, thank you! @kazutakahirata , please add some justification for using `dyn_cast_if_present` (instead of `dyn_cast`) in the summary. Thanks!

https://github.com/llvm/llvm-project/pull/123693


More information about the Mlir-commits mailing list