This is an archive of the discontinued LLVM Phabricator instance.

[VP] Change getVPForBaseOpcode to return std::optional
AbandonedPublic

Authored by luke on Apr 17 2023, 6:07 AM.

Details

Summary

In an upcoming patch we would like to check if a regular base opcode has a corresponding VP opcode, so this changes the signature to return std::nullopt instead of LLVM_UNREACHABLE.
Where we previously relied on it to be unreachable, we just manually assert has_value() instead.

Diff Detail

Event Timeline

luke created this revision.Apr 17 2023, 6:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2023, 6:07 AM
luke requested review of this revision.Apr 17 2023, 6:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2023, 6:07 AM
craig.topper added inline comments.Apr 17 2023, 10:03 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
937

I think we're supposed to use operator* instead of value().

There were commits like this in December

[lldb] llvm::Optional::value() && => operator*/operator->
    
    std::optional::value() has undesired exception checking semantics and is
    unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The
    call sites block std::optional migration.
luke updated this revision to Diff 514614.Apr 18 2023, 5:14 AM

Use has_value() instead of value()

luke added inline comments.Apr 18 2023, 5:15 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
937

Good shout. Hopefully we can still use has_value(), I've changed it to just manually assert it.

luke edited the summary of this revision. (Show Details)Apr 18 2023, 5:17 AM
This revision is now accepted and ready to land.Apr 18 2023, 10:11 AM
luke abandoned this revision.Jun 29 2023, 4:58 AM

This is no longer needed without D148523