Cleanup of the [SU]ADDO type legalization code. Patch by Duncan!
[oota-llvm.git] / lib / AsmParser / llvmAsmParser.y
index 9b29cdd76c6f85c34332a11db12af3d5d842b124..af8e3afee3f6213abce006c314634c24dbac03af 100644 (file)
@@ -140,6 +140,7 @@ static struct PerModuleInfo {
     GlobalValue *Ret = 0;
     if (I != GlobalRefs.end()) {
       Ret = I->second;
+      I->first.second.destroy();
       GlobalRefs.erase(I);
     }
     return Ret;
@@ -307,8 +308,10 @@ static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
   }
 
   std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
-  if (I != CurModule.LateResolveTypes.end())
+  if (I != CurModule.LateResolveTypes.end()) {
+    D.destroy();
     return I->second;
+  }
 
   Type *Typ = OpaqueType::get();
   CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
@@ -415,6 +418,7 @@ static Value *getExistingVal(const Type *Ty, const ValID &D) {
 
     {
       APSInt Tmp = *D.ConstPoolInt;
+      D.destroy();
       Tmp.extOrTrunc(Ty->getPrimitiveSizeInBits());
       return ConstantInt::get(Tmp);
     }
@@ -433,7 +437,11 @@ static Value *getExistingVal(const Type *Ty, const ValID &D) {
       D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
                              &ignored);
     }
-    return ConstantFP::get(*D.ConstPoolFP);
+    {
+      ConstantFP *tmp = ConstantFP::get(*D.ConstPoolFP);
+      D.destroy();
+      return tmp;
+    }
 
   case ValID::ConstNullVal:      // Is it a null value?
     if (!isa<PointerType>(Ty)) {
@@ -1129,7 +1137,7 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
 
 // Function Attributes
 %token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
-%token READNONE READONLY GC OPTSIZE NOINLINE ALWAYSINLINE
+%token READNONE READONLY GC OPTSIZE NOINLINE ALWAYSINLINE SSP SSPREQ
 
 // Visibility Styles
 %token DEFAULT HIDDEN PROTECTED
@@ -1297,7 +1305,9 @@ FuncAttr      : NORETURN { $$ = Attribute::NoReturn; }
               | READONLY { $$ = Attribute::ReadOnly; }
               | NOINLINE { $$ = Attribute::NoInline; }
               | ALWAYSINLINE { $$ = Attribute::AlwaysInline; }
-              | OPTSIZE { $$ = Attribute::OptimizeForSize; }
+              | OPTSIZE  { $$ = Attribute::OptimizeForSize; }
+              | SSP      { $$ = Attribute::StackProtect; }
+              | SSPREQ   { $$ = Attribute::StackProtectReq; }
               ;
 
 OptFuncAttrs  : /* empty */ { $$ = Attribute::None; }