Index: llvm/trunk/lib/Analysis/ConstantFolding.cpp =================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp @@ -17,29 +17,38 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/ConstantFolding.h" +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringMap.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Config/config.h" +#include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" -#include "llvm/IR/GetElementPtrTypeIterator.h" +#include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalVariable.h" +#include "llvm/IR/InstrTypes.h" +#include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" -#include "llvm/IR/Intrinsics.h" #include "llvm/IR/Operator.h" +#include "llvm/IR/Type.h" +#include "llvm/IR/Value.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include #include #include #include -#include +#include +#include using namespace llvm; @@ -342,7 +351,7 @@ uint64_t CurEltOffset = SL->getElementOffset(Index); ByteOffset -= CurEltOffset; - while (1) { + while (true) { // If the element access is to the element itself and not to tail padding, // read the bytes from the element. uint64_t EltSize = DL.getTypeAllocSize(CS->getOperand(Index)->getType()); Index: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -15,24 +15,38 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/MemoryDependenceAnalysis.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/AssumptionCache.h" -#include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/PHITransAddr.h" #include "llvm/Analysis/OrderedBasicBlock.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Analysis/TargetLibraryInfo.h" +#include "llvm/IR/CallSite.h" +#include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Function.h" +#include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/PredIteratorCache.h" +#include "llvm/Support/AtomicOrdering.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/MathExtras.h" +#include +#include +#include + using namespace llvm; #define DEBUG_TYPE "memdep" @@ -292,7 +306,7 @@ unsigned NewLoadByteSize = LI->getType()->getPrimitiveSizeInBits() / 8U; NewLoadByteSize = NextPowerOf2(NewLoadByteSize); - while (1) { + while (true) { // If this load size is bigger than our known alignment or would not fit // into a native integer register, then we fail. if (NewLoadByteSize > LoadAlign || @@ -355,9 +369,9 @@ return MemDepResult::getUnknown(); MemDepResult Result = MemDepResult::getUnknown(); - llvm::SmallSet Seen; + SmallSet Seen; // Queue to process all pointers that are equivalent to load operand. - llvm::SmallVector LoadOperandsQueue; + SmallVector LoadOperandsQueue; LoadOperandsQueue.push_back(LoadOperand); while (!LoadOperandsQueue.empty()) { Value *Ptr = LoadOperandsQueue.pop_back_val(); @@ -395,7 +409,6 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom( const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst) { - const Value *MemLocBase = nullptr; int64_t MemLocOffset = 0; unsigned Limit = BlockScanLimit; @@ -1684,6 +1697,7 @@ MemoryDependenceWrapperPass::MemoryDependenceWrapperPass() : FunctionPass(ID) { initializeMemoryDependenceWrapperPassPass(*PassRegistry::getPassRegistry()); } + MemoryDependenceWrapperPass::~MemoryDependenceWrapperPass() {} void MemoryDependenceWrapperPass::releaseMemory() { Index: llvm/trunk/lib/AsmParser/LLParser.cpp =================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp +++ llvm/trunk/lib/AsmParser/LLParser.cpp @@ -12,29 +12,46 @@ //===----------------------------------------------------------------------===// #include "LLParser.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/AsmParser/SlotMapping.h" +#include "llvm/IR/Argument.h" #include "llvm/IR/AutoUpgrade.h" +#include "llvm/IR/BasicBlock.h" #include "llvm/IR/CallingConv.h" -#include "llvm/IR/CallSite.h" +#include "llvm/IR/Comdat.h" #include "llvm/IR/Constants.h" -#include "llvm/IR/DebugInfo.h" #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/GlobalIFunc.h" +#include "llvm/IR/GlobalObject.h" #include "llvm/IR/InlineAsm.h" +#include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Metadata.h" #include "llvm/IR/Module.h" #include "llvm/IR/Operator.h" +#include "llvm/IR/Type.h" +#include "llvm/IR/Value.h" #include "llvm/IR/ValueSymbolTable.h" -#include "llvm/Support/Debug.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/SaveAndRestore.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include + using namespace llvm; static std::string getTypeString(Type *T) { @@ -247,7 +264,7 @@ //===----------------------------------------------------------------------===// bool LLParser::ParseTopLevelEntities() { - while (1) { + while (true) { switch (Lex.getKind()) { default: return TokError("expected top-level entity"); case lltok::Eof: return false; @@ -275,7 +292,6 @@ } } - /// toplevelentity /// ::= 'module' 'asm' STRINGCONSTANT bool LLParser::ParseModuleAsm() { @@ -376,7 +392,6 @@ return false; } - /// toplevelentity /// ::= LocalVar '=' 'type' type bool LLParser::ParseNamedType() { @@ -403,7 +418,6 @@ return false; } - /// toplevelentity /// ::= 'declare' FunctionHeader bool LLParser::ParseDeclare() { @@ -1213,7 +1227,6 @@ return FwdVal; } - //===----------------------------------------------------------------------===// // Comdat Reference/Resolution Routines. //===----------------------------------------------------------------------===// @@ -1231,7 +1244,6 @@ return C; } - //===----------------------------------------------------------------------===// // Helper Routines. //===----------------------------------------------------------------------===// @@ -1350,7 +1362,7 @@ B.clear(); - while (1) { + while (true) { lltok::Kind Token = Lex.getKind(); switch (Token) { default: // End of attributes. @@ -1439,7 +1451,7 @@ B.clear(); - while (1) { + while (true) { lltok::Kind Token = Lex.getKind(); switch (Token) { default: // End of attributes. @@ -2024,7 +2036,7 @@ } // Parse the type suffixes. - while (1) { + while (true) { switch (Lex.getKind()) { // End of type. default: @@ -2357,7 +2369,6 @@ return false; } - /// ParseStructType: Handles packed and unpacked types. parsed elsewhere. /// StructType /// ::= '{' '}' @@ -2480,7 +2491,6 @@ return false; } - /// GetVal - Get a value with the specified name or ID, creating a /// forward reference record if needed. This can return null if the value /// exists but does not have the right type. @@ -3354,34 +3364,43 @@ MDUnsignedField(uint64_t Default = 0, uint64_t Max = UINT64_MAX) : ImplTy(Default), Max(Max) {} }; + struct LineField : public MDUnsignedField { LineField() : MDUnsignedField(0, UINT32_MAX) {} }; + struct ColumnField : public MDUnsignedField { ColumnField() : MDUnsignedField(0, UINT16_MAX) {} }; + struct DwarfTagField : public MDUnsignedField { DwarfTagField() : MDUnsignedField(0, dwarf::DW_TAG_hi_user) {} DwarfTagField(dwarf::Tag DefaultTag) : MDUnsignedField(DefaultTag, dwarf::DW_TAG_hi_user) {} }; + struct DwarfMacinfoTypeField : public MDUnsignedField { DwarfMacinfoTypeField() : MDUnsignedField(0, dwarf::DW_MACINFO_vendor_ext) {} DwarfMacinfoTypeField(dwarf::MacinfoRecordType DefaultType) : MDUnsignedField(DefaultType, dwarf::DW_MACINFO_vendor_ext) {} }; + struct DwarfAttEncodingField : public MDUnsignedField { DwarfAttEncodingField() : MDUnsignedField(0, dwarf::DW_ATE_hi_user) {} }; + struct DwarfVirtualityField : public MDUnsignedField { DwarfVirtualityField() : MDUnsignedField(0, dwarf::DW_VIRTUALITY_max) {} }; + struct DwarfLangField : public MDUnsignedField { DwarfLangField() : MDUnsignedField(0, dwarf::DW_LANG_hi_user) {} }; + struct DwarfCCField : public MDUnsignedField { DwarfCCField() : MDUnsignedField(0, dwarf::DW_CC_hi_user) {} }; + struct EmissionKindField : public MDUnsignedField { EmissionKindField() : MDUnsignedField(0, DICompileUnit::LastEmissionKind) {} }; @@ -3403,24 +3422,28 @@ struct MDBoolField : public MDFieldImpl { MDBoolField(bool Default = false) : ImplTy(Default) {} }; + struct MDField : public MDFieldImpl { bool AllowNull; MDField(bool AllowNull = true) : ImplTy(nullptr), AllowNull(AllowNull) {} }; + struct MDConstant : public MDFieldImpl { MDConstant() : ImplTy(nullptr) {} }; + struct MDStringField : public MDFieldImpl { bool AllowEmpty; MDStringField(bool AllowEmpty = true) : ImplTy(nullptr), AllowEmpty(AllowEmpty) {} }; + struct MDFieldList : public MDFieldImpl> { MDFieldList() : ImplTy(SmallVector()) {} }; -} // end namespace +} // end anonymous namespace namespace llvm { @@ -4109,7 +4132,6 @@ return false; } - /// ParseDIModule: /// ::= !DIModule(scope: !0, name: "SomeModule", configMacros: "-DNDEBUG", /// includePath: "/usr/include", isysroot: "/") @@ -4375,7 +4397,6 @@ return false; } - //===----------------------------------------------------------------------===// // Function Parsing. //===----------------------------------------------------------------------===// @@ -4542,7 +4563,6 @@ return false; } - /// FunctionHeader /// ::= OptionalLinkage OptionalVisibility OptionalCallingConv OptRetAttrs /// OptUnnamedAddr Type GlobalName '(' ArgList ')' OptFuncAttrs OptSection @@ -5123,7 +5143,6 @@ return false; } - /// ParseBr /// ::= 'br' TypeAndValue /// ::= 'br' TypeAndValue ',' TypeAndValue ',' TypeAndValue @@ -5238,7 +5257,6 @@ return false; } - /// ParseInvoke /// ::= 'invoke' OptionalCallingConv OptionalAttrs Type Value ParamList /// OptionalAttrs 'to' TypeAndValue 'unwind' TypeAndValue @@ -5586,7 +5604,6 @@ return false; } - /// ParseCompare /// ::= 'icmp' IPredicates TypeAndValue ',' Value /// ::= 'fcmp' FPredicates TypeAndValue ',' Value @@ -5751,7 +5768,8 @@ bool AteExtraComma = false; SmallVector, 16> PHIVals; - while (1) { + + while (true) { PHIVals.push_back(std::make_pair(Op0, cast(Op1))); if (!EatIfPresent(lltok::comma)) Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp @@ -7,38 +7,81 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" +#include "llvm/ADT/Twine.h" #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Bitcode/LLVMBitCodes.h" #include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/IR/Argument.h" +#include "llvm/IR/Attributes.h" #include "llvm/IR/AutoUpgrade.h" +#include "llvm/IR/BasicBlock.h" +#include "llvm/IR/CallingConv.h" #include "llvm/IR/CallSite.h" +#include "llvm/IR/Comdat.h" +#include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DebugInfo.h" #include "llvm/IR/DebugInfoMetadata.h" +#include "llvm/IR/DebugLoc.h" #include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/GlobalAlias.h" +#include "llvm/IR/GlobalIFunc.h" +#include "llvm/IR/GlobalIndirectSymbol.h" +#include "llvm/IR/GlobalObject.h" +#include "llvm/IR/GlobalValue.h" +#include "llvm/IR/GlobalVariable.h" #include "llvm/IR/GVMaterializer.h" #include "llvm/IR/InlineAsm.h" -#include "llvm/IR/IntrinsicInst.h" +#include "llvm/IR/InstrTypes.h" +#include "llvm/IR/Instruction.h" +#include "llvm/IR/Instructions.h" +#include "llvm/IR/Intrinsics.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/ModuleSummaryIndex.h" #include "llvm/IR/OperandTraits.h" #include "llvm/IR/Operator.h" +#include "llvm/IR/TrackingMDRef.h" +#include "llvm/IR/Type.h" #include "llvm/IR/ValueHandle.h" +#include "llvm/Support/AtomicOrdering.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataStream.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MathExtras.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/StreamingMemoryObject.h" +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include +#include using namespace llvm; @@ -48,6 +91,7 @@ "Print the global id for each value when reading the module summary")); namespace { + enum { SWITCH_INST_MAGIC = 0x4B5 // May 2012 => 1205 => Hex }; @@ -65,6 +109,7 @@ typedef std::vector > ResolveConstantsTy; ResolveConstantsTy ResolveConstants; LLVMContext &Context; + public: BitcodeReaderValueList(LLVMContext &C) : Context(C) {} ~BitcodeReaderValueList() { @@ -89,6 +134,7 @@ Value *back() const { return ValuePtrs.back(); } void pop_back() { ValuePtrs.pop_back(); } bool empty() const { return ValuePtrs.empty(); } + void shrinkTo(unsigned N) { assert(N <= size() && "Invalid shrinkTo request!"); ValuePtrs.resize(N); @@ -125,6 +171,7 @@ } OldTypeRefs; LLVMContext &Context; + public: BitcodeReaderMetadataList(LLVMContext &C) : NumFwdRefs(0), AnyFwdRefs(false), Context(C) {} @@ -335,18 +382,22 @@ StructType *createIdentifiedStructType(LLVMContext &Context); Type *getTypeByID(unsigned ID); + Value *getFnValueByID(unsigned ID, Type *Ty) { if (Ty && Ty->isMetadataTy()) return MetadataAsValue::get(Ty->getContext(), getFnMetadataByID(ID)); return ValueList.getValueFwdRef(ID, Ty); } + Metadata *getFnMetadataByID(unsigned ID) { return MetadataList.getMetadataFwdRef(ID); } + BasicBlock *getBasicBlock(unsigned ID) const { if (ID >= FunctionBBs.size()) return nullptr; // Invalid ID return FunctionBBs[ID]; } + AttributeSet getAttributes(unsigned i) const { if (i-1 < MAttributes.size()) return MAttributes[i-1]; @@ -543,8 +594,10 @@ std::error_code initStreamFromBuffer(); std::error_code initLazyStream(std::unique_ptr Streamer); std::pair + getGUIDFromValueId(unsigned ValueId); }; + } // end anonymous namespace BitcodeDiagnosticInfo::BitcodeDiagnosticInfo(std::error_code EC, @@ -898,7 +951,7 @@ return FMF; } -static void upgradeDLLImportExportLinkage(llvm::GlobalValue *GV, unsigned Val) { +static void upgradeDLLImportExportLinkage(GlobalValue *GV, unsigned Val) { switch (Val) { case 5: GV->setDLLStorageClass(GlobalValue::DLLImportStorageClass); break; case 6: GV->setDLLStorageClass(GlobalValue::DLLExportStorageClass); break; @@ -907,6 +960,7 @@ namespace llvm { namespace { + /// \brief A class for maintaining the slot number definition /// as a placeholder for the actual definition for forward constants defs. class ConstantPlaceHolder : public ConstantExpr { @@ -929,6 +983,7 @@ /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; + } // end anonymous namespace // FIXME: can we inherit this from ConstantExpr? @@ -937,6 +992,7 @@ public FixedNumOperandTraits { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPlaceHolder, Value) + } // end namespace llvm void BitcodeReaderValueList::assignValue(Value *V, unsigned Idx) { @@ -986,7 +1042,7 @@ Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, Type *Ty) { // Bail out for a clearly invalid value. This would make us call resize(0) - if (Idx == UINT_MAX) + if (Idx == std::numeric_limits::max()) return nullptr; if (Idx >= size()) @@ -1287,7 +1343,6 @@ // Functions for parsing blocks from the bitcode file //===----------------------------------------------------------------------===// - /// \brief This fills an AttrBuilder object with the LLVM attributes that have /// been decoded from the given integer. This function must stay in sync with /// 'encodeLLVMAttributesForBitcode'. @@ -1319,7 +1374,7 @@ SmallVector Attrs; // Read all the records. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -1506,7 +1561,7 @@ SmallVector Record; // Read all the records. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -1601,7 +1656,7 @@ SmallString<64> TypeName; // Read all the records for this type table. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -1836,7 +1891,7 @@ SmallVector Record; - while (1) { + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -1944,7 +1999,8 @@ // Read all the records for this value table. SmallString<128> ValueName; - while (1) { + + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -2075,6 +2131,7 @@ } namespace { + class PlaceholderQueue { // Placeholders would thrash around when moved, so store in a std::deque // instead of some sort of vector. @@ -2084,7 +2141,8 @@ DistinctMDOperandPlaceholder &getPlaceholderOp(unsigned ID); void flush(BitcodeReaderMetadataList &MetadataList); }; -} // end namespace + +} // end anonymous namespace DistinctMDOperandPlaceholder &PlaceholderQueue::getPlaceholderOp(unsigned ID) { PHs.emplace_back(ID); @@ -2151,7 +2209,7 @@ (IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS) // Read all the records. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -2719,6 +2777,7 @@ } } } + #undef GET_OR_DISTINCT } @@ -2730,7 +2789,7 @@ SmallVector Record; // Read all the records. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -2874,7 +2933,8 @@ // Read all the records for this value table. Type *CurTy = Type::getInt32Ty(Context); unsigned NextCstNo = ValueList.size(); - while (1) { + + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -3334,7 +3394,8 @@ // Read all the records. SmallVector Record; - while (1) { + + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -3490,7 +3551,7 @@ SmallVector Record; - while (1) { + while (true) { BitstreamEntry Entry = Stream.advance(); switch (Entry.Kind) { default: @@ -3515,7 +3576,8 @@ // Read all the records. SmallVector Record; - while (1) { + + while (true) { BitstreamEntry Entry = Stream.advance(); switch (Entry.Kind) { @@ -3564,7 +3626,7 @@ std::vector GCTable; // Read all the records for this module. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advance(); switch (Entry.Kind) { @@ -4056,7 +4118,7 @@ // We expect a number of well-defined blocks, though we don't necessarily // need to understand them all. - while (1) { + while (true) { if (Stream.AtEndOfStream()) { // We didn't really read a proper Module. return error("Malformed IR file"); @@ -4088,8 +4150,9 @@ SmallVector Record; std::string Triple; + // Read all the records for this module. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -4129,7 +4192,7 @@ // We expect a number of well-defined blocks, though we don't necessarily // need to understand them all. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advance(); switch (Entry.Kind) { @@ -4164,7 +4227,7 @@ // We expect a number of well-defined blocks, though we don't necessarily // need to understand them all. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advance(); switch (Entry.Kind) { case BitstreamEntry::Error: @@ -4214,7 +4277,7 @@ // We expect a number of well-defined blocks, though we don't necessarily // need to understand them all. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advance(); switch (Entry.Kind) { @@ -4245,7 +4308,8 @@ SmallVector Record; // Read all the records for this module. - while (1) { + + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -4285,7 +4349,8 @@ return error("Invalid record"); SmallVector Record; - while (1) { + + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -4396,7 +4461,8 @@ // Read all the records. SmallVector Record; - while (1) { + + while (true) { BitstreamEntry Entry = Stream.advance(); switch (Entry.Kind) { @@ -5878,7 +5944,8 @@ // Read all the records for this value table. SmallString<128> ValueName; - while (1) { + + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -5972,7 +6039,7 @@ unsigned ValueId = 0; // Read the index for this module. - while (1) { + while (true) { BitstreamEntry Entry = Stream.advance(); switch (Entry.Kind) { @@ -6133,7 +6200,8 @@ // "OriginalName" attachement. GlobalValueSummary *LastSeenSummary = nullptr; bool Combined = false; - while (1) { + + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -6372,7 +6440,8 @@ SmallString<128> ModulePath; ModulePathStringTableTy::iterator LastSeenModulePath; - while (1) { + + while (true) { BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); switch (Entry.Kind) { @@ -6437,7 +6506,7 @@ // We expect a number of well-defined blocks, though we don't necessarily // need to understand them all. - while (1) { + while (true) { if (Stream.AtEndOfStream()) { // We didn't really read a proper Module block. return error("Malformed block"); @@ -6513,6 +6582,7 @@ } namespace { + // FIXME: This class is only here to support the transition to llvm::Error. It // will be removed once this transition is complete. Clients should prefer to // deal with the Error value directly, rather than converting to error_code. @@ -6531,6 +6601,7 @@ llvm_unreachable("Unknown error type!"); } }; + } // end anonymous namespace static ManagedStatic ErrorCategory; @@ -6547,7 +6618,7 @@ getBitcodeModuleImpl(std::unique_ptr Streamer, StringRef Name, BitcodeReader *R, LLVMContext &Context, bool MaterializeAll, bool ShouldLazyLoadMetadata) { - std::unique_ptr M = make_unique(Name, Context); + std::unique_ptr M = llvm::make_unique(Name, Context); M->setMaterializer(R); auto cleanupOnError = [&](std::error_code EC) { @@ -6607,7 +6678,7 @@ llvm::getStreamedBitcodeModule(StringRef Name, std::unique_ptr Streamer, LLVMContext &Context) { - std::unique_ptr M = make_unique(Name, Context); + std::unique_ptr M = llvm::make_unique(Name, Context); BitcodeReader *R = new BitcodeReader(Context); return getBitcodeModuleImpl(std::move(Streamer), Name, R, Context, false, Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -12,28 +12,33 @@ //===----------------------------------------------------------------------===// #include "DwarfUnit.h" -#include "DwarfAccelTable.h" +#include "AddressPool.h" #include "DwarfCompileUnit.h" #include "DwarfDebug.h" #include "DwarfExpression.h" #include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/ADT/None.h" #include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineOperand.h" #include "llvm/IR/Constants.h" -#include "llvm/IR/DIBuilder.h" #include "llvm/IR/DataLayout.h" -#include "llvm/IR/GlobalVariable.h" -#include "llvm/IR/Instructions.h" -#include "llvm/IR/Mangler.h" -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/MC/MCContext.h" +#include "llvm/IR/GlobalValue.h" +#include "llvm/IR/Metadata.h" +#include "llvm/MC/MachineLocation.h" +#include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCSection.h" #include "llvm/MC/MCStreamer.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Target/TargetFrameLowering.h" #include "llvm/Target/TargetLoweringObjectFile.h" -#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetSubtargetInfo.h" +#include +#include +#include +#include using namespace llvm; @@ -52,12 +57,15 @@ void DIEDwarfExpression::EmitOp(uint8_t Op, const char* Comment) { DU.addUInt(DIE, dwarf::DW_FORM_data1, Op); } + void DIEDwarfExpression::EmitSigned(int64_t Value) { DU.addSInt(DIE, dwarf::DW_FORM_sdata, Value); } + void DIEDwarfExpression::EmitUnsigned(uint64_t Value) { DU.addUInt(DIE, dwarf::DW_FORM_udata, Value); } + bool DIEDwarfExpression::isFrameRegister(const TargetRegisterInfo &TRI, unsigned MachineReg) { return MachineReg == TRI.getFrameRegister(*AP.MF); @@ -735,7 +743,7 @@ void DwarfUnit::updateAcceleratorTables(const DIScope *Context, const DIType *Ty, const DIE &TyDIE) { if (!Ty->getName().empty() && !Ty->isForwardDecl()) { - bool IsImplementation = 0; + bool IsImplementation = false; if (auto *CT = dyn_cast(Ty)) { // A runtime language of 0 actually means C/C++ and that any // non-negative value is some version of Objective-C/C++. Index: llvm/trunk/lib/CodeGen/EdgeBundles.cpp =================================================================== --- llvm/trunk/lib/CodeGen/EdgeBundles.cpp +++ llvm/trunk/lib/CodeGen/EdgeBundles.cpp @@ -17,6 +17,7 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/GraphWriter.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -57,8 +58,8 @@ Blocks.resize(getNumBundles()); for (unsigned i = 0, e = MF->getNumBlockIDs(); i != e; ++i) { - unsigned b0 = getBundle(i, 0); - unsigned b1 = getBundle(i, 1); + unsigned b0 = getBundle(i, false); + unsigned b1 = getBundle(i, true); Blocks[b0].push_back(i); if (b1 != b0) Blocks[b1].push_back(i); @@ -69,6 +70,7 @@ /// Specialize WriteGraph, the standard implementation won't work. namespace llvm { + template<> raw_ostream &WriteGraph<>(raw_ostream &O, const EdgeBundles &G, bool ShortNames, @@ -89,7 +91,8 @@ O << "}\n"; return O; } -} + +} // end namespace llvm /// view - Visualize the annotated bipartite CFG with Graphviz. void EdgeBundles::view() const { Index: llvm/trunk/lib/CodeGen/MachineSink.cpp =================================================================== --- llvm/trunk/lib/CodeGen/MachineSink.cpp +++ llvm/trunk/lib/CodeGen/MachineSink.cpp @@ -22,9 +22,14 @@ #include "llvm/ADT/SparseBitVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" #include "llvm/CodeGen/MachineDominators.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineLoopInfo.h" +#include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/MachinePostDominators.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/IR/LLVMContext.h" @@ -34,6 +39,13 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetSubtargetInfo.h" +#include +#include +#include +#include +#include +#include + using namespace llvm; #define DEBUG_TYPE "machine-sink" @@ -48,12 +60,12 @@ cl::desc("Use block frequency info to find successors to sink"), cl::init(true), cl::Hidden); - STATISTIC(NumSunk, "Number of machine instructions sunk"); STATISTIC(NumSplit, "Number of critical edges split"); STATISTIC(NumCoalesces, "Number of copies coalesced"); namespace { + class MachineSinking : public MachineFunctionPass { const TargetInstrInfo *TII; const TargetRegisterInfo *TRI; @@ -65,12 +77,12 @@ AliasAnalysis *AA; // Remember which edges have been considered for breaking. - SmallSet, 8> + SmallSet, 8> CEBCandidates; // Remember which edges we are about to split. // This is different from CEBCandidates since those edges // will be split. - SetVector > ToSplit; + SetVector > ToSplit; SparseBitVector<> RegsToClearKillFlags; @@ -79,6 +91,7 @@ public: static char ID; // Pass identification + MachineSinking() : MachineFunctionPass(ID) { initializeMachineSinkingPass(*PassRegistry::getPassRegistry()); } @@ -143,6 +156,7 @@ GetAllSortedSuccessors(MachineInstr &MI, MachineBasicBlock *MBB, AllSuccsCache &AllSuccessors) const; }; + } // end anonymous namespace char MachineSinking::ID = 0; @@ -273,7 +287,7 @@ bool EverMadeChange = false; - while (1) { + while (true) { bool MadeChange = false; // Process all basic blocks. Index: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp =================================================================== --- llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp +++ llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp @@ -70,17 +70,28 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" +#include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineDominators.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/MC/MCInstrDesc.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetSubtargetInfo.h" +#include +#include +#include #include + using namespace llvm; #define DEBUG_TYPE "peephole-opt" @@ -118,6 +129,7 @@ STATISTIC(NumNAPhysCopies, "Number of non-allocatable physical copies removed"); namespace { + class ValueTrackerResult; class PeepholeOptimizer : public MachineFunctionPass { @@ -128,6 +140,7 @@ public: static char ID; // Pass identification + PeepholeOptimizer() : MachineFunctionPass(ID) { initializePeepholeOptimizerPass(*PassRegistry::getPassRegistry()); } @@ -390,10 +403,12 @@ /// register of the last source. unsigned getReg() const { return Reg; } }; -} + +} // end anonymous namespace char PeepholeOptimizer::ID = 0; char &llvm::PeepholeOptimizerID = PeepholeOptimizer::ID; + INITIALIZE_PASS_BEGIN(PeepholeOptimizer, DEBUG_TYPE, "Peephole Optimizations", false, false) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree) @@ -737,6 +752,7 @@ } namespace { + /// \brief Helper class to rewrite the arguments of a copy-like instruction. class CopyRewriter { protected: @@ -820,7 +836,6 @@ TargetInstrInfo::RegSubRegPair Def, PeepholeOptimizer::RewriteMapTy &RewriteMap, bool HandleMultipleSources = true) { - TargetInstrInfo::RegSubRegPair LookupSrc(Def.Reg, Def.SubReg); do { ValueTrackerResult Res = RewriteMap.lookup(LookupSrc); @@ -859,7 +874,7 @@ const MachineOperand &MODef = NewPHI->getOperand(0); return TargetInstrInfo::RegSubRegPair(MODef.getReg(), MODef.getSubReg()); - } while (1); + } while (true); return TargetInstrInfo::RegSubRegPair(0, 0); } @@ -1001,6 +1016,7 @@ TrackSubReg = (unsigned)CopyLike.getOperand(3).getImm(); return true; } + bool RewriteCurrentSource(unsigned NewReg, unsigned NewSubReg) override { if (CurrentSrcIdx != 2) return false; @@ -1141,7 +1157,8 @@ return true; } }; -} // End namespace. + +} // end anonymous namespace /// \brief Get the appropriated CopyRewriter for \p MI. /// \return A pointer to a dynamically allocated CopyRewriter or nullptr