diff options
author | Eli Bendersky <eliben@google.com> | 2013-04-22 21:21:08 +0000 |
---|---|---|
committer | Eli Bendersky <eliben@google.com> | 2013-04-22 21:21:08 +0000 |
commit | 58b04b7e2eec3332f1fcbdce679912d323aa29f3 (patch) | |
tree | 319e031585e2ea9808280fff7d9844f53910308f /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | 365e3359ab11f71091d3414b96600700f3314862 (diff) | |
download | bcm5719-llvm-58b04b7e2eec3332f1fcbdce679912d323aa29f3.tar.gz bcm5719-llvm-58b04b7e2eec3332f1fcbdce679912d323aa29f3.zip |
Optimize MachineBasicBlock::getSymbol by caching the symbol. Since the symbol
name computation is expensive, this helps save about 25% of the time spent in
this function.
llvm-svn: 180049
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 898e165feea..78e9950e5ef 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -37,7 +37,7 @@ using namespace llvm; MachineBasicBlock::MachineBasicBlock(MachineFunction &mf, const BasicBlock *bb) : BB(bb), Number(-1), xParent(&mf), Alignment(0), IsLandingPad(false), - AddressTaken(false) { + AddressTaken(false), CachedMCSymbol(NULL) { Insts.Parent = this; } @@ -48,12 +48,16 @@ MachineBasicBlock::~MachineBasicBlock() { /// getSymbol - Return the MCSymbol for this basic block. /// MCSymbol *MachineBasicBlock::getSymbol() const { - const MachineFunction *MF = getParent(); - MCContext &Ctx = MF->getContext(); - const char *Prefix = Ctx.getAsmInfo().getPrivateGlobalPrefix(); - return Ctx.GetOrCreateSymbol(Twine(Prefix) + "BB" + - Twine(MF->getFunctionNumber()) + "_" + - Twine(getNumber())); + if (!CachedMCSymbol) { + const MachineFunction *MF = getParent(); + MCContext &Ctx = MF->getContext(); + const char *Prefix = Ctx.getAsmInfo().getPrivateGlobalPrefix(); + CachedMCSymbol = Ctx.GetOrCreateSymbol(Twine(Prefix) + "BB" + + Twine(MF->getFunctionNumber()) + + "_" + Twine(getNumber())); + } + + return CachedMCSymbol; } |