Add some missing checks for the case where the extract_subregs are
[oota-llvm.git] / lib / MC / MCContext.cpp
index 5cc72e8e9f555162763198f37c20b48cc1d3d4bd..53ffc9409a6459e242bbf634a539a2a689c1f079 100644 (file)
@@ -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) {