[clang] [llvm] Revert "demangle function names in trace files (#87626)" (PR #102274)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 6 23:31:15 PDT 2024
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/102274
This reverts commit 0fa20c55b58deb94090985a5c5ffda4d5ceb3cd1.
Storing raw symbol names is generally preferred in profile files.
Demangling might lose information. Some platforms might use different
demangling schemes (
https://github.com/llvm/llvm-project/issues/45901#issuecomment-2008686663).
In addition, calling `demangle` for each function has a significant
performance overhead (#102222).
I believe that even if we decide to provide a producer-side demangling,
it would not be on by default.
>From e37ffc4ff6f06879d83ba1a9b9faa1ac6ea86ac2 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Tue, 6 Aug 2024 23:31:05 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.5-bogner
---
clang/test/Driver/ftime-trace-sections.py | 11 -----------
llvm/lib/IR/LegacyPassManager.cpp | 4 +---
llvm/lib/Passes/CMakeLists.txt | 1 -
llvm/lib/Passes/StandardInstrumentations.cpp | 9 ++++-----
utils/bazel/llvm-project-overlay/llvm/BUILD.bazel | 1 -
5 files changed, 5 insertions(+), 21 deletions(-)
mode change 100755 => 100644 clang/test/Driver/ftime-trace-sections.py
diff --git a/clang/test/Driver/ftime-trace-sections.py b/clang/test/Driver/ftime-trace-sections.py
old mode 100755
new mode 100644
index b332931d29a62..02afa4ac54eb7
--- a/clang/test/Driver/ftime-trace-sections.py
+++ b/clang/test/Driver/ftime-trace-sections.py
@@ -19,10 +19,7 @@ def is_before(range1, range2):
log_contents = json.loads(sys.stdin.read())
events = log_contents["traceEvents"]
-
-instants = [event for event in events if event["name"] == "InstantiateFunction"]
codegens = [event for event in events if event["name"] == "CodeGen Function"]
-opts = [event for event in events if event["name"] == "OptFunction"]
frontends = [event for event in events if event["name"] == "Frontend"]
backends = [event for event in events if event["name"] == "Backend"]
@@ -51,11 +48,3 @@ def is_before(range1, range2):
]
):
sys.exit("Not all Frontend section are before all Backend sections!")
-
-# Check that entries for foo exist and are in a demangled form.
-if not any(e for e in instants if "foo<int>" in e["args"]["detail"]):
- sys.exit("Missing Instantiate entry for foo!")
-if not any(e for e in codegens if "foo<int>" in e["args"]["detail"]):
- sys.exit("Missing CodeGen entry for foo!")
-if not any(e for e in opts if "foo<int>" in e["args"]["detail"]):
- sys.exit("Missing Optimize entry for foo!")
diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index f2a83b50923e9..96e2f1d7908ba 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -12,7 +12,6 @@
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/ADT/MapVector.h"
-#include "llvm/Demangle/Demangle.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/LLVMContext.h"
@@ -1384,8 +1383,7 @@ bool FPPassManager::runOnFunction(Function &F) {
// Store name outside of loop to avoid redundant calls.
const StringRef Name = F.getName();
- llvm::TimeTraceScope FunctionScope(
- "OptFunction", [&F]() { return demangle(F.getName().str()); });
+ llvm::TimeTraceScope FunctionScope("OptFunction", Name);
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
FunctionPass *FP = getContainedPass(Index);
diff --git a/llvm/lib/Passes/CMakeLists.txt b/llvm/lib/Passes/CMakeLists.txt
index b5224327d7921..6425f4934b210 100644
--- a/llvm/lib/Passes/CMakeLists.txt
+++ b/llvm/lib/Passes/CMakeLists.txt
@@ -21,7 +21,6 @@ add_llvm_component_library(LLVMPasses
CodeGen
Core
Coroutines
- Demangle
HipStdPar
IPO
InstCombine
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index 8f2461f40cb00..036484c9c1c0c 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -22,7 +22,6 @@
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineVerifier.h"
-#include "llvm/Demangle/Demangle.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
@@ -236,12 +235,12 @@ void printIR(raw_ostream &OS, const MachineFunction *MF) {
MF->print(OS);
}
-std::string getIRName(Any IR, bool demangled = false) {
+std::string getIRName(Any IR) {
if (unwrapIR<Module>(IR))
return "[module]";
if (const auto *F = unwrapIR<Function>(IR))
- return demangled ? demangle(F->getName()) : F->getName().str();
+ return F->getName().str();
if (const auto *C = unwrapIR<LazyCallGraph::SCC>(IR))
return C->getName();
@@ -251,7 +250,7 @@ std::string getIRName(Any IR, bool demangled = false) {
L->getHeader()->getParent()->getName().str();
if (const auto *MF = unwrapIR<MachineFunction>(IR))
- return demangled ? demangle(MF->getName()) : MF->getName().str();
+ return MF->getName().str();
llvm_unreachable("Unknown wrapped IR type");
}
@@ -1588,7 +1587,7 @@ void TimeProfilingPassesHandler::registerCallbacks(
}
void TimeProfilingPassesHandler::runBeforePass(StringRef PassID, Any IR) {
- timeTraceProfilerBegin(PassID, getIRName(IR, true));
+ timeTraceProfilerBegin(PassID, getIRName(IR));
}
void TimeProfilingPassesHandler::runAfterPass() { timeTraceProfilerEnd(); }
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index c58236a4a3ed2..1bf6cdbb447a4 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -2654,7 +2654,6 @@ cc_library(
":CodeGen",
":Core",
":Coroutines",
- ":Demangle",
":HipStdPar",
":IPO",
":IRPrinter",
More information about the llvm-commits
mailing list