Skip to content

Commit 72b73e2

Browse files
authored
Revert "demangle function names in trace files (llvm#87626)"
This reverts commit 0fa20c5. Storing raw symbol names is generally preferred in profile files. Demangling might lose information. Language frontends might use demangling schemes not supported by LLVMDemangle (llvm#45901 (comment)). In addition, calling `demangle` for each function has a significant performance overhead (llvm#102222). I believe that even if we decide to provide a producer-side demangling, it would not be on by default. Pull Request: llvm#102274
1 parent ca7368d commit 72b73e2

File tree

5 files changed

+5
-21
lines changed

5 files changed

+5
-21
lines changed

clang/test/Driver/ftime-trace-sections.py

100755100644
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ def is_before(range1, range2):
1919

2020
log_contents = json.loads(sys.stdin.read())
2121
events = log_contents["traceEvents"]
22-
23-
instants = [event for event in events if event["name"] == "InstantiateFunction"]
2422
codegens = [event for event in events if event["name"] == "CodeGen Function"]
25-
opts = [event for event in events if event["name"] == "OptFunction"]
2623
frontends = [event for event in events if event["name"] == "Frontend"]
2724
backends = [event for event in events if event["name"] == "Backend"]
2825

@@ -51,11 +48,3 @@ def is_before(range1, range2):
5148
]
5249
):
5350
sys.exit("Not all Frontend section are before all Backend sections!")
54-
55-
# Check that entries for foo exist and are in a demangled form.
56-
if not any(e for e in instants if "foo<int>" in e["args"]["detail"]):
57-
sys.exit("Missing Instantiate entry for foo!")
58-
if not any(e for e in codegens if "foo<int>" in e["args"]["detail"]):
59-
sys.exit("Missing CodeGen entry for foo!")
60-
if not any(e for e in opts if "foo<int>" in e["args"]["detail"]):
61-
sys.exit("Missing Optimize entry for foo!")

llvm/lib/IR/LegacyPassManager.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include "llvm/IR/LegacyPassManager.h"
1414
#include "llvm/ADT/MapVector.h"
15-
#include "llvm/Demangle/Demangle.h"
1615
#include "llvm/IR/DiagnosticInfo.h"
1716
#include "llvm/IR/IRPrintingPasses.h"
1817
#include "llvm/IR/LLVMContext.h"
@@ -1384,8 +1383,7 @@ bool FPPassManager::runOnFunction(Function &F) {
13841383

13851384
// Store name outside of loop to avoid redundant calls.
13861385
const StringRef Name = F.getName();
1387-
llvm::TimeTraceScope FunctionScope(
1388-
"OptFunction", [&F]() { return demangle(F.getName().str()); });
1386+
llvm::TimeTraceScope FunctionScope("OptFunction", Name);
13891387

13901388
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
13911389
FunctionPass *FP = getContainedPass(Index);

llvm/lib/Passes/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ add_llvm_component_library(LLVMPasses
2121
CodeGen
2222
Core
2323
Coroutines
24-
Demangle
2524
HipStdPar
2625
IPO
2726
InstCombine

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "llvm/CodeGen/MachineFunction.h"
2323
#include "llvm/CodeGen/MachineModuleInfo.h"
2424
#include "llvm/CodeGen/MachineVerifier.h"
25-
#include "llvm/Demangle/Demangle.h"
2625
#include "llvm/IR/Constants.h"
2726
#include "llvm/IR/Function.h"
2827
#include "llvm/IR/Module.h"
@@ -236,12 +235,12 @@ void printIR(raw_ostream &OS, const MachineFunction *MF) {
236235
MF->print(OS);
237236
}
238237

239-
std::string getIRName(Any IR, bool demangled = false) {
238+
std::string getIRName(Any IR) {
240239
if (unwrapIR<Module>(IR))
241240
return "[module]";
242241

243242
if (const auto *F = unwrapIR<Function>(IR))
244-
return demangled ? demangle(F->getName()) : F->getName().str();
243+
return F->getName().str();
245244

246245
if (const auto *C = unwrapIR<LazyCallGraph::SCC>(IR))
247246
return C->getName();
@@ -251,7 +250,7 @@ std::string getIRName(Any IR, bool demangled = false) {
251250
L->getHeader()->getParent()->getName().str();
252251

253252
if (const auto *MF = unwrapIR<MachineFunction>(IR))
254-
return demangled ? demangle(MF->getName()) : MF->getName().str();
253+
return MF->getName().str();
255254

256255
llvm_unreachable("Unknown wrapped IR type");
257256
}
@@ -1588,7 +1587,7 @@ void TimeProfilingPassesHandler::registerCallbacks(
15881587
}
15891588

15901589
void TimeProfilingPassesHandler::runBeforePass(StringRef PassID, Any IR) {
1591-
timeTraceProfilerBegin(PassID, getIRName(IR, true));
1590+
timeTraceProfilerBegin(PassID, getIRName(IR));
15921591
}
15931592

15941593
void TimeProfilingPassesHandler::runAfterPass() { timeTraceProfilerEnd(); }

utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,6 @@ cc_library(
26542654
":CodeGen",
26552655
":Core",
26562656
":Coroutines",
2657-
":Demangle",
26582657
":HipStdPar",
26592658
":IPO",
26602659
":IRPrinter",

0 commit comments

Comments
 (0)