diff options
author | Sebastian Neubauer <Sebastian.Neubauer@amd.com> | 2022-12-20 13:28:30 +0100 |
---|---|---|
committer | Sebastian Neubauer <Sebastian.Neubauer@amd.com> | 2022-12-20 13:28:30 +0100 |
commit | bb7940e25f6ca201ca57943544016390f1d2e504 (patch) | |
tree | 80c036c44496fffe523f290f8c67bc6f0160250f /llvm/lib/Transforms/Scalar/LoopPassManager.cpp | |
parent | 741396af16d14091c26b63a32ca925520f1ef16d (diff) | |
download | llvm-bb7940e25f6ca201ca57943544016390f1d2e504.zip llvm-bb7940e25f6ca201ca57943544016390f1d2e504.tar.gz llvm-bb7940e25f6ca201ca57943544016390f1d2e504.tar.bz2 |
[llvm] Make llvm::Any similar to std::any
This facilitates replacing llvm::Any with std::any.
- Deprecate any_isa in favor of using any_cast(Any*) and checking for
nullptr because C++17 has no any_isa.
- Remove the assert from any_cast(Any*), so it returns nullptr if the
type is not correct. This aligns it with std::any_cast(any*).
Use any_cast(Any*) throughout LLVM instead of checks with any_isa.
This is the first part outlined in
https://discourse.llvm.org/t/rfc-switching-from-llvm-any-to-std-any/67176
Differential Revision: https://reviews.llvm.org/D139973
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopPassManager.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopPassManager.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp index fadd070..c98b94b 100644 --- a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp +++ b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp @@ -269,10 +269,11 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F, PI.pushBeforeNonSkippedPassCallback([&LAR, &LI](StringRef PassID, Any IR) { if (isSpecialPass(PassID, {"PassManager"})) return; - assert(any_isa<const Loop *>(IR) || any_isa<const LoopNest *>(IR)); - const Loop *L = any_isa<const Loop *>(IR) - ? any_cast<const Loop *>(IR) - : &any_cast<const LoopNest *>(IR)->getOutermostLoop(); + assert(any_cast<const Loop *>(&IR) || any_cast<const LoopNest *>(&IR)); + const Loop **LPtr = any_cast<const Loop *>(&IR); + const Loop *L = LPtr ? *LPtr : nullptr; + if (!L) + L = &any_cast<const LoopNest *>(IR)->getOutermostLoop(); assert(L && "Loop should be valid for printing"); // Verify the loop structure and LCSSA form before visiting the loop. |