Browse Source

Use the raw import ID, not the tagged ID, as an array index. (#7058)

Previously we'd create a *huge* array here as the tagged ID produced a
very large index value, and spend multiple seconds allocating it and
filling it with zeroes the first time `GetCppLocation` was called.

Reduces test runtime from 26s -> 6s wall time, 450s -> 320s total time
on my machine for `-c dbg`.
Richard Smith 2 weeks ago
parent
commit
5b1de7633c
1 changed files with 1 additions and 1 deletions
  1. 1 1
      toolchain/check/cpp/location.cpp

+ 1 - 1
toolchain/check/cpp/location.cpp

@@ -26,7 +26,7 @@ static auto GetFileInfo(Context& context, SemIR::CheckIRId ir_id) -> FileInfo {
   if (ir_id != context.sem_ir().check_ir_id()) {
     auto import_id = context.check_ir_map().Get(ir_id);
     CARBON_CHECK(import_id.has_value());
-    file_index = import_id.index + 1;
+    file_index = context.import_irs().GetRawIndex(import_id) + 1;
 
     sem_ir = context.import_irs().Get(import_id).sem_ir;
     CARBON_CHECK(sem_ir, "Node location in nonexistent IR");