[llvm-commits] [llvm-gcc-4.2] r45220 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Duncan Sands baldrick at free.fr
Wed Dec 19 13:19:51 PST 2007


Author: baldrick
Date: Wed Dec 19 15:19:51 2007
New Revision: 45220

URL: http://llvm.org/viewvc/llvm-project?rev=45220&view=rev
Log:
Simplify adding nounwind attributes using new helpers.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=45220&r1=45219&r2=45220&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Dec 19 15:19:51 2007
@@ -2344,16 +2344,10 @@
     }
   }
 
-  if (NoUnwind && !(PAL && PAL->paramHasAttr(0, ParamAttr::NoUnwind))) {
+  if (NoUnwind)
     // This particular call does not unwind even though the callee may
     // unwind in general.  Add the 'nounwind' attribute to the call.
-    uint16_t RAttributes = PAL ? PAL->getParamAttrs(0) : 0;
-    RAttributes |= ParamAttr::NoUnwind;
-
-    ParamAttrsVector modVec;
-    modVec.push_back(ParamAttrsWithIndex::get(0, RAttributes));
-    PAL = ParamAttrsList::getModified(PAL, modVec);
-  }
+    PAL = ParamAttrsList::includeAttrs(PAL, 0, ParamAttr::NoUnwind);
 
   SmallVector<Value*, 16> CallOperands;
   CallingConv::ID CallingConvention;
@@ -3295,16 +3289,6 @@
 //===----------------------------------------------------------------------===//
 
 
-/// Return a ParamAttrsList for the given function return attributes.
-const ParamAttrsList *getReturnAttrs(uint16_t attrs) {
-  if (attrs == ParamAttr::None)
-    return NULL;
-
-  ParamAttrsVector Attrs;
-  Attrs.push_back(ParamAttrsWithIndex::get(0, attrs));
-  return ParamAttrsList::get(Attrs);
-}
-
 /// Reads from register variables are handled by emitting an inline asm node
 /// that copies the value out of the specified register.
 Value *TreeToLLVM::EmitReadOfRegisterVariable(tree decl,
@@ -3324,7 +3308,7 @@
   const char *Name = extractRegisterName(decl);
   InlineAsm *IA = InlineAsm::get(FTy, "", "={"+std::string(Name)+"}", false);
   CallInst *Call = Builder.CreateCall(IA, "tmp");
-  Call->setParamAttrs(getReturnAttrs(ParamAttr::NoUnwind));
+  Call->setDoesNotThrow();
   return Call;
 }
 
@@ -3343,7 +3327,7 @@
   const char *Name = extractRegisterName(decl);
   InlineAsm *IA = InlineAsm::get(FTy, "", "{"+std::string(Name)+"}", true);
   CallInst *Call = Builder.CreateCall(IA, RHS);
-  Call->setParamAttrs(getReturnAttrs(ParamAttr::NoUnwind));
+  Call->setDoesNotThrow();
 }
 
 /// ConvertInlineAsmStr - Convert the specified inline asm string to an LLVM
@@ -3766,7 +3750,7 @@
                               ASM_VOLATILE_P(exp) || !ASM_OUTPUTS(exp));   
   CallInst *CV = Builder.CreateCall(Asm, CallOps.begin(), CallOps.end(),
                                     StoreCallResultAddr ? "tmp" : "");
-  CV->setParamAttrs(getReturnAttrs(ParamAttr::NoUnwind));
+  CV->setDoesNotThrow();
 
   // If the call produces a value, store it into the destination.
   if (StoreCallResultAddr)





More information about the llvm-commits mailing list