Skip to content

Commit d7ba6c6

Browse files
committed
store std::string, print before BB identifier
1 parent d96cb1d commit d7ba6c6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

include/swift/SIL/SILModule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class SILModule {
164164
using CoverageMapCollectionType =
165165
llvm::MapVector<StringRef, SILCoverageMap *>;
166166
using BasicBlockNameMapType =
167-
llvm::DenseMap<const SILBasicBlock *, llvm::StringRef>;
167+
llvm::DenseMap<const SILBasicBlock *, std::string>;
168168

169169
enum class LinkingMode : uint8_t {
170170
/// Link functions with non-public linkage. Used by the mandatory pipeline.
@@ -455,7 +455,7 @@ class SILModule {
455455

456456
void setBasicBlockName(const SILBasicBlock *block, StringRef name) {
457457
#if NDEBUG
458-
basicBlockNames[block] = name;
458+
basicBlockNames[block] = name.str();
459459
#endif
460460
}
461461
Optional<StringRef> getBasicBlockName(const SILBasicBlock *block) {
@@ -464,7 +464,7 @@ class SILModule {
464464
if (Known == basicBlockNames.end())
465465
return None;
466466

467-
return Known->second;
467+
return StringRef(Known->second);
468468
#else
469469
return None;
470470
#endif

lib/SIL/IR/SILPrinter.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,12 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
791791
// the block header.
792792
printBlockArgumentUses(BB);
793793

794+
// If the basic block has a name available, print it as well
795+
auto debugName = BB->getDebugName();
796+
if (debugName.hasValue()) {
797+
*this << "// " << debugName.getValue() << '\n';
798+
}
799+
794800
// Then print the name of our block, the arguments, and the block colon.
795801
*this << Ctx.getID(BB);
796802
printBlockArguments(BB);
@@ -816,12 +822,6 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
816822
for (auto Id : PredIDs)
817823
*this << ' ' << Id;
818824
}
819-
820-
// If the basic block has a name available, print it as well
821-
auto debugName = BB->getDebugName();
822-
if (debugName.hasValue()) {
823-
*this << " /// " << debugName.getValue();
824-
}
825825
*this << '\n';
826826

827827
const auto &SM = BB->getModule().getASTContext().SourceMgr;

0 commit comments

Comments
 (0)