Skip to content

Commit 1fc3704

Browse files
committed
[CodeGen] Use temp symbol for MBBs
Internal label names never occur in the symbol table, so when using an object streamer, there's no point in constructing these names and then adding them to hash tables -- they are never visible in the output. This changes label names to use the PrivateGlobalPrefix instead of the PrivateLabelPrefix. These are the same for all targets, however, so this seems acceptable.
1 parent cc158d4 commit 1fc3704

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

llvm/lib/CodeGen/MachineBasicBlock.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,18 @@ MCSymbol *MachineBasicBlock::getSymbol() const {
7979
Suffix = (Suffix + Twine(".__part.") + Twine(SectionID.Number)).str();
8080
}
8181
CachedMCSymbol = Ctx.getOrCreateSymbol(MF->getName() + Suffix);
82-
} else {
82+
} else if (hasLabelMustBeEmitted()) {
83+
// If the block occurs as label in inline assembly, parsing the assembly
84+
// needs an actual label name.
8385
const StringRef Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix();
8486
CachedMCSymbol = Ctx.getOrCreateSymbol(Twine(Prefix) + "BB" +
8587
Twine(MF->getFunctionNumber()) +
8688
"_" + Twine(getNumber()));
89+
} else {
90+
CachedMCSymbol = Ctx.createTempSymbol("BB" +
91+
Twine(MF->getFunctionNumber()) +
92+
"_" + Twine(getNumber()),
93+
/*AlwaysAddSuffix=*/false);
8794
}
8895
}
8996
return CachedMCSymbol;
@@ -104,10 +111,10 @@ MCSymbol *MachineBasicBlock::getEndSymbol() const {
104111
if (!CachedEndMCSymbol) {
105112
const MachineFunction *MF = getParent();
106113
MCContext &Ctx = MF->getContext();
107-
auto Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix();
108-
CachedEndMCSymbol = Ctx.getOrCreateSymbol(Twine(Prefix) + "BB_END" +
109-
Twine(MF->getFunctionNumber()) +
110-
"_" + Twine(getNumber()));
114+
CachedEndMCSymbol = Ctx.createTempSymbol("BB_END" +
115+
Twine(MF->getFunctionNumber()) +
116+
"_" + Twine(getNumber()),
117+
/*AlwaysAddSuffix=*/false);
111118
}
112119
return CachedEndMCSymbol;
113120
}

llvm/test/CodeGen/AArch64/branch-relax-cross-section.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ body: |
473473
; INDIRECT-NEXT: successors: %bb.1
474474
; INDIRECT-NEXT: liveins: $x16
475475
; INDIRECT-NEXT: {{ $}}
476-
; INDIRECT-NEXT: $[[SCAVENGED_REGISTER:x[0-9]+]] = ADRP target-flags(aarch64-page) <mcsymbol .LBB5_1>
477-
; INDIRECT-NEXT: $[[SCAVENGED_REGISTER]] = ADDXri $[[SCAVENGED_REGISTER]], target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol .LBB5_1>, 0
476+
; INDIRECT-NEXT: $[[SCAVENGED_REGISTER:x[0-9]+]] = ADRP target-flags(aarch64-page) <mcsymbol >
477+
; INDIRECT-NEXT: $[[SCAVENGED_REGISTER]] = ADDXri $[[SCAVENGED_REGISTER]], target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol >, 0
478478
; INDIRECT-NEXT: BR $[[SCAVENGED_REGISTER]]
479479
480480
bb.0.entry:

0 commit comments

Comments
 (0)