Migrate all CARBON_VLOG to the format string variant. (#4284)

This mostly uses a hilarious set of regular expressions to mechanically
switch all but two uses, and then manually fixed the last two. There
weren't too many.

Also simplifies the `vlog` implementation now that it's all going
through a format string.

This alone has a nice impact on parse and check of about 2% and 1%
respectively. The impact on lex in my timings looks like noise (no
change in instruction count, unlike the other phases).
```
name                                               old cpu/op   new cpu/op   delta
BM_CompileAPIFileDenseDecls<Phase::Lex>/256        39.1µs ± 3%  38.1µs ± 2%  -2.42%  (p=0.000 n=20+19)
BM_CompileAPIFileDenseDecls<Phase::Lex>/1024        187µs ± 3%   183µs ± 1%  -2.30%  (p=0.000 n=20+20)
BM_CompileAPIFileDenseDecls<Phase::Lex>/4096        776µs ± 4%   756µs ± 1%  -2.62%  (p=0.000 n=20+20)
BM_CompileAPIFileDenseDecls<Phase::Lex>/16384      3.36ms ± 1%  3.33ms ± 1%  -0.90%  (p=0.000 n=18+18)
BM_CompileAPIFileDenseDecls<Phase::Lex>/65536      14.4ms ± 2%  14.2ms ± 1%  -1.41%  (p=0.000 n=20+20)
BM_CompileAPIFileDenseDecls<Phase::Lex>/262144     65.7ms ± 1%  65.2ms ± 2%  -0.86%  (p=0.002 n=19+20)
BM_CompileAPIFileDenseDecls<Phase::Parse>/256      87.5µs ± 1%  86.3µs ± 1%  -1.43%  (p=0.000 n=19+20)
BM_CompileAPIFileDenseDecls<Phase::Parse>/1024      438µs ± 2%   431µs ± 1%  -1.54%  (p=0.000 n=19+20)
BM_CompileAPIFileDenseDecls<Phase::Parse>/4096     1.81ms ± 2%  1.77ms ± 1%  -2.12%  (p=0.000 n=20+20)
BM_CompileAPIFileDenseDecls<Phase::Parse>/16384    7.54ms ± 1%  7.43ms ± 1%  -1.44%  (p=0.000 n=19+20)
BM_CompileAPIFileDenseDecls<Phase::Parse>/65536    31.2ms ± 1%  30.6ms ± 1%  -2.03%  (p=0.000 n=20+20)
BM_CompileAPIFileDenseDecls<Phase::Parse>/262144    133ms ± 1%   130ms ± 1%  -1.85%  (p=0.000 n=20+20)
BM_CompileAPIFileDenseDecls<Phase::Check>/256       882µs ± 1%   878µs ± 1%  -0.52%  (p=0.001 n=17+19)
BM_CompileAPIFileDenseDecls<Phase::Check>/1024     1.90ms ± 2%  1.88ms ± 1%  -1.17%  (p=0.000 n=19+19)
BM_CompileAPIFileDenseDecls<Phase::Check>/4096     5.85ms ± 2%  5.76ms ± 1%  -1.43%  (p=0.000 n=20+19)
BM_CompileAPIFileDenseDecls<Phase::Check>/16384    22.2ms ± 2%  21.9ms ± 2%  -1.20%  (p=0.000 n=20+19)
BM_CompileAPIFileDenseDecls<Phase::Check>/65536    91.2ms ± 2%  90.3ms ± 1%  -1.00%  (p=0.000 n=20+19)
BM_CompileAPIFileDenseDecls<Phase::Check>/262144    382ms ± 1%   380ms ± 1%  -0.51%  (p=0.003 n=18+19)
```
This commit is contained in:
Chandler Carruth
2024-09-11 12:11:23 +00:00
committed by GitHub
parent e48101b608
commit 0c8ab663c9
13 changed files with 86 additions and 156 deletions
+9 -10
View File
@@ -101,8 +101,8 @@ auto Context::FinishInst(SemIR::InstId inst_id, SemIR::Inst inst) -> void {
auto const_id = TryEvalInst(*this, inst_id, inst);
constant_values().Set(inst_id, const_id);
if (const_id.is_constant()) {
CARBON_VLOG() << "Constant: " << inst << " -> "
<< constant_values().GetInstId(const_id) << "\n";
CARBON_VLOG("Constant: {0} -> {1}\n", inst,
constant_values().GetInstId(const_id));
// If the constant value is symbolic, track that we need to substitute into
// it.
@@ -150,7 +150,7 @@ auto Context::CheckCompatibleImportedNodeKind(
auto Context::AddInstInNoBlock(SemIR::LocIdAndInst loc_id_and_inst)
-> SemIR::InstId {
auto inst_id = sem_ir().insts().AddInNoBlock(loc_id_and_inst);
CARBON_VLOG() << "AddInst: " << loc_id_and_inst.inst << "\n";
CARBON_VLOG("AddInst: {0}\n", loc_id_and_inst.inst);
FinishInst(inst_id, loc_id_and_inst.inst);
return inst_id;
}
@@ -164,7 +164,7 @@ auto Context::AddInst(SemIR::LocIdAndInst loc_id_and_inst) -> SemIR::InstId {
auto Context::AddPlaceholderInstInNoBlock(SemIR::LocIdAndInst loc_id_and_inst)
-> SemIR::InstId {
auto inst_id = sem_ir().insts().AddInNoBlock(loc_id_and_inst);
CARBON_VLOG() << "AddPlaceholderInst: " << loc_id_and_inst.inst << "\n";
CARBON_VLOG("AddPlaceholderInst: {0}\n", loc_id_and_inst.inst);
constant_values().Set(inst_id, SemIR::ConstantId::Invalid);
return inst_id;
}
@@ -179,22 +179,21 @@ auto Context::AddPlaceholderInst(SemIR::LocIdAndInst loc_id_and_inst)
auto Context::AddConstant(SemIR::Inst inst, bool is_symbolic)
-> SemIR::ConstantId {
auto const_id = constants().GetOrAdd(inst, is_symbolic);
CARBON_VLOG() << "AddConstant: " << inst << "\n";
CARBON_VLOG("AddConstant: {0}\n", inst);
return const_id;
}
auto Context::ReplaceLocIdAndInstBeforeConstantUse(
SemIR::InstId inst_id, SemIR::LocIdAndInst loc_id_and_inst) -> void {
sem_ir().insts().SetLocIdAndInst(inst_id, loc_id_and_inst);
CARBON_VLOG() << "ReplaceInst: " << inst_id << " -> " << loc_id_and_inst.inst
<< "\n";
CARBON_VLOG("ReplaceInst: {0} -> {1}\n", inst_id, loc_id_and_inst.inst);
FinishInst(inst_id, loc_id_and_inst.inst);
}
auto Context::ReplaceInstBeforeConstantUse(SemIR::InstId inst_id,
SemIR::Inst inst) -> void {
sem_ir().insts().Set(inst_id, inst);
CARBON_VLOG() << "ReplaceInst: " << inst_id << " -> " << inst << "\n";
CARBON_VLOG("ReplaceInst: {0} -> {1}\n", inst_id, inst);
FinishInst(inst_id, inst);
}
@@ -678,8 +677,8 @@ auto Context::SetBlockArgResultBeforeConstantUse(SemIR::InstId select_id,
}
if (const_id.is_constant()) {
CARBON_VLOG() << "Constant: " << insts().Get(select_id) << " -> "
<< constant_values().GetInstId(const_id) << "\n";
CARBON_VLOG("Constant: {0} -> {1}\n", insts().Get(select_id),
constant_values().GetInstId(const_id));
constant_values().Set(select_id, const_id);
}
}