aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Debugify.cpp
diff options
context:
space:
mode:
authorSebastian Neubauer <Sebastian.Neubauer@amd.com>2022-12-08 11:48:00 +0100
committerSebastian Neubauer <Sebastian.Neubauer@amd.com>2022-12-08 11:48:00 +0100
commitaeac2e4884a3ce62c920cd51806a9396da64d9f7 (patch)
tree5758bf1aff9a52eff54d372a93ff76e2a1302e2e /llvm/lib/Transforms/Utils/Debugify.cpp
parent3528e63d89305907b3d6e0f59f7b03b94a12dacc (diff)
downloadllvm-aeac2e4884a3ce62c920cd51806a9396da64d9f7.zip
llvm-aeac2e4884a3ce62c920cd51806a9396da64d9f7.tar.gz
llvm-aeac2e4884a3ce62c920cd51806a9396da64d9f7.tar.bz2
[llvm] Replace llvm::Any with std::any
llvm::Any had several bugs in the past, due to being sensitive to symbol visibility. (See D101972 and D108943) Even with these fixes applied, I still encounter the same issue on Windows. Similar to llvm::Optional going away in favor of std::optional, we can use std::any from C++17. Using std::any fixes the problem and puts the burden to do it correctly on the standard library. Differential Revision: https://reviews.llvm.org/D139532
Diffstat (limited to 'llvm/lib/Transforms/Utils/Debugify.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Debugify.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index f4d9bce..0baae37 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -29,6 +29,8 @@
#include "llvm/Support/JSON.h"
#include <optional>
+#include <any>
+
#define DEBUG_TYPE "debugify"
using namespace llvm;
@@ -1028,22 +1030,22 @@ static bool isIgnoredPass(StringRef PassID) {
void DebugifyEachInstrumentation::registerCallbacks(
PassInstrumentationCallbacks &PIC) {
- PIC.registerBeforeNonSkippedPassCallback([this](StringRef P, Any IR) {
+ PIC.registerBeforeNonSkippedPassCallback([this](StringRef P, std::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 = std::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 = std::any_cast<const Module *>(&IR))
+ applyDebugify(*const_cast<Module *>(*M),
Mode, DebugInfoBeforePass, P);
});
- PIC.registerAfterPassCallback([this](StringRef P, Any IR,
+ PIC.registerAfterPassCallback([this](StringRef P, std::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 = std::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 +1056,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 = std::any_cast<const Module *>(&IR)) {
+ auto &M = *const_cast<Module *>(*CM);
if (Mode == DebugifyMode::SyntheticDebugInfo)
checkDebugifyMetadata(M, M.functions(), P, "CheckModuleDebugify",
/*Strip=*/true, DIStatsMap);