mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:50:30 +00:00
Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D23861 llvm-svn: 279695
This commit is contained in:
parent
69ca8eb5f7
commit
5c80b0e4f8
@ -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 <cassert>
|
||||
#include <cerrno>
|
||||
#include <cfenv>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
@ -342,7 +351,7 @@ bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset, unsigned char *CurPtr,
|
||||
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());
|
||||
|
@ -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 <algorithm>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "memdep"
|
||||
@ -292,7 +306,7 @@ unsigned MemoryDependenceResults::getLoadLoadClobberFullWidthSize(
|
||||
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 @@ MemoryDependenceResults::getInvariantGroupPointerDependency(LoadInst *LI,
|
||||
return MemDepResult::getUnknown();
|
||||
|
||||
MemDepResult Result = MemDepResult::getUnknown();
|
||||
llvm::SmallSet<Value *, 14> Seen;
|
||||
SmallSet<Value *, 14> Seen;
|
||||
// Queue to process all pointers that are equivalent to load operand.
|
||||
llvm::SmallVector<Value *, 8> LoadOperandsQueue;
|
||||
SmallVector<Value *, 8> LoadOperandsQueue;
|
||||
LoadOperandsQueue.push_back(LoadOperand);
|
||||
while (!LoadOperandsQueue.empty()) {
|
||||
Value *Ptr = LoadOperandsQueue.pop_back_val();
|
||||
@ -395,7 +409,6 @@ MemoryDependenceResults::getInvariantGroupPointerDependency(LoadInst *LI,
|
||||
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 @@ INITIALIZE_PASS_END(MemoryDependenceWrapperPass, "memdep",
|
||||
MemoryDependenceWrapperPass::MemoryDependenceWrapperPass() : FunctionPass(ID) {
|
||||
initializeMemoryDependenceWrapperPassPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
MemoryDependenceWrapperPass::~MemoryDependenceWrapperPass() {}
|
||||
|
||||
void MemoryDependenceWrapperPass::releaseMemory() {
|
||||
|
@ -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 <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
static std::string getTypeString(Type *T) {
|
||||
@ -247,7 +264,7 @@ bool LLParser::ValidateEndOfModule() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
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 @@ bool LLParser::ParseTopLevelEntities() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// toplevelentity
|
||||
/// ::= 'module' 'asm' STRINGCONSTANT
|
||||
bool LLParser::ParseModuleAsm() {
|
||||
@ -376,7 +392,6 @@ bool LLParser::ParseUnnamedType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// toplevelentity
|
||||
/// ::= LocalVar '=' 'type' type
|
||||
bool LLParser::ParseNamedType() {
|
||||
@ -403,7 +418,6 @@ bool LLParser::ParseNamedType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// toplevelentity
|
||||
/// ::= 'declare' FunctionHeader
|
||||
bool LLParser::ParseDeclare() {
|
||||
@ -1213,7 +1227,6 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
|
||||
return FwdVal;
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Comdat Reference/Resolution Routines.
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -1231,7 +1244,6 @@ Comdat *LLParser::getComdat(const std::string &Name, LocTy Loc) {
|
||||
return C;
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Helper Routines.
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -1350,7 +1362,7 @@ bool LLParser::ParseOptionalParamAttrs(AttrBuilder &B) {
|
||||
|
||||
B.clear();
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
lltok::Kind Token = Lex.getKind();
|
||||
switch (Token) {
|
||||
default: // End of attributes.
|
||||
@ -1439,7 +1451,7 @@ bool LLParser::ParseOptionalReturnAttrs(AttrBuilder &B) {
|
||||
|
||||
B.clear();
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
lltok::Kind Token = Lex.getKind();
|
||||
switch (Token) {
|
||||
default: // End of attributes.
|
||||
@ -2024,7 +2036,7 @@ bool LLParser::ParseType(Type *&Result, const Twine &Msg, bool AllowVoid) {
|
||||
}
|
||||
|
||||
// Parse the type suffixes.
|
||||
while (1) {
|
||||
while (true) {
|
||||
switch (Lex.getKind()) {
|
||||
// End of type.
|
||||
default:
|
||||
@ -2357,7 +2369,6 @@ bool LLParser::ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// ParseStructType: Handles packed and unpacked types. </> parsed elsewhere.
|
||||
/// StructType
|
||||
/// ::= '{' '}'
|
||||
@ -2480,7 +2491,6 @@ bool LLParser::PerFunctionState::FinishFunction() {
|
||||
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 @@ struct MDUnsignedField : public MDFieldImpl<uint64_t> {
|
||||
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 MDSignedField : public MDFieldImpl<int64_t> {
|
||||
struct MDBoolField : public MDFieldImpl<bool> {
|
||||
MDBoolField(bool Default = false) : ImplTy(Default) {}
|
||||
};
|
||||
|
||||
struct MDField : public MDFieldImpl<Metadata *> {
|
||||
bool AllowNull;
|
||||
|
||||
MDField(bool AllowNull = true) : ImplTy(nullptr), AllowNull(AllowNull) {}
|
||||
};
|
||||
|
||||
struct MDConstant : public MDFieldImpl<ConstantAsMetadata *> {
|
||||
MDConstant() : ImplTy(nullptr) {}
|
||||
};
|
||||
|
||||
struct MDStringField : public MDFieldImpl<MDString *> {
|
||||
bool AllowEmpty;
|
||||
MDStringField(bool AllowEmpty = true)
|
||||
: ImplTy(nullptr), AllowEmpty(AllowEmpty) {}
|
||||
};
|
||||
|
||||
struct MDFieldList : public MDFieldImpl<SmallVector<Metadata *, 4>> {
|
||||
MDFieldList() : ImplTy(SmallVector<Metadata *, 4>()) {}
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
} // end anonymous namespace
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -4109,7 +4132,6 @@ bool LLParser::ParseDIMacroFile(MDNode *&Result, bool IsDistinct) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// ParseDIModule:
|
||||
/// ::= !DIModule(scope: !0, name: "SomeModule", configMacros: "-DNDEBUG",
|
||||
/// includePath: "/usr/include", isysroot: "/")
|
||||
@ -4375,7 +4397,6 @@ bool LLParser::ParseMetadata(Metadata *&MD, PerFunctionState *PFS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Function Parsing.
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -4542,7 +4563,6 @@ bool LLParser::ParseTypeAndBasicBlock(BasicBlock *&BB, LocTy &Loc,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// FunctionHeader
|
||||
/// ::= OptionalLinkage OptionalVisibility OptionalCallingConv OptRetAttrs
|
||||
/// OptUnnamedAddr Type GlobalName '(' ArgList ')' OptFuncAttrs OptSection
|
||||
@ -5123,7 +5143,6 @@ bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// ParseBr
|
||||
/// ::= 'br' TypeAndValue
|
||||
/// ::= 'br' TypeAndValue ',' TypeAndValue ',' TypeAndValue
|
||||
@ -5238,7 +5257,6 @@ bool LLParser::ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// ParseInvoke
|
||||
/// ::= 'invoke' OptionalCallingConv OptionalAttrs Type Value ParamList
|
||||
/// OptionalAttrs 'to' TypeAndValue 'unwind' TypeAndValue
|
||||
@ -5586,7 +5604,6 @@ bool LLParser::ParseLogical(Instruction *&Inst, PerFunctionState &PFS,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// ParseCompare
|
||||
/// ::= 'icmp' IPredicates TypeAndValue ',' Value
|
||||
/// ::= 'fcmp' FPredicates TypeAndValue ',' Value
|
||||
@ -5751,7 +5768,8 @@ int LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
|
||||
bool AteExtraComma = false;
|
||||
SmallVector<std::pair<Value*, BasicBlock*>, 16> PHIVals;
|
||||
while (1) {
|
||||
|
||||
while (true) {
|
||||
PHIVals.push_back(std::make_pair(Op0, cast<BasicBlock>(Op1)));
|
||||
|
||||
if (!EatIfPresent(lltok::comma))
|
||||
|
@ -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 <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
@ -48,6 +91,7 @@ static cl::opt<bool> PrintSummaryGUIDs(
|
||||
"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 @@ class BitcodeReaderValueList {
|
||||
typedef std::vector<std::pair<Constant*, unsigned> > ResolveConstantsTy;
|
||||
ResolveConstantsTy ResolveConstants;
|
||||
LLVMContext &Context;
|
||||
|
||||
public:
|
||||
BitcodeReaderValueList(LLVMContext &C) : Context(C) {}
|
||||
~BitcodeReaderValueList() {
|
||||
@ -89,6 +134,7 @@ public:
|
||||
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 @@ class BitcodeReaderMetadataList {
|
||||
} OldTypeRefs;
|
||||
|
||||
LLVMContext &Context;
|
||||
|
||||
public:
|
||||
BitcodeReaderMetadataList(LLVMContext &C)
|
||||
: NumFwdRefs(0), AnyFwdRefs(false), Context(C) {}
|
||||
@ -335,18 +382,22 @@ private:
|
||||
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 @@ private:
|
||||
std::error_code initStreamFromBuffer();
|
||||
std::error_code initLazyStream(std::unique_ptr<DataStreamer> Streamer);
|
||||
std::pair<GlobalValue::GUID, GlobalValue::GUID>
|
||||
|
||||
getGUIDFromValueId(unsigned ValueId);
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
BitcodeDiagnosticInfo::BitcodeDiagnosticInfo(std::error_code EC,
|
||||
@ -898,7 +951,7 @@ static FastMathFlags getDecodedFastMathFlags(unsigned Val) {
|
||||
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 @@ static void upgradeDLLImportExportLinkage(llvm::GlobalValue *GV, unsigned Val) {
|
||||
|
||||
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 @@ public:
|
||||
/// Provide fast operand accessors
|
||||
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
// FIXME: can we inherit this from ConstantExpr?
|
||||
@ -937,6 +992,7 @@ struct OperandTraits<ConstantPlaceHolder> :
|
||||
public FixedNumOperandTraits<ConstantPlaceHolder, 1> {
|
||||
};
|
||||
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPlaceHolder, Value)
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
void BitcodeReaderValueList::assignValue(Value *V, unsigned Idx) {
|
||||
@ -986,7 +1042,7 @@ Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx,
|
||||
|
||||
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<unsigned>::max())
|
||||
return nullptr;
|
||||
|
||||
if (Idx >= size())
|
||||
@ -1287,7 +1343,6 @@ StructType *BitcodeReader::createIdentifiedStructType(LLVMContext &Context) {
|
||||
// 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 @@ std::error_code BitcodeReader::parseAttributeBlock() {
|
||||
SmallVector<AttributeSet, 8> Attrs;
|
||||
|
||||
// Read all the records.
|
||||
while (1) {
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -1506,7 +1561,7 @@ std::error_code BitcodeReader::parseAttributeGroupBlock() {
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
|
||||
// Read all the records.
|
||||
while (1) {
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -1601,7 +1656,7 @@ std::error_code BitcodeReader::parseTypeTableBody() {
|
||||
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 @@ std::error_code BitcodeReader::parseOperandBundleTags() {
|
||||
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -1944,7 +1999,8 @@ std::error_code BitcodeReader::parseValueSymbolTable(uint64_t Offset) {
|
||||
|
||||
// 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 @@ std::error_code BitcodeReader::parseMetadataStrings(ArrayRef<uint64_t> Record,
|
||||
}
|
||||
|
||||
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 @@ public:
|
||||
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 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
|
||||
(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 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef GET_OR_DISTINCT
|
||||
}
|
||||
|
||||
@ -2730,7 +2789,7 @@ std::error_code BitcodeReader::parseMetadataKinds() {
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
|
||||
// Read all the records.
|
||||
while (1) {
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -2874,7 +2933,8 @@ std::error_code BitcodeReader::parseConstants() {
|
||||
// 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 @@ std::error_code BitcodeReader::parseUseLists() {
|
||||
|
||||
// Read all the records.
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
while (1) {
|
||||
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -3490,7 +3551,7 @@ std::error_code BitcodeReader::rememberAndSkipFunctionBodies() {
|
||||
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advance();
|
||||
switch (Entry.Kind) {
|
||||
default:
|
||||
@ -3515,7 +3576,8 @@ std::error_code BitcodeReader::parseBitcodeVersion() {
|
||||
|
||||
// Read all the records.
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
while (1) {
|
||||
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advance();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -3564,7 +3626,7 @@ std::error_code BitcodeReader::parseModule(uint64_t ResumeBit,
|
||||
std::vector<std::string> GCTable;
|
||||
|
||||
// Read all the records for this module.
|
||||
while (1) {
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advance();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -4056,7 +4118,7 @@ BitcodeReader::parseBitcodeInto(std::unique_ptr<DataStreamer> Streamer,
|
||||
|
||||
// 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 @@ ErrorOr<std::string> BitcodeReader::parseModuleTriple() {
|
||||
SmallVector<uint64_t, 64> 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 @@ ErrorOr<std::string> BitcodeReader::parseTriple() {
|
||||
|
||||
// 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 @@ ErrorOr<std::string> BitcodeReader::parseIdentificationBlock() {
|
||||
|
||||
// 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 @@ ErrorOr<bool> BitcodeReader::hasObjCCategory() {
|
||||
|
||||
// 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 @@ ErrorOr<bool> BitcodeReader::hasObjCCategoryInModule() {
|
||||
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
// Read all the records for this module.
|
||||
while (1) {
|
||||
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -4285,7 +4349,8 @@ std::error_code BitcodeReader::parseMetadataAttachment(Function &F) {
|
||||
return error("Invalid record");
|
||||
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
while (1) {
|
||||
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -4396,7 +4461,8 @@ std::error_code BitcodeReader::parseFunctionBody(Function *F) {
|
||||
|
||||
// Read all the records.
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
while (1) {
|
||||
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advance();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -5878,7 +5944,8 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseValueSymbolTable(
|
||||
|
||||
// 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 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseModule() {
|
||||
unsigned ValueId = 0;
|
||||
|
||||
// Read the index for this module.
|
||||
while (1) {
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advance();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -6133,7 +6200,8 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
|
||||
// "OriginalName" attachement.
|
||||
GlobalValueSummary *LastSeenSummary = nullptr;
|
||||
bool Combined = false;
|
||||
while (1) {
|
||||
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -6372,7 +6440,8 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseModuleStringTable() {
|
||||
|
||||
SmallString<128> ModulePath;
|
||||
ModulePathStringTableTy::iterator LastSeenModulePath;
|
||||
while (1) {
|
||||
|
||||
while (true) {
|
||||
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
|
||||
|
||||
switch (Entry.Kind) {
|
||||
@ -6437,7 +6506,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseSummaryIndexInto(
|
||||
|
||||
// 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 @@ std::error_code ModuleSummaryIndexBitcodeReader::initLazyStream(
|
||||
}
|
||||
|
||||
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 @@ class BitcodeErrorCategoryType : public std::error_category {
|
||||
llvm_unreachable("Unknown error type!");
|
||||
}
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
static ManagedStatic<BitcodeErrorCategoryType> ErrorCategory;
|
||||
@ -6547,7 +6618,7 @@ static ErrorOr<std::unique_ptr<Module>>
|
||||
getBitcodeModuleImpl(std::unique_ptr<DataStreamer> Streamer, StringRef Name,
|
||||
BitcodeReader *R, LLVMContext &Context,
|
||||
bool MaterializeAll, bool ShouldLazyLoadMetadata) {
|
||||
std::unique_ptr<Module> M = make_unique<Module>(Name, Context);
|
||||
std::unique_ptr<Module> M = llvm::make_unique<Module>(Name, Context);
|
||||
M->setMaterializer(R);
|
||||
|
||||
auto cleanupOnError = [&](std::error_code EC) {
|
||||
@ -6607,7 +6678,7 @@ ErrorOr<std::unique_ptr<Module>>
|
||||
llvm::getStreamedBitcodeModule(StringRef Name,
|
||||
std::unique_ptr<DataStreamer> Streamer,
|
||||
LLVMContext &Context) {
|
||||
std::unique_ptr<Module> M = make_unique<Module>(Name, Context);
|
||||
std::unique_ptr<Module> M = llvm::make_unique<Module>(Name, Context);
|
||||
BitcodeReader *R = new BitcodeReader(Context);
|
||||
|
||||
return getBitcodeModuleImpl(std::move(Streamer), Name, R, Context, false,
|
||||
|
@ -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 <cassert>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
@ -52,12 +57,15 @@ DIEDwarfExpression::DIEDwarfExpression(const AsmPrinter &AP, DwarfUnit &DU,
|
||||
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 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
|
||||
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<DICompositeType>(Ty)) {
|
||||
// A runtime language of 0 actually means C/C++ and that any
|
||||
// non-negative value is some version of Objective-C/C++.
|
||||
|
@ -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 @@ bool EdgeBundles::runOnMachineFunction(MachineFunction &mf) {
|
||||
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 @@ bool EdgeBundles::runOnMachineFunction(MachineFunction &mf) {
|
||||
|
||||
/// 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 @@ raw_ostream &WriteGraph<>(raw_ostream &O, const EdgeBundles &G,
|
||||
O << "}\n";
|
||||
return O;
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
/// view - Visualize the annotated bipartite CFG with Graphviz.
|
||||
void EdgeBundles::view() const {
|
||||
|
@ -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 <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "machine-sink"
|
||||
@ -48,12 +60,12 @@ UseBlockFreqInfo("machine-sink-bfi",
|
||||
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 @@ namespace {
|
||||
AliasAnalysis *AA;
|
||||
|
||||
// Remember which edges have been considered for breaking.
|
||||
SmallSet<std::pair<MachineBasicBlock*,MachineBasicBlock*>, 8>
|
||||
SmallSet<std::pair<MachineBasicBlock*, MachineBasicBlock*>, 8>
|
||||
CEBCandidates;
|
||||
// Remember which edges we are about to split.
|
||||
// This is different from CEBCandidates since those edges
|
||||
// will be split.
|
||||
SetVector<std::pair<MachineBasicBlock*,MachineBasicBlock*> > ToSplit;
|
||||
SetVector<std::pair<MachineBasicBlock*, MachineBasicBlock*> > ToSplit;
|
||||
|
||||
SparseBitVector<> RegsToClearKillFlags;
|
||||
|
||||
@ -79,6 +91,7 @@ namespace {
|
||||
|
||||
public:
|
||||
static char ID; // Pass identification
|
||||
|
||||
MachineSinking() : MachineFunctionPass(ID) {
|
||||
initializeMachineSinkingPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
@ -143,6 +156,7 @@ namespace {
|
||||
GetAllSortedSuccessors(MachineInstr &MI, MachineBasicBlock *MBB,
|
||||
AllSuccsCache &AllSuccessors) const;
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
char MachineSinking::ID = 0;
|
||||
@ -273,7 +287,7 @@ bool MachineSinking::runOnMachineFunction(MachineFunction &MF) {
|
||||
|
||||
bool EverMadeChange = false;
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
bool MadeChange = false;
|
||||
|
||||
// Process all basic blocks.
|
||||
|
@ -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 <cassert>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "peephole-opt"
|
||||
@ -118,6 +129,7 @@ STATISTIC(NumRewrittenCopies, "Number of copies rewritten");
|
||||
STATISTIC(NumNAPhysCopies, "Number of non-allocatable physical copies removed");
|
||||
|
||||
namespace {
|
||||
|
||||
class ValueTrackerResult;
|
||||
|
||||
class PeepholeOptimizer : public MachineFunctionPass {
|
||||
@ -128,6 +140,7 @@ namespace {
|
||||
|
||||
public:
|
||||
static char ID; // Pass identification
|
||||
|
||||
PeepholeOptimizer() : MachineFunctionPass(ID) {
|
||||
initializePeepholeOptimizerPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
@ -390,10 +403,12 @@ namespace {
|
||||
/// 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 @@ insertPHI(MachineRegisterInfo *MRI, const TargetInstrInfo *TII,
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
/// \brief Helper class to rewrite the arguments of a copy-like instruction.
|
||||
class CopyRewriter {
|
||||
protected:
|
||||
@ -820,7 +836,6 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ public:
|
||||
TrackSubReg = (unsigned)CopyLike.getOperand(3).getImm();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RewriteCurrentSource(unsigned NewReg, unsigned NewSubReg) override {
|
||||
if (CurrentSrcIdx != 2)
|
||||
return false;
|
||||
@ -1141,7 +1157,8 @@ public:
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user