aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Debugify.cpp
diff options
context:
space:
mode:
authorSebastian Neubauer <Sebastian.Neubauer@amd.com>2022-12-20 13:28:30 +0100
committerSebastian Neubauer <Sebastian.Neubauer@amd.com>2022-12-20 13:28:30 +0100
commitbb7940e25f6ca201ca57943544016390f1d2e504 (patch)
tree80c036c44496fffe523f290f8c67bc6f0160250f /llvm/lib/Transforms/Utils/Debugify.cpp
parent741396af16d14091c26b63a32ca925520f1ef16d (diff)
downloadllvm-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/Utils/Debugify.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Debugify.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index f4d9bce..b114353 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -1031,19 +1031,19 @@ void DebugifyEachInstrumentation::registerCallbacks(
PIC.registerBeforeNonSkippedPassCallback([this](StringRef P, Any IR) {
if (isIgnoredPass(P))
return;
- if (any_isa<const Function *>(IR))
- applyDebugify(*const_cast<Function *>(any_cast<const Function *>(IR)),
+ if (const auto **F = any_cast<const Function *>(&IR))
+ applyDebugify(*const_cast<Function *>(*F),
Mode, DebugInfoBeforePass, P);
- else if (any_isa<const Module *>(IR))
- applyDebugify(*const_cast<Module *>(any_cast<const Module *>(IR)),
+ else if (const auto **M = any_cast<const Module *>(&IR))
+ applyDebugify(*const_cast<Module *>(*M),
Mode, DebugInfoBeforePass, P);
});
PIC.registerAfterPassCallback([this](StringRef P, Any IR,
const PreservedAnalyses &PassPA) {
if (isIgnoredPass(P))
return;
- if (any_isa<const Function *>(IR)) {
- auto &F = *const_cast<Function *>(any_cast<const Function *>(IR));
+ if (const auto **CF = any_cast<const Function *>(&IR)) {
+ auto &F = *const_cast<Function *>(*CF);
Module &M = *F.getParent();
auto It = F.getIterator();
if (Mode == DebugifyMode::SyntheticDebugInfo)
@@ -1054,8 +1054,8 @@ void DebugifyEachInstrumentation::registerCallbacks(
M, make_range(It, std::next(It)), *DebugInfoBeforePass,
"CheckModuleDebugify (original debuginfo)",
P, OrigDIVerifyBugsReportFilePath);
- } else if (any_isa<const Module *>(IR)) {
- auto &M = *const_cast<Module *>(any_cast<const Module *>(IR));
+ } else if (const auto **CM = any_cast<const Module *>(&IR)) {
+ auto &M = *const_cast<Module *>(*CM);
if (Mode == DebugifyMode::SyntheticDebugInfo)
checkDebugifyMetadata(M, M.functions(), P, "CheckModuleDebugify",
/*Strip=*/true, DIStatsMap);