summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-05-18 12:15:34 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-05-18 12:15:34 +0000
commitab7be75e3f8fafca83da6556b55ea07e6f4ae7a7 (patch)
tree301fd75cbebdd0eabf96e65432b9389da17fd433 /llvm/lib/MC/MCContext.cpp
parent0e704f7fcdf3231cf5b6ae7e758b74e47c3a9c05 (diff)
downloadbcm5719-llvm-ab7be75e3f8fafca83da6556b55ea07e6f4ae7a7.tar.gz
bcm5719-llvm-ab7be75e3f8fafca83da6556b55ea07e6f4ae7a7.zip
Simplify MCContext::(Next|Get)Instance
- Allocate MCLabels in the context so they don't leak. - Avoid duplicated densemap lookup. llvm-svn: 104020
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r--llvm/lib/MC/MCContext.cpp32
1 files changed, 8 insertions, 24 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 5cc72e8e9f5..53ffc9409a6 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -73,33 +73,17 @@ MCSymbol *MCContext::CreateTempSymbol() {
}
unsigned MCContext::NextInstance(int64_t LocalLabelVal) {
- unsigned Instance;
- MCLabel *Label;
- Label = Instances[LocalLabelVal];
- if (Label) {
- Instance = Label->incInstance();
- }
- else {
- Instance = 1;
- Label = new MCLabel(Instance);
- Instances[LocalLabelVal] = Label;
- }
- return Instance;
+ MCLabel *&Label = Instances[LocalLabelVal];
+ if (!Label)
+ Label = new (*this) MCLabel(0);
+ return Label->incInstance();
}
unsigned MCContext::GetInstance(int64_t LocalLabelVal) {
- int Instance;
- MCLabel *Label;
- Label = Instances[LocalLabelVal];
- if (Label) {
- Instance = Label->getInstance();
- }
- else {
- Instance = 0;
- Label = new MCLabel(Instance);
- Instances[LocalLabelVal] = Label;
- }
- return Instance;
+ MCLabel *&Label = Instances[LocalLabelVal];
+ if (!Label)
+ Label = new (*this) MCLabel(0);
+ return Label->getInstance();
}
MCSymbol *MCContext::CreateDirectionalLocalSymbol(int64_t LocalLabelVal) {
OpenPOWER on IntegriCloud