[cfe-commits] r149363 - in /cfe/trunk/lib/CodeGen: CGExprConstant.cpp CGObjCGNU.cpp CGObjCMac.cpp CGRTTI.cpp CodeGenAction.cpp CodeGenModule.cpp

Argyrios Kyrtzidis kyrtzidis at apple.com
Tue Jan 31 22:43:36 PST 2012


I reverted this in r149477; reverting your series of commits in r149470 caused "test/CodeGen/PR3589-freestanding-libcalls.c" to fail.

On Jan 30, 2012, at 10:13 PM, Chris Lattner wrote:

> Author: lattner
> Date: Tue Jan 31 00:13:55 2012
> New Revision: 149363
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=149363&view=rev
> Log:
> ConstantArray::get() (for strings) is going away, use
> ConstantDataArray::getString instead.
> 
> Many instances of ConstantArray::get() could be moved to 
> use more efficient ConstantDataArray methods that avoid a ton
> of intermediate Constant*'s for each element (e.g. 
> GetConstantArrayFromStringLiteral).  I don't plan on doing this
> in the short-term though.
> 
> 
> Modified:
>    cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>    cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
>    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
>    cfe/trunk/lib/CodeGen/CGRTTI.cpp
>    cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=149363&r1=149362&r2=149363&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Tue Jan 31 00:13:55 2012
> @@ -811,7 +811,7 @@
>     // Resize the string to the right size, adding zeros at the end, or
>     // truncating as needed.
>     Str.resize(CAT->getSize().getZExtValue(), '\0');
> -    return llvm::ConstantArray::get(VMContext, Str, false);
> +    return llvm::ConstantDataArray::getString(VMContext, Str, false);
>   }
> 
>   llvm::Constant *VisitUnaryExtension(const UnaryOperator *E) {
> 
> Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=149363&r1=149362&r2=149363&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Tue Jan 31 00:13:55 2012
> @@ -187,7 +187,7 @@
>     std::string name = prefix + Str;
>     llvm::Constant *ConstStr = TheModule.getGlobalVariable(name);
>     if (!ConstStr) {
> -      llvm::Constant *value = llvm::ConstantArray::get(VMContext, Str, true);
> +      llvm::Constant *value = llvm::ConstantDataArray::getString(VMContext,Str);
>       ConstStr = new llvm::GlobalVariable(TheModule, value->getType(), true,
>               llvm::GlobalValue::LinkOnceODRLinkage, value, prefix + Str);
>     }
> 
> Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=149363&r1=149362&r2=149363&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Jan 31 00:13:55 2012
> @@ -3714,8 +3714,8 @@
> 
>   if (!Entry)
>     Entry = CreateMetadataVar("\01L_OBJC_CLASS_NAME_",
> -                          llvm::ConstantArray::get(VMContext,
> -                                                   Ident->getNameStart()),
> +                              llvm::ConstantDataArray::getString(VMContext,
> +                                                         Ident->getNameStart()),
>                               ((ObjCABI == 2) ?
>                                "__TEXT,__objc_classname,cstring_literals" :
>                                "__TEXT,__cstring,cstring_literals"),
> @@ -3923,7 +3923,7 @@
> /// the given argument BitMap string container. Routine reads
> /// two containers, IvarsInfo and SkipIvars which are assumed to be
> /// filled already by the caller.
> -llvm::Constant *CGObjCCommonMac::BuildIvarLayoutBitmap(std::string& BitMap) {
> +llvm::Constant *CGObjCCommonMac::BuildIvarLayoutBitmap(std::string &BitMap) {
>   unsigned int WordsToScan, WordsToSkip;
>   llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
> 
> @@ -4040,7 +4040,7 @@
> 
>   llvm::GlobalVariable * Entry =
>   CreateMetadataVar("\01L_OBJC_CLASS_NAME_",
> -                    llvm::ConstantArray::get(VMContext, BitMap.c_str()),
> +                    llvm::ConstantDataArray::getString(VMContext, BitMap),
>                     ((ObjCABI == 2) ?
>                      "__TEXT,__objc_classname,cstring_literals" :
>                      "__TEXT,__cstring,cstring_literals"),
> @@ -4129,7 +4129,7 @@
>   // FIXME: Avoid std::string copying.
>   if (!Entry)
>     Entry = CreateMetadataVar("\01L_OBJC_METH_VAR_NAME_",
> -                        llvm::ConstantArray::get(VMContext, Sel.getAsString()),
> +               llvm::ConstantDataArray::getString(VMContext, Sel.getAsString()),
>                               ((ObjCABI == 2) ?
>                                "__TEXT,__objc_methname,cstring_literals" :
>                                "__TEXT,__cstring,cstring_literals"),
> @@ -4151,7 +4151,7 @@
> 
>   if (!Entry)
>     Entry = CreateMetadataVar("\01L_OBJC_METH_VAR_TYPE_",
> -                              llvm::ConstantArray::get(VMContext, TypeStr),
> +                         llvm::ConstantDataArray::getString(VMContext, TypeStr),
>                               ((ObjCABI == 2) ?
>                                "__TEXT,__objc_methtype,cstring_literals" :
>                                "__TEXT,__cstring,cstring_literals"),
> @@ -4172,7 +4172,7 @@
> 
>   if (!Entry)
>     Entry = CreateMetadataVar("\01L_OBJC_METH_VAR_TYPE_",
> -                              llvm::ConstantArray::get(VMContext, TypeStr),
> +                         llvm::ConstantDataArray::getString(VMContext, TypeStr),
>                               ((ObjCABI == 2) ?
>                                "__TEXT,__objc_methtype,cstring_literals" :
>                                "__TEXT,__cstring,cstring_literals"),
> @@ -4187,8 +4187,8 @@
> 
>   if (!Entry)
>     Entry = CreateMetadataVar("\01L_OBJC_PROP_NAME_ATTR_",
> -                          llvm::ConstantArray::get(VMContext,
> -                                                   Ident->getNameStart()),
> +                        llvm::ConstantDataArray::getString(VMContext,
> +                                                       Ident->getNameStart()),
>                               "__TEXT,__cstring,cstring_literals",
>                               1, true);
> 
> 
> Modified: cfe/trunk/lib/CodeGen/CGRTTI.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRTTI.cpp?rev=149363&r1=149362&r2=149363&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGRTTI.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGRTTI.cpp Tue Jan 31 00:13:55 2012
> @@ -125,7 +125,8 @@
>   // We know that the mangled name of the type starts at index 4 of the
>   // mangled name of the typename, so we can just index into it in order to
>   // get the mangled name of the type.
> -  llvm::Constant *Init = llvm::ConstantArray::get(VMContext, Name.substr(4));
> +  llvm::Constant *Init = llvm::ConstantDataArray::getString(VMContext,
> +                                                            Name.substr(4));
> 
>   llvm::GlobalVariable *GV = 
>     CGM.CreateOrReplaceCXXRuntimeVariable(Name, Init->getType(), Linkage);
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=149363&r1=149362&r2=149363&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Jan 31 00:13:55 2012
> @@ -220,18 +220,15 @@
>                                             SourceLocation LocCookie) {
>   // There are a couple of different kinds of errors we could get here.  First,
>   // we re-format the SMDiagnostic in terms of a clang diagnostic.
> -
> -  // Strip "error: " off the start of the message string.
>   StringRef Message = D.getMessage();
> -  if (Message.startswith("error: "))
> -    Message = Message.substr(7);
> 
>   // If the SMDiagnostic has an inline asm source location, translate it.
>   FullSourceLoc Loc;
>   if (D.getLoc() != SMLoc())
>     Loc = ConvertBackendLocation(D, Context->getSourceManager());
> -  
> 
> +  // FIXME: Propagate ranges up as well.
> +  
>   // If this problem has clang-level source location information, report the
>   // issue as being an error in the source with a note showing the instantiated
>   // code.
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=149363&r1=149362&r2=149363&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan 31 00:13:55 2012
> @@ -689,7 +689,7 @@
>     return i->second;
> 
>   // Not found yet, create a new global.
> -  llvm::Constant *s = llvm::ConstantArray::get(getLLVMContext(), Str, true);
> +  llvm::Constant *s = llvm::ConstantDataArray::getString(getLLVMContext(), Str);
>   llvm::GlobalValue *gv = new llvm::GlobalVariable(getModule(), s->getType(),
>     true, llvm::GlobalValue::PrivateLinkage, s, ".str");
>   gv->setSection(AnnotationSection);
> @@ -1853,7 +1853,8 @@
>     llvm::ConstantInt::get(Ty, 0x07C8);
> 
>   // String pointer.
> -  llvm::Constant *C = llvm::ConstantArray::get(VMContext, Entry.getKey().str());
> +  llvm::Constant *C = llvm::ConstantDataArray::getString(VMContext,
> +                                                         Entry.getKey());
> 
>   llvm::GlobalValue::LinkageTypes Linkage;
>   if (isUTF16)
> @@ -1985,7 +1986,8 @@
>   Fields[0] = ConstantStringClassRef;
> 
>   // String pointer.
> -  llvm::Constant *C = llvm::ConstantArray::get(VMContext, Entry.getKey().str());
> +  llvm::Constant *C =
> +    llvm::ConstantDataArray::getString(VMContext, Entry.getKey());
> 
>   llvm::GlobalValue::LinkageTypes Linkage;
>   bool isConstant;
> @@ -2081,29 +2083,28 @@
>   // Don't emit it as the address of the string, emit the string data itself
>   // as an inline array.
>   if (E->getCharByteWidth()==1) {
> -    return llvm::ConstantArray::get(VMContext,
> +    return llvm::ConstantDataArray::getString(VMContext,
>                                     GetStringForStringLiteral(E), false);
> -  } else {
> -    llvm::ArrayType *AType =
> -      cast<llvm::ArrayType>(getTypes().ConvertType(E->getType()));
> -    llvm::Type *ElemTy = AType->getElementType();
> -    unsigned NumElements = AType->getNumElements();
> -    std::vector<llvm::Constant*> Elts;
> -    Elts.reserve(NumElements);
> -    
> -    for(unsigned i=0;i<E->getLength();++i) {
> -      unsigned value = E->getCodeUnit(i);
> -      llvm::Constant *C = llvm::ConstantInt::get(ElemTy,value,false);
> -      Elts.push_back(C);
> -    }
> -    for(unsigned i=E->getLength();i<NumElements;++i) {
> -      llvm::Constant *C = llvm::ConstantInt::get(ElemTy,0,false);
> -      Elts.push_back(C);
> -    }
> -    
> -    return llvm::ConstantArray::get(AType, Elts);
>   }
> -
> +  
> +  llvm::ArrayType *AType =
> +    cast<llvm::ArrayType>(getTypes().ConvertType(E->getType()));
> +  llvm::Type *ElemTy = AType->getElementType();
> +  unsigned NumElements = AType->getNumElements();
> +  std::vector<llvm::Constant*> Elts;
> +  Elts.reserve(NumElements);
> +  
> +  for(unsigned i=0;i<E->getLength();++i) {
> +    unsigned value = E->getCodeUnit(i);
> +    llvm::Constant *C = llvm::ConstantInt::get(ElemTy,value,false);
> +    Elts.push_back(C);
> +  }
> +  for(unsigned i=E->getLength();i<NumElements;++i) {
> +    llvm::Constant *C = llvm::ConstantInt::get(ElemTy,0,false);
> +    Elts.push_back(C);
> +  }
> +  
> +  return llvm::ConstantArray::get(AType, Elts);
> }
> 
> /// GetAddrOfConstantStringFromLiteral - Return a pointer to a
> @@ -2152,7 +2153,7 @@
>                                              unsigned Alignment) {
>   // Create Constant for this string literal. Don't add a '\0'.
>   llvm::Constant *C =
> -      llvm::ConstantArray::get(CGM.getLLVMContext(), str, false);
> +      llvm::ConstantDataArray::getString(CGM.getLLVMContext(), str, false);
> 
>   // Create a global variable for this string
>   llvm::GlobalVariable *GV =
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list