Reapply [Dominators] Add findNearestCommonDominator() for Instructions (NFC)
authorNikita Popov <npopov@redhat.com>
Fri, 6 Jan 2023 15:56:34 +0000 (16:56 +0100)
committerNikita Popov <npopov@redhat.com>
Tue, 10 Jan 2023 11:16:31 +0000 (12:16 +0100)
commit094ccee2c89e9fa12a3439f5561f9472f98654e5
treeefc89cbd6ce4494127cbfecb0df6f3aefd6b541e
parent1ee4a93b15bb5dee7a1045fd035e1a286bb5d162
Reapply [Dominators] Add findNearestCommonDominator() for Instructions (NFC)

Reapply with checks for instructions in unreachable blocks. A test
case for this was added in 1ee4a93b15bb.

-----

This is a recurring pattern: We want to find the nearest common
dominator (instruction) for two instructions, but currently only
provide an API for the nearest common dominator of two basic blocks.

Add an overload that accepts and return instructions.
llvm/include/llvm/IR/Dominators.h
llvm/lib/Analysis/CaptureTracking.cpp
llvm/lib/IR/Dominators.cpp
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp
llvm/lib/Transforms/Utils/SimplifyIndVar.cpp