Make output match actual condition tested. Thanks, Duncan.
[oota-llvm.git] / lib / VMCore / Function.cpp
index b6ff70d6a33463e8c1a5455d8971e473313590ed..dd781964a9174ad28bb215a4a1132fab8cf9352f 100644 (file)
@@ -90,17 +90,21 @@ std::string
 ParamAttrsList::getParamAttrsText(uint16_t Attrs) {
   std::string Result;
   if (Attrs & ParamAttr::ZExt)
-    Result += "zext ";
+    Result += "zeroext ";
   if (Attrs & ParamAttr::SExt)
-    Result += "sext ";
+    Result += "signext ";
   if (Attrs & ParamAttr::NoReturn)
     Result += "noreturn ";
   if (Attrs & ParamAttr::NoUnwind)
     Result += "nounwind ";
   if (Attrs & ParamAttr::InReg)
     Result += "inreg ";
+  if (Attrs & ParamAttr::NoAlias)
+    Result += "noalias ";
   if (Attrs & ParamAttr::StructRet)
     Result += "sret ";  
+  if (Attrs & ParamAttr::ByVal)
+    Result += "byval ";
   return Result;
 }
 
@@ -129,6 +133,10 @@ ParamAttrsList::get(const ParamAttrsVector &attrVec) {
   return PAL;
 }
 
+ParamAttrsList::~ParamAttrsList() {
+  ParamAttrsLists->RemoveNode(this);
+}
+
 //===----------------------------------------------------------------------===//
 // Function Implementation
 //===----------------------------------------------------------------------===//
@@ -162,6 +170,10 @@ Function::~Function() {
   // Delete all of the method arguments and unlink from symbol table...
   ArgumentList.clear();
   delete SymTab;
+
+  // Drop our reference to the parameter attributes, if any.
+  if (ParamAttrs)
+    ParamAttrs->dropRef();
 }
 
 void Function::setParent(Module *parent) {
@@ -172,6 +184,16 @@ void Function::setParent(Module *parent) {
     LeakDetector::removeGarbageObject(this);
 }
 
+void Function::setParamAttrs(ParamAttrsList *attrs) { 
+  if (ParamAttrs)
+    ParamAttrs->dropRef();
+
+  if (attrs)
+    attrs->addRef();
+
+  ParamAttrs = attrs; 
+}
+
 const FunctionType *Function::getFunctionType() const {
   return cast<FunctionType>(getType()->getElementType());
 }
@@ -251,7 +273,7 @@ std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) {
 }
 
 const FunctionType *Intrinsic::getType(ID id, const Type **Tys, 
-                                       uint32_t numTys) {
+                                       unsigned numTys) {
   const Type *ResultTy = NULL;
   std::vector<const Type*> ArgTys;
   bool IsVarArg = false;
@@ -289,11 +311,8 @@ Value *IntrinsicInst::StripPointerCasts(Value *Ptr) {
     if (isa<PointerType>(CI->getOperand(0)->getType()))
       return StripPointerCasts(CI->getOperand(0));
   } else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Ptr)) {
-    for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i)
-      if (!isa<Constant>(GEP->getOperand(i)) ||
-          !cast<Constant>(GEP->getOperand(i))->isNullValue())
-        return Ptr;
-    return StripPointerCasts(GEP->getOperand(0));
+    if (GEP->hasAllZeroIndices())
+      return StripPointerCasts(GEP->getOperand(0));
   }
   return Ptr;
 }