Skip to content

Commit d893708

Browse files
MaskRaytru
authored andcommitted
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 (cherry picked from commit 72b73e2)
1 parent 39746ee commit d893708

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"
@@ -1416,8 +1415,7 @@ bool FPPassManager::runOnFunction(Function &F) {
14161415

14171416
// Store name outside of loop to avoid redundant calls.
14181417
const StringRef Name = F.getName();
1419-
llvm::TimeTraceScope FunctionScope(
1420-
"OptFunction", [&F]() { return demangle(F.getName().str()); });
1418+
llvm::TimeTraceScope FunctionScope("OptFunction", Name);
14211419

14221420
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
14231421
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
@@ -23,7 +23,6 @@
2323
#include "llvm/CodeGen/MachineFunction.h"
2424
#include "llvm/CodeGen/MachineModuleInfo.h"
2525
#include "llvm/CodeGen/MachineVerifier.h"
26-
#include "llvm/Demangle/Demangle.h"
2726
#include "llvm/IR/Constants.h"
2827
#include "llvm/IR/Function.h"
2928
#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
}
@@ -1589,7 +1588,7 @@ void TimeProfilingPassesHandler::registerCallbacks(
15891588
}
15901589

15911590
void TimeProfilingPassesHandler::runBeforePass(StringRef PassID, Any IR) {
1592-
timeTraceProfilerBegin(PassID, getIRName(IR, true));
1591+
timeTraceProfilerBegin(PassID, getIRName(IR));
15931592
}
15941593

15951594
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
@@ -2653,7 +2653,6 @@ cc_library(
26532653
":CodeGen",
26542654
":Core",
26552655
":Coroutines",
2656-
":Demangle",
26572656
":HipStdPar",
26582657
":IPO",
26592658
":IRPrinter",

0 commit comments

Comments
 (0)