Skip to content

Commit abaf13a

Browse files
authored
Revert "Reapply "Add source file name for template instantiations in -ftime-trace"" (#99731)
Reverts #99545 There were a couple of issues reported in the PR: a sanitizer warning (https://lab.llvm.org/buildbot/#/builders/164/builds/1246/steps/14/logs/stdio) and a tmp file accidentally included in the commit.
1 parent cfc2260 commit abaf13a

File tree

13 files changed

+64
-225
lines changed

13 files changed

+64
-225
lines changed

a-abfdec1d.o.tmp

Whitespace-only changes.

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,9 +750,6 @@ Improvements to Clang's time-trace
750750
- Clang now specifies that using ``auto`` in a lambda parameter is a C++14 extension when
751751
appropriate. (`#46059: <https://github.com/llvm/llvm-project/issues/46059>`_).
752752

753-
- Clang now adds source file infomation for template instantiations as ``event["args"]["filename"]``. This
754-
added behind an option ``-ftime-trace-verbose``. This is expected to increase the size of trace by 2-3 times.
755-
756753
Improvements to Coverage Mapping
757754
--------------------------------
758755

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3998,10 +3998,6 @@ def ftime_trace_granularity_EQ : Joined<["-"], "ftime-trace-granularity=">, Grou
39983998
HelpText<"Minimum time granularity (in microseconds) traced by time profiler">,
39993999
Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
40004000
MarshallingInfoInt<FrontendOpts<"TimeTraceGranularity">, "500u">;
4001-
def ftime_trace_verbose : Joined<["-"], "ftime-trace-verbose">, Group<f_Group>,
4002-
HelpText<"Make time trace capture verbose event details (e.g. source filenames). This can increase the size of the output by 2-3 times">,
4003-
Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
4004-
MarshallingInfoFlag<FrontendOpts<"TimeTraceVerbose">>;
40054001
def ftime_trace_EQ : Joined<["-"], "ftime-trace=">, Group<f_Group>,
40064002
HelpText<"Similar to -ftime-trace. Specify the JSON file or a directory which will contain the JSON file">,
40074003
Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,

clang/include/clang/Frontend/FrontendOptions.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,6 @@ class FrontendOptions {
580580
/// Minimum time granularity (in microseconds) traced by time profiler.
581581
unsigned TimeTraceGranularity;
582582

583-
/// Make time trace capture verbose event details (e.g. source filenames).
584-
/// This can increase the size of the output by 2-3 times.
585-
LLVM_PREFERRED_TYPE(bool)
586-
unsigned TimeTraceVerbose : 1;
587-
588583
/// Path which stores the output files for -ftime-trace
589584
std::string TimeTracePath;
590585

@@ -606,8 +601,7 @@ class FrontendOptions {
606601
EmitSymbolGraph(false), EmitExtensionSymbolGraphs(false),
607602
EmitSymbolGraphSymbolLabelsForTesting(false),
608603
EmitPrettySymbolGraphs(false), GenReducedBMI(false),
609-
UseClangIRPipeline(false), TimeTraceGranularity(500),
610-
TimeTraceVerbose(false) {}
604+
UseClangIRPipeline(false), TimeTraceGranularity(500) {}
611605

612606
/// getInputKindForExtension - Return the appropriate input kind for a file
613607
/// extension. For example, "c" would return Language::C.

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6757,7 +6757,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
67576757
if (const char *Name = C.getTimeTraceFile(&JA)) {
67586758
CmdArgs.push_back(Args.MakeArgString("-ftime-trace=" + Twine(Name)));
67596759
Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
6760-
Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_verbose);
67616760
}
67626761

67636762
if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,16 +3426,11 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
34263426
return true;
34273427

34283428
llvm::TimeTraceScope TimeScope("InstantiateClass", [&]() {
3429-
llvm::TimeTraceMetadata M;
3430-
llvm::raw_string_ostream OS(M.Detail);
3429+
std::string Name;
3430+
llvm::raw_string_ostream OS(Name);
34313431
Instantiation->getNameForDiagnostic(OS, getPrintingPolicy(),
34323432
/*Qualified=*/true);
3433-
if (llvm::isTimeTraceVerbose()) {
3434-
auto Loc = SourceMgr.getExpansionLoc(Instantiation->getLocation());
3435-
M.File = SourceMgr.getFilename(Loc);
3436-
M.Line = SourceMgr.getExpansionLineNumber(Loc);
3437-
}
3438-
return M;
3433+
return Name;
34393434
});
34403435

34413436
Pattern = PatternDef;

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4966,16 +4966,11 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
49664966
}
49674967

49684968
llvm::TimeTraceScope TimeScope("InstantiateFunction", [&]() {
4969-
llvm::TimeTraceMetadata M;
4970-
llvm::raw_string_ostream OS(M.Detail);
4969+
std::string Name;
4970+
llvm::raw_string_ostream OS(Name);
49714971
Function->getNameForDiagnostic(OS, getPrintingPolicy(),
49724972
/*Qualified=*/true);
4973-
if (llvm::isTimeTraceVerbose()) {
4974-
auto Loc = SourceMgr.getExpansionLoc(Function->getLocation());
4975-
M.File = SourceMgr.getFilename(Loc);
4976-
M.Line = SourceMgr.getExpansionLineNumber(Loc);
4977-
}
4978-
return M;
4973+
return Name;
49794974
});
49804975

49814976
// If we're performing recursive template instantiation, create our own

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: rm -rf %t && mkdir %t && cd %t
2-
// RUN: %clangxx -S -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose -o out %s
2+
// RUN: %clangxx -S -ftime-trace -ftime-trace-granularity=0 -o out %s
33
// RUN: %python %S/ftime-trace-sections.py < out.json
44

55
template <typename T>

clang/test/Driver/ftime-trace.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// RUN: rm -rf %t && mkdir -p %t && cd %t
2-
// RUN: %clangxx -S -no-canonical-prefixes -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose -o out %s
2+
// RUN: %clangxx -S -no-canonical-prefixes -ftime-trace -ftime-trace-granularity=0 -o out %s
33
// RUN: cat out.json \
44
// RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
55
// RUN: | FileCheck %s
6-
// RUN: %clangxx -S -no-canonical-prefixes -ftime-trace=new-name.json -ftime-trace-granularity=0 -ftime-trace-verbose -o out %s
6+
// RUN: %clangxx -S -no-canonical-prefixes -ftime-trace=new-name.json -ftime-trace-granularity=0 -o out %s
77
// RUN: cat new-name.json \
88
// RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
99
// RUN: | FileCheck %s
1010
// RUN: mkdir dir1 dir2
11-
// RUN: %clangxx -S -no-canonical-prefixes -ftime-trace=dir1 -ftime-trace-granularity=0 -ftime-trace-verbose -o out %s
11+
// RUN: %clangxx -S -no-canonical-prefixes -ftime-trace=dir1 -ftime-trace-granularity=0 -o out %s
1212
// RUN: cat dir1/out.json \
1313
// RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
1414
// RUN: | FileCheck %s
15-
// RUN: %clangxx -S -no-canonical-prefixes -ftime-trace=dir2/ -ftime-trace-granularity=0 -ftime-trace-verbose -o out %s
15+
// RUN: %clangxx -S -no-canonical-prefixes -ftime-trace=dir2/ -ftime-trace-granularity=0 -o out %s
1616
// RUN: cat dir2/out.json \
1717
// RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
1818
// RUN: | FileCheck %s
@@ -34,33 +34,32 @@
3434
// RUN: mkdir d e f && cp %s d/a.cpp && touch d/b.c
3535

3636
/// TODO: Support -fno-integrated-as.
37-
// RUN: %clang -### -c -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose -fintegrated-as d/a.cpp -o e/a.o 2>&1 | FileCheck %s --check-prefix=COMPILE1
38-
// COMPILE1: -cc1{{.*}} "-ftime-trace=e/a.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose"
37+
// RUN: %clang -### -c -ftime-trace -ftime-trace-granularity=0 -fintegrated-as d/a.cpp -o e/a.o 2>&1 | FileCheck %s --check-prefix=COMPILE1
38+
// COMPILE1: -cc1{{.*}} "-ftime-trace=e/a.json" "-ftime-trace-granularity=0"
3939

40-
// RUN: %clang -### -c -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp d/b.c -dumpdir f/ 2>&1 | FileCheck %s --check-prefix=COMPILE2
41-
// COMPILE2: -cc1{{.*}} "-ftime-trace=f/a.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose"
42-
// COMPILE2: -cc1{{.*}} "-ftime-trace=f/b.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose"
40+
// RUN: %clang -### -c -ftime-trace -ftime-trace-granularity=0 d/a.cpp d/b.c -dumpdir f/ 2>&1 | FileCheck %s --check-prefix=COMPILE2
41+
// COMPILE2: -cc1{{.*}} "-ftime-trace=f/a.json" "-ftime-trace-granularity=0"
42+
// COMPILE2: -cc1{{.*}} "-ftime-trace=f/b.json" "-ftime-trace-granularity=0"
4343

4444
/// -o specifies the link output. Create ${output}-${basename}.json.
45-
// RUN: %clang -### -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp d/b.c -o e/x 2>&1 | FileCheck %s --check-prefix=LINK1
46-
// LINK1: -cc1{{.*}} "-ftime-trace=e/x-a.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose"
47-
// LINK1: -cc1{{.*}} "-ftime-trace=e/x-b.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose"
45+
// RUN: %clang -### -ftime-trace -ftime-trace-granularity=0 d/a.cpp d/b.c -o e/x 2>&1 | FileCheck %s --check-prefix=LINK1
46+
// LINK1: -cc1{{.*}} "-ftime-trace=e/x-a.json" "-ftime-trace-granularity=0"
47+
// LINK1: -cc1{{.*}} "-ftime-trace=e/x-b.json" "-ftime-trace-granularity=0"
4848

4949
/// -dumpdir is f/g, not ending with a path separator. We create f/g${basename}.json.
50-
// RUN: %clang -### -ftime-trace -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp d/b.c -o e/x -dumpdir f/g 2>&1 | FileCheck %s --check-prefix=LINK2
51-
// LINK2: -cc1{{.*}} "-ftime-trace=f/ga.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose"
52-
// LINK2: -cc1{{.*}} "-ftime-trace=f/gb.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose"
50+
// RUN: %clang -### -ftime-trace -ftime-trace-granularity=0 d/a.cpp d/b.c -o e/x -dumpdir f/g 2>&1 | FileCheck %s --check-prefix=LINK2
51+
// LINK2: -cc1{{.*}} "-ftime-trace=f/ga.json" "-ftime-trace-granularity=0"
52+
// LINK2: -cc1{{.*}} "-ftime-trace=f/gb.json" "-ftime-trace-granularity=0"
5353

54-
// RUN: %clang -### -ftime-trace=e -ftime-trace-granularity=0 -ftime-trace-verbose d/a.cpp d/b.c -o f/x -dumpdir f/ 2>&1 | FileCheck %s --check-prefix=LINK3
55-
// LINK3: -cc1{{.*}} "-ftime-trace=e{{/|\\\\}}a-{{[^.]*}}.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose"
56-
// LINK3: -cc1{{.*}} "-ftime-trace=e{{/|\\\\}}b-{{[^.]*}}.json" "-ftime-trace-granularity=0" "-ftime-trace-verbose"
54+
// RUN: %clang -### -ftime-trace=e -ftime-trace-granularity=0 d/a.cpp d/b.c -o f/x -dumpdir f/ 2>&1 | FileCheck %s --check-prefix=LINK3
55+
// LINK3: -cc1{{.*}} "-ftime-trace=e{{/|\\\\}}a-{{[^.]*}}.json" "-ftime-trace-granularity=0"
56+
// LINK3: -cc1{{.*}} "-ftime-trace=e{{/|\\\\}}b-{{[^.]*}}.json" "-ftime-trace-granularity=0"
5757

58-
// RUN: %clang -### -ftime-trace -ftime-trace=e -ftime-trace-granularity=1 -ftime-trace-verbose -xassembler d/a.cpp 2>&1 | \
58+
// RUN: %clang -### -ftime-trace -ftime-trace=e -ftime-trace-granularity=1 -xassembler d/a.cpp 2>&1 | \
5959
// RUN: FileCheck %s --check-prefix=UNUSED
6060
// UNUSED: warning: argument unused during compilation: '-ftime-trace'
6161
// UNUSED-NEXT: warning: argument unused during compilation: '-ftime-trace=e'
6262
// UNUSED-NEXT: warning: argument unused during compilation: '-ftime-trace-granularity=1'
63-
// UNUSED-NEXT: warning: argument unused during compilation: '-ftime-trace-verbose'
6463
// UNUSED-NOT: warning:
6564

6665
template <typename T>

clang/tools/driver/cc1_main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
241241

242242
if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
243243
llvm::timeTraceProfilerInitialize(
244-
Clang->getFrontendOpts().TimeTraceGranularity, Argv0,
245-
Clang->getFrontendOpts().TimeTraceVerbose);
244+
Clang->getFrontendOpts().TimeTraceGranularity, Argv0);
246245
}
247246
// --print-supported-cpus takes priority over the actual compilation.
248247
if (Clang->getFrontendOpts().PrintSupportedCPUs)

0 commit comments

Comments
 (0)