Author: lattner Date: Wed Jan 9 18:48:14 2008 New Revision: 45800 URL: http://llvm.org/viewvc/llvm-project?rev=45800&view=rev Log: Fix a "bug" introduced by attribute(annotate). Before this patch it would always call " ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl));" even if there are no annotate attributes on a global, causing the string to be emitted and unused.
Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=45800&r1=45799&r2=45800&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Jan 9 18:48:14 2008 @@ -754,12 +754,14 @@ // Handle annotate attribute on global. tree annotateAttr = lookup_attribute("annotate", DECL_ATTRIBUTES (decl)); + if (annotateAttr == 0) + return; // Get file and line number - Constant *lineNo = ConstantInt::get(Type::Int32Ty, DECL_SOURCE_LINE(decl)); - Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl)); - const Type *SBP= PointerType::getUnqual(Type::Int8Ty); - file = ConstantExpr::getBitCast(file, SBP); + Constant *lineNo = ConstantInt::get(Type::Int32Ty, DECL_SOURCE_LINE(decl)); + Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl)); + const Type *SBP= PointerType::getUnqual(Type::Int8Ty); + file = ConstantExpr::getBitCast(file, SBP); // There may be multiple annotate attributes. Pass return of lookup_attr // to successive lookups. @@ -779,10 +781,12 @@ assert(TREE_CODE(val) == STRING_CST && "Annotate attribute arg should always be a string"); Constant *strGV = TreeConstantToLLVM::EmitLV_STRING_CST(val); - Constant *Element[4] = {ConstantExpr::getBitCast(GV,SBP), + Constant *Element[4] = { + ConstantExpr::getBitCast(GV,SBP), ConstantExpr::getBitCast(strGV,SBP), file, - lineNo}; + lineNo + }; AttributeAnnotateGlobals.push_back(ConstantStruct::get(Element, 4, false)); } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits