[SIL] Allow giving debug names to SILBasicBlocks

This commit is contained in:
Konrad `ktoso` Malawski
2022-02-01 14:22:49 +09:00
parent 56a614adbb
commit d96cb1dbaf
6 changed files with 47 additions and 0 deletions

View File

@@ -163,6 +163,8 @@ public:
llvm::ilist<SILDifferentiabilityWitness>;
using CoverageMapCollectionType =
llvm::MapVector<StringRef, SILCoverageMap *>;
using BasicBlockNameMapType =
llvm::DenseMap<const SILBasicBlock *, llvm::StringRef>;
enum class LinkingMode : uint8_t {
/// Link functions with non-public linkage. Used by the mandatory pipeline.
@@ -360,6 +362,10 @@ private:
/// Action to be executed for serializing the SILModule.
ActionCallback SerializeSILAction;
#if NDEBUG
BasicBlockNameMapType basicBlockNames;
#endif
SILModule(llvm::PointerUnion<FileUnit *, ModuleDecl *> context,
Lowering::TypeConverter &TC, const SILOptions &Options);
@@ -447,6 +453,23 @@ public:
void setSerialized() { serialized = true; }
bool isSerialized() const { return serialized; }
void setBasicBlockName(const SILBasicBlock *block, StringRef name) {
#if NDEBUG
basicBlockNames[block] = name;
#endif
}
Optional<StringRef> getBasicBlockName(const SILBasicBlock *block) {
#if NDEBUG
auto Known = basicBlockNames.find(block);
if (Known == basicBlockNames.end())
return None;
return Known->second;
#else
return None;
#endif
}
/// Serialize a SIL module using the configured SerializeSILAction.
void serialize();