@@ -163,6 +163,8 @@ class SILModule {
163163 llvm::ilist<SILDifferentiabilityWitness>;
164164 using CoverageMapCollectionType =
165165 llvm::MapVector<StringRef, SILCoverageMap *>;
166+ using BasicBlockNameMapType =
167+ llvm::DenseMap<const SILBasicBlock *, std::string>;
166168
167169 enum class LinkingMode : uint8_t {
168170 // / Link functions with non-public linkage. Used by the mandatory pipeline.
@@ -360,6 +362,10 @@ class SILModule {
360362 // / Action to be executed for serializing the SILModule.
361363 ActionCallback SerializeSILAction;
362364
365+ #if NDEBUG
366+ BasicBlockNameMapType basicBlockNames;
367+ #endif
368+
363369 SILModule (llvm::PointerUnion<FileUnit *, ModuleDecl *> context,
364370 Lowering::TypeConverter &TC, const SILOptions &Options);
365371
@@ -447,6 +453,23 @@ class SILModule {
447453 void setSerialized () { serialized = true ; }
448454 bool isSerialized () const { return serialized; }
449455
456+ void setBasicBlockName (const SILBasicBlock *block, StringRef name) {
457+ #if NDEBUG
458+ basicBlockNames[block] = name.str ();
459+ #endif
460+ }
461+ Optional<StringRef> getBasicBlockName (const SILBasicBlock *block) {
462+ #if NDEBUG
463+ auto Known = basicBlockNames.find (block);
464+ if (Known == basicBlockNames.end ())
465+ return None;
466+
467+ return StringRef (Known->second );
468+ #else
469+ return None;
470+ #endif
471+ }
472+
450473 // / Serialize a SIL module using the configured SerializeSILAction.
451474 void serialize ();
452475
0 commit comments