[IR] Fix some Clang-tidy modernize-use-equals-delete and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 288853
This commit is contained in:
Eugene Zelenko 2016-12-06 22:00:57 +00:00
parent 175959e350
commit 40b89ff81e
14 changed files with 250 additions and 161 deletions

View File

@ -14,21 +14,24 @@
#ifndef LLVM_IR_BASICBLOCK_H
#define LLVM_IR_BASICBLOCK_H
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/ilist.h"
#include "llvm/ADT/ilist_node.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/DataTypes.h"
#include "llvm-c/Types.h"
#include <cassert>
#include <cstddef>
namespace llvm {
class CallInst;
class LandingPadInst;
class TerminatorInst;
class LLVMContext;
class BlockAddress;
class Function;
class LandingPadInst;
class LLVMContext;
class TerminatorInst;
/// \brief LLVM Basic Block Representation
///
@ -47,19 +50,17 @@ class Function;
/// are "well formed".
class BasicBlock : public Value, // Basic blocks are data objects also
public ilist_node_with_parent<BasicBlock, Function> {
friend class BlockAddress;
public:
typedef SymbolTableList<Instruction> InstListType;
private:
friend class BlockAddress;
friend class SymbolTableListTraits<BasicBlock>;
InstListType InstList;
Function *Parent;
void setParent(Function *parent);
friend class SymbolTableListTraits<BasicBlock>;
BasicBlock(const BasicBlock &) = delete;
void operator=(const BasicBlock &) = delete;
/// \brief Constructor.
///
@ -69,7 +70,12 @@ private:
explicit BasicBlock(LLVMContext &C, const Twine &Name = "",
Function *Parent = nullptr,
BasicBlock *InsertBefore = nullptr);
public:
BasicBlock(const BasicBlock &) = delete;
BasicBlock &operator=(const BasicBlock &) = delete;
~BasicBlock() override;
/// \brief Get the context in which this basic block lives.
LLVMContext &getContext() const;
@ -89,7 +95,6 @@ public:
BasicBlock *InsertBefore = nullptr) {
return new BasicBlock(Context, Name, Parent, InsertBefore);
}
~BasicBlock() override;
/// \brief Return the enclosing method, or null if none.
const Function *getParent() const { return Parent; }
@ -330,6 +335,7 @@ private:
assert((int)(signed char)getSubclassDataFromValue() >= 0 &&
"Refcount wrap-around");
}
/// \brief Shadow Value::setValueSubclassData with a private forwarding method
/// so that any future subclasses cannot accidentally use it.
void setValueSubclassData(unsigned short D) {
@ -340,6 +346,6 @@ private:
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef)
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_BASICBLOCK_H

View File

@ -36,7 +36,9 @@ public:
SameSize, ///< The data referenced by the COMDAT must be the same size.
};
Comdat(const Comdat &) = delete;
Comdat(Comdat &&C);
SelectionKind getSelectionKind() const { return SK; }
void setSelectionKind(SelectionKind Val) { SK = Val; }
StringRef getName() const;
@ -45,8 +47,8 @@ public:
private:
friend class Module;
Comdat();
Comdat(const Comdat &) = delete;
// Points to the map in Module.
StringMapEntry<Comdat> *Name;
@ -58,6 +60,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, const Comdat &C) {
return OS;
}
} // end llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_COMDAT_H

View File

@ -15,21 +15,27 @@
#ifndef LLVM_IR_DIBUILDER_H
#define LLVM_IR_DIBUILDER_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/TrackingMDRef.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/Casting.h"
#include <algorithm>
#include <cstdint>
namespace llvm {
class BasicBlock;
class Instruction;
class Constant;
class Function;
class Instruction;
class LLVMContext;
class Module;
class Value;
class Constant;
class LLVMContext;
class StringRef;
template <typename T> class ArrayRef;
class DIBuilder {
Module &M;
@ -57,9 +63,6 @@ namespace llvm {
/// copy.
DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> PreservedVariables;
DIBuilder(const DIBuilder &) = delete;
void operator=(const DIBuilder &) = delete;
/// Create a temporary.
///
/// Create an \a temporary node and track it in \a UnresolvedNodes.
@ -71,6 +74,8 @@ namespace llvm {
/// If \c AllowUnresolved, collect unresolved nodes attached to the module
/// in order to resolve cycles during \a finalize().
explicit DIBuilder(Module &M, bool AllowUnresolved = true);
DIBuilder(const DIBuilder &) = delete;
DIBuilder &operator=(const DIBuilder &) = delete;
/// Construct any deferred debug info descriptors.
void finalize();
@ -223,7 +228,7 @@ namespace llvm {
DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
DIFile *File, unsigned LineNo,
DIType *Ty, DINode::DIFlags Flags,
llvm::Constant *Val,
Constant *Val,
uint32_t AlignInBits = 0);
/// Create debugging information entry for Objective-C
@ -742,6 +747,7 @@ namespace llvm {
return Replacement;
}
};
} // end namespace llvm
#endif
#endif // LLVM_IR_DIBUILDER_H

View File

@ -18,24 +18,30 @@
#ifndef LLVM_IR_GLOBALVALUE_H
#define LLVM_IR_GLOBALVALUE_H
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
#include <cstdint>
#include <string>
namespace llvm {
class Comdat;
class Error;
class GlobalObject;
class PointerType;
class Module;
namespace Intrinsic {
enum ID : unsigned;
}
} // end namespace Intrinsic
class GlobalValue : public Constant {
GlobalValue(const GlobalValue &) = delete;
public:
/// @brief An enumeration for the kinds of linkage for global values.
enum LinkageTypes {
@ -90,11 +96,12 @@ protected:
static const unsigned GlobalValueSubClassDataBits = 19;
private:
friend class Constant;
// Give subclasses access to what otherwise would be wasted padding.
// (19 + 4 + 2 + 2 + 2 + 3) == 32.
unsigned SubClassData : GlobalValueSubClassDataBits;
friend class Constant;
void destroyConstantImpl();
Value *handleOperandChangeImpl(Value *From, Value *To);
@ -155,6 +162,8 @@ public:
LocalExecTLSModel
};
GlobalValue(const GlobalValue &) = delete;
~GlobalValue() override {
removeDeadConstantUsers(); // remove any dead constants using this.
}
@ -522,6 +531,6 @@ public:
}
};
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_GLOBALVALUE_H

View File

@ -24,31 +24,28 @@
#include "llvm/ADT/ilist_node.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/OperandTraits.h"
#include "llvm/IR/Value.h"
#include <cassert>
#include <cstddef>
namespace llvm {
class Constant;
class DIGlobalVariable;
class Module;
template <typename ValueSubClass> class SymbolTableListTraits;
class GlobalVariable : public GlobalObject, public ilist_node<GlobalVariable> {
friend class SymbolTableListTraits<GlobalVariable>;
void *operator new(size_t, unsigned) = delete;
void operator=(const GlobalVariable &) = delete;
GlobalVariable(const GlobalVariable &) = delete;
bool isConstantGlobal : 1; // Is this a global constant?
bool isExternallyInitializedConstant : 1; // Is this a global whose value
// can change from its initial
// value before global
// initializers are run?
public:
// allocate space for exactly one operand
void *operator new(size_t s) {
return User::operator new(s, 1);
}
public:
/// GlobalVariable ctor - If a parent module is specified, the global is
/// automatically inserted into the end of the specified modules global list.
GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage,
@ -62,6 +59,8 @@ public:
const Twine &Name = "", GlobalVariable *InsertBefore = nullptr,
ThreadLocalMode = NotThreadLocal, unsigned AddressSpace = 0,
bool isExternallyInitialized = false);
GlobalVariable(const GlobalVariable &) = delete;
GlobalVariable &operator=(const GlobalVariable &) = delete;
~GlobalVariable() override {
dropAllReferences();
@ -70,6 +69,13 @@ public:
setGlobalVariableNumOperands(1);
}
// allocate space for exactly one operand
void *operator new(size_t s) {
return User::operator new(s, 1);
}
void *operator new(size_t, unsigned) = delete;
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@ -180,6 +186,6 @@ struct OperandTraits<GlobalVariable> :
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalVariable, Value)
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_GLOBALVARIABLE_H

View File

@ -17,7 +17,6 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/BasicBlock.h"
@ -45,6 +44,8 @@
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <algorithm>
#include <functional>
namespace llvm {
@ -101,7 +102,7 @@ protected:
public:
IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = nullptr,
ArrayRef<OperandBundleDef> OpBundles = None)
: Context(context), DefaultFPMathTag(FPMathTag), FMF(),
: Context(context), DefaultFPMathTag(FPMathTag),
DefaultOperandBundles(OpBundles) {
ClearInsertionPoint();
}
@ -165,12 +166,12 @@ public:
/// InsertPoint - A saved insertion point.
class InsertPoint {
BasicBlock *Block;
BasicBlock *Block = nullptr;
BasicBlock::iterator Point;
public:
/// \brief Creates a new insertion point which doesn't point to anything.
InsertPoint() : Block(nullptr) {}
InsertPoint() = default;
/// \brief Creates a new insertion point at the given location.
InsertPoint(BasicBlock *InsertBlock, BasicBlock::iterator InsertPoint)
@ -179,8 +180,8 @@ public:
/// \brief Returns true if this insert point is set.
bool isSet() const { return (Block != nullptr); }
llvm::BasicBlock *getBlock() const { return Block; }
llvm::BasicBlock::iterator getPoint() const { return Point; }
BasicBlock *getBlock() const { return Block; }
BasicBlock::iterator getPoint() const { return Point; }
};
/// \brief Returns the current insert point.
@ -230,14 +231,14 @@ public:
BasicBlock::iterator Point;
DebugLoc DbgLoc;
InsertPointGuard(const InsertPointGuard &) = delete;
InsertPointGuard &operator=(const InsertPointGuard &) = delete;
public:
InsertPointGuard(IRBuilderBase &B)
: Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
DbgLoc(B.getCurrentDebugLocation()) {}
InsertPointGuard(const InsertPointGuard &) = delete;
InsertPointGuard &operator=(const InsertPointGuard &) = delete;
~InsertPointGuard() {
Builder.restoreIP(InsertPoint(Block, Point));
Builder.SetCurrentDebugLocation(DbgLoc);
@ -251,14 +252,13 @@ public:
FastMathFlags FMF;
MDNode *FPMathTag;
FastMathFlagGuard(const FastMathFlagGuard &) = delete;
FastMathFlagGuard &operator=(
const FastMathFlagGuard &) = delete;
public:
FastMathFlagGuard(IRBuilderBase &B)
: Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag) {}
FastMathFlagGuard(const FastMathFlagGuard &) = delete;
FastMathFlagGuard &operator=(const FastMathFlagGuard &) = delete;
~FastMathFlagGuard() {
Builder.FMF = FMF;
Builder.DefaultFPMathTag = FPMathTag;
@ -1035,7 +1035,7 @@ public:
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Insert(Folder.CreateBinOp(Opc, LC, RC), Name);
llvm::Instruction *BinOp = BinaryOperator::Create(Opc, LHS, RHS);
Instruction *BinOp = BinaryOperator::Create(Opc, LHS, RHS);
if (isa<FPMathOperator>(BinOp))
BinOp = AddFPMathAttributes(BinOp, FPMathTag, FMF);
return Insert(BinOp, Name);
@ -1445,12 +1445,6 @@ public:
return CreateBitCast(V, DestTy, Name);
}
private:
// \brief Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
// compile time error, instead of converting the string to bool for the
// isSigned parameter.
Value *CreateIntCast(Value *, Type *, const char *) = delete;
public:
Value *CreateFPCast(Value *V, Type *DestTy, const Twine &Name = "") {
if (V->getType() == DestTy)
@ -1460,6 +1454,11 @@ public:
return Insert(CastInst::CreateFPCast(V, DestTy), Name);
}
// \brief Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
// compile time error, instead of converting the string to bool for the
// isSigned parameter.
Value *CreateIntCast(Value *, Type *, const char *) = delete;
//===--------------------------------------------------------------------===//
// Instruction creation methods: Compare Instructions
//===--------------------------------------------------------------------===//
@ -1584,7 +1583,7 @@ public:
return CreateCall(FTy, Callee, Args, Name, FPMathTag);
}
CallInst *CreateCall(llvm::FunctionType *FTy, Value *Callee,
CallInst *CreateCall(FunctionType *FTy, Value *Callee,
ArrayRef<Value *> Args, const Twine &Name = "",
MDNode *FPMathTag = nullptr) {
CallInst *CI = CallInst::Create(FTy, Callee, Args, DefaultOperandBundles);

View File

@ -18,15 +18,14 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Value.h"
#include <cassert>
#include <string>
#include <vector>
namespace llvm {
class PointerType;
class FunctionType;
class Module;
struct InlineAsmKeyType;
class PointerType;
template <class ConstantClass> class ConstantUniqueMap;
class InlineAsm : public Value {
@ -40,9 +39,6 @@ private:
friend struct InlineAsmKeyType;
friend class ConstantUniqueMap<InlineAsm>;
InlineAsm(const InlineAsm &) = delete;
void operator=(const InlineAsm&) = delete;
std::string AsmString, Constraints;
FunctionType *FTy;
bool HasSideEffects;
@ -59,6 +55,9 @@ private:
void destroyConstant();
public:
InlineAsm(const InlineAsm &) = delete;
InlineAsm &operator=(const InlineAsm &) = delete;
/// InlineAsm::get - Return the specified uniqued inline asm string.
///
static InlineAsm *get(FunctionType *Ty, StringRef AsmString,
@ -361,6 +360,6 @@ public:
}
};
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_INLINEASM_H

View File

@ -25,20 +25,28 @@
#define LLVM_IR_INTRINSICINST_H
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include <cassert>
#include <cstdint>
namespace llvm {
/// A wrapper class for inspecting calls to intrinsic functions.
/// This allows the standard isa/dyncast/cast functionality to work with calls
/// to intrinsic functions.
class IntrinsicInst : public CallInst {
IntrinsicInst() = delete;
IntrinsicInst(const IntrinsicInst&) = delete;
void operator=(const IntrinsicInst&) = delete;
public:
IntrinsicInst() = delete;
IntrinsicInst(const IntrinsicInst &) = delete;
IntrinsicInst &operator=(const IntrinsicInst &) = delete;
/// Return the intrinsic ID of this intrinsic.
Intrinsic::ID getIntrinsicID() const {
return getCalledFunction()->getIntrinsicID();
@ -81,9 +89,11 @@ namespace llvm {
class DbgDeclareInst : public DbgInfoIntrinsic {
public:
Value *getAddress() const { return getVariableLocation(); }
DILocalVariable *getVariable() const {
return cast<DILocalVariable>(getRawVariable());
}
DIExpression *getExpression() const {
return cast<DIExpression>(getRawExpression());
}
@ -91,6 +101,7 @@ namespace llvm {
Metadata *getRawVariable() const {
return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
}
Metadata *getRawExpression() const {
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
}
@ -110,13 +121,16 @@ namespace llvm {
Value *getValue() const {
return getVariableLocation(/* AllowNullOp = */ false);
}
uint64_t getOffset() const {
return cast<ConstantInt>(
const_cast<Value*>(getArgOperand(1)))->getZExtValue();
}
DILocalVariable *getVariable() const {
return cast<DILocalVariable>(getRawVariable());
}
DIExpression *getExpression() const {
return cast<DIExpression>(getRawExpression());
}
@ -124,6 +138,7 @@ namespace llvm {
Metadata *getRawVariable() const {
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
}
Metadata *getRawExpression() const {
return cast<MetadataAsValue>(getArgOperand(3))->getMetadata();
}
@ -159,6 +174,7 @@ namespace llvm {
ConstantInt *getVolatileCst() const {
return cast<ConstantInt>(const_cast<Value*>(getArgOperand(4)));
}
bool isVolatile() const {
return !getVolatileCst()->isZero();
}
@ -268,7 +284,6 @@ namespace llvm {
}
};
/// This class wraps the llvm.memcpy intrinsic.
class MemCpyInst : public MemTransferInst {
public:
@ -359,6 +374,7 @@ namespace llvm {
ConstantInt *getIndex() const {
return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
}
Value *getStep() const;
};
@ -404,6 +420,7 @@ namespace llvm {
return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
}
};
} // namespace llvm
#endif
} // end namespace llvm
#endif // LLVM_IR_INTRINSICINST_H

View File

@ -15,28 +15,30 @@
#ifndef LLVM_IR_LLVMCONTEXT_H
#define LLVM_IR_LLVMCONTEXT_H
#include "llvm-c/Types.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/Options.h"
#include <cstdint>
#include <memory>
#include <string>
namespace llvm {
class LLVMContextImpl;
class StringRef;
class Twine;
class Instruction;
class Module;
class MDString;
class DICompositeType;
class SMDiagnostic;
class DiagnosticInfo;
enum DiagnosticSeverity : char;
template <typename T> class SmallVectorImpl;
class Function;
class DebugLoc;
class Instruction;
class LLVMContextImpl;
class Module;
class OptBisect;
template <typename T> class SmallVectorImpl;
class SMDiagnostic;
class StringRef;
class Twine;
namespace yaml {
class Output;
}
} // end namespace yaml
/// This is an important class for using LLVM in a threaded context. It
/// (opaquely) owns and manages the core "global" data of LLVM's core
@ -47,6 +49,8 @@ class LLVMContext {
public:
LLVMContextImpl *const pImpl;
LLVMContext();
LLVMContext(LLVMContext &) = delete;
LLVMContext &operator=(const LLVMContext &) = delete;
~LLVMContext();
// Pinned metadata names, which always have the same value. This is a
@ -259,8 +263,8 @@ public:
/// analysis.
OptBisect &getOptBisect();
private:
LLVMContext(LLVMContext&) = delete;
void operator=(LLVMContext&) = delete;
// Module needs access to the add/removeModule methods.
friend class Module;
/// addModule - Register a module as being instantiated in this context. If
/// the context is deleted, the module will be deleted as well.
@ -268,9 +272,6 @@ private:
/// removeModule - Unregister a module from this context.
void removeModule(Module*);
// Module needs access to the add/removeModule methods.
friend class Module;
};
// Create wrappers for C Binding types (see CBindingWrapping.h).
@ -286,6 +287,6 @@ inline LLVMContextRef *wrap(const LLVMContext **Tys) {
return reinterpret_cast<LLVMContextRef*>(const_cast<LLVMContext**>(Tys));
}
}
} // end namespace llvm
#endif
#endif // LLVM_IR_LLVMCONTEXT_H

View File

@ -15,28 +15,22 @@
#ifndef LLVM_IR_OPERATOR_H
#define LLVM_IR_OPERATOR_H
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include <cstddef>
namespace llvm {
class GetElementPtrInst;
class BinaryOperator;
class ConstantExpr;
/// This is a utility class that provides an abstraction for the common
/// functionality between Instructions and ConstantExprs.
class Operator : public User {
private:
// The Operator class is intended to be used as a utility, and is never itself
// instantiated.
void *operator new(size_t, unsigned) = delete;
void *operator new(size_t s) = delete;
Operator() = delete;
protected:
// NOTE: Cannot use = delete because it's not legal to delete
// an overridden method that's not deleted in the base class. Cannot leave
@ -44,6 +38,13 @@ protected:
~Operator() override;
public:
// The Operator class is intended to be used as a utility, and is never itself
// instantiated.
Operator() = delete;
void *operator new(size_t, unsigned) = delete;
void *operator new(size_t s) = delete;
/// Return the opcode for this Instruction or ConstantExpr.
unsigned getOpcode() const {
if (const Instruction *I = dyn_cast<Instruction>(this))
@ -81,6 +82,7 @@ public:
private:
friend class Instruction;
friend class ConstantExpr;
void setHasNoUnsignedWrap(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~NoUnsignedWrap) | (B * NoUnsignedWrap);
@ -132,6 +134,7 @@ public:
private:
friend class Instruction;
friend class ConstantExpr;
void setIsExact(bool B) {
SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact);
}
@ -148,6 +151,7 @@ public:
OpC == Instruction::AShr ||
OpC == Instruction::LShr;
}
static inline bool classof(const ConstantExpr *CE) {
return isPossiblyExactOpcode(CE->getOpcode());
}
@ -164,7 +168,9 @@ public:
class FastMathFlags {
private:
friend class FPMathOperator;
unsigned Flags;
unsigned Flags = 0;
FastMathFlags(unsigned F) : Flags(F) { }
public:
@ -176,8 +182,7 @@ public:
AllowReciprocal = (1 << 4)
};
FastMathFlags() : Flags(0)
{ }
FastMathFlags() = default;
/// Whether any flag is set
bool any() const { return Flags != 0; }
@ -210,7 +215,6 @@ public:
}
};
/// Utility class for floating point operations which can have
/// information about relaxed accuracy requirements attached to them.
class FPMathOperator : public Operator {
@ -230,21 +234,25 @@ private:
setHasAllowReciprocal(true);
}
}
void setHasNoNaNs(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~FastMathFlags::NoNaNs) |
(B * FastMathFlags::NoNaNs);
}
void setHasNoInfs(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~FastMathFlags::NoInfs) |
(B * FastMathFlags::NoInfs);
}
void setHasNoSignedZeros(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~FastMathFlags::NoSignedZeros) |
(B * FastMathFlags::NoSignedZeros);
}
void setHasAllowReciprocal(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~FastMathFlags::AllowReciprocal) |
@ -313,7 +321,6 @@ public:
}
};
/// A helper template for defining operators for individual opcodes.
template<typename SuperClass, unsigned Opc>
class ConcreteOperator : public SuperClass {
@ -343,7 +350,6 @@ class ShlOperator
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {
};
class SDivOperator
: public ConcreteOperator<PossiblyExactOperator, Instruction::SDiv> {
};
@ -357,19 +363,18 @@ class LShrOperator
: public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {
};
class ZExtOperator : public ConcreteOperator<Operator, Instruction::ZExt> {};
class GEPOperator
: public ConcreteOperator<Operator, Instruction::GetElementPtr> {
friend class GetElementPtrInst;
friend class ConstantExpr;
enum {
IsInBounds = (1 << 0),
// InRangeIndex: bits 1-6
};
friend class GetElementPtrInst;
friend class ConstantExpr;
void setIsInBounds(bool B) {
SubclassOptionalData =
(SubclassOptionalData & ~IsInBounds) | (B * IsInBounds);
@ -380,6 +385,7 @@ public:
bool isInBounds() const {
return SubclassOptionalData & IsInBounds;
}
/// Returns the offset of the index with an inrange attachment, or None if
/// none.
Optional<unsigned> getInRangeIndex() const {
@ -470,6 +476,7 @@ public:
const Value *getPointerOperand() const {
return getOperand(0);
}
static unsigned getPointerOperandIndex() {
return 0U; // get index for modifying correct operand
}
@ -500,6 +507,6 @@ public:
}
};
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_OPERATOR_H

View File

@ -1,4 +1,4 @@
//===-- llvm/IR/Statepoint.h - gc.statepoint utilities ------ --*- C++ -*-===//
//===-- llvm/IR/Statepoint.h - gc.statepoint utilities ----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -19,6 +19,7 @@
#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/Optional.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
@ -26,8 +27,14 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/Support/Casting.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <vector>
namespace llvm {
/// The statepoint intrinsic accepts a set of flags as its third argument.
/// Valid values come out of this set.
enum class StatepointFlags {
@ -47,7 +54,6 @@ enum class StatepointFlags {
class GCRelocateInst;
class GCResultInst;
class ImmutableStatepoint;
bool isStatepoint(ImmutableCallSite CS);
bool isStatepoint(const Value *V);
@ -66,8 +72,6 @@ template <typename FunTy, typename InstructionTy, typename ValueTy,
typename CallSiteTy>
class StatepointBase {
CallSiteTy StatepointCS;
void *operator new(size_t, unsigned) = delete;
void *operator new(size_t s) = delete;
protected:
explicit StatepointBase(InstructionTy *I) {
@ -76,6 +80,7 @@ protected:
assert(StatepointCS && "isStatepoint implies CallSite");
}
}
explicit StatepointBase(CallSiteTy CS) {
if (isStatepoint(CS))
StatepointCS = CS;
@ -93,6 +98,9 @@ public:
CallArgsBeginPos = 5,
};
void *operator new(size_t, unsigned) = delete;
void *operator new(size_t s) = delete;
explicit operator bool() const {
// We do not assign non-statepoint CallSites to StatepointCS.
return (bool)StatepointCS;
@ -451,6 +459,7 @@ StatepointDirectives parseStatepointDirectivesFromAttrs(AttributeSet AS);
/// Return \c true if the the \p Attr is an attribute that is a statepoint
/// directive.
bool isStatepointDirectiveAttr(Attribute Attr);
}
#endif
} // end namespace llvm
#endif // LLVM_IR_STATEPOINT_H

View File

@ -27,7 +27,7 @@
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/CBindingWrapping.h"
#include <cstddef>
#include "llvm-c/Types.h"
namespace llvm {
@ -40,9 +40,11 @@ template <typename> struct simplify_type;
template <> class PointerLikeTypeTraits<Use **> {
public:
static inline void *getAsVoidPointer(Use **P) { return P; }
static inline Use **getFromVoidPointer(void *P) {
return static_cast<Use **>(P);
}
enum { NumLowBitsAvailable = 2 };
};
@ -65,6 +67,8 @@ public:
/// time complexity.
class Use {
public:
Use(const Use &U) = delete;
/// \brief Provide a fast substitute to std::swap<Use>
/// that also works with less standard-compliant compilers
void swap(Use &RHS);
@ -74,8 +78,6 @@ public:
typedef PointerIntPair<User *, 1, unsigned> UserRef;
private:
Use(const Use &U) = delete;
/// Destructor - Only for zap()
~Use() {
if (Val)
@ -128,6 +130,7 @@ private:
PointerIntPair<Use **, 2, PrevPtrTag> Prev;
void setPrev(Use **NewPrev) { Prev.setPointer(NewPrev); }
void addToList(Use **List) {
Next = *List;
if (Next)
@ -135,6 +138,7 @@ private:
setPrev(List);
*List = this;
}
void removeFromList() {
Use **StrippedPrev = Prev.getPointer();
*StrippedPrev = Next;
@ -159,6 +163,6 @@ template <> struct simplify_type<const Use> {
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef)
}
} // end namespace llvm
#endif
#endif // LLVM_IR_USE_H

View File

@ -27,14 +27,20 @@
#define LLVM_IR_VALUEMAP_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/IR/TrackingMDRef.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/UniqueLock.h"
#include "llvm/Support/type_traits.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <memory>
#include <type_traits>
#include <utility>
namespace llvm {
@ -77,11 +83,12 @@ struct ValueMapConfig {
};
/// See the file comment.
template<typename KeyT, typename ValueT, typename Config =ValueMapConfig<KeyT> >
template<typename KeyT, typename ValueT, typename Config =ValueMapConfig<KeyT>>
class ValueMap {
friend class ValueMapCallbackVH<KeyT, ValueT, Config>;
typedef ValueMapCallbackVH<KeyT, ValueT, Config> ValueMapCVH;
typedef DenseMap<ValueMapCVH, ValueT, DenseMapInfo<ValueMapCVH> > MapT;
typedef DenseMap<ValueMapCVH, ValueT, DenseMapInfo<ValueMapCVH>> MapT;
typedef DenseMap<const Metadata *, TrackingMDRef> MDMapT;
typedef typename Config::ExtraData ExtraData;
MapT Map;
@ -90,8 +97,6 @@ class ValueMap {
bool MayMapMetadata = true;
ValueMap(const ValueMap&) = delete;
ValueMap& operator=(const ValueMap&) = delete;
public:
typedef KeyT key_type;
typedef ValueT mapped_type;
@ -102,6 +107,8 @@ public:
: Map(NumInitBuckets), Data() {}
explicit ValueMap(const ExtraData &Data, unsigned NumInitBuckets = 64)
: Map(NumInitBuckets), Data(Data) {}
ValueMap(const ValueMap &) = delete;
ValueMap &operator=(const ValueMap &) = delete;
bool hasMD() const { return bool(MDMap); }
MDMapT &MD() {
@ -183,7 +190,6 @@ public:
insert(*I);
}
bool erase(const KeyT &Val) {
typename MapT::iterator I = Map.find_as(Val);
if (I == Map.end())
@ -237,6 +243,7 @@ template <typename KeyT, typename ValueT, typename Config>
class ValueMapCallbackVH final : public CallbackVH {
friend class ValueMap<KeyT, ValueT, Config>;
friend struct DenseMapInfo<ValueMapCallbackVH>;
typedef ValueMap<KeyT, ValueT, Config> ValueMapT;
typedef typename std::remove_pointer<KeyT>::type KeySansPointerT;
@ -262,6 +269,7 @@ public:
Config::onDelete(Copy.Map->Data, Copy.Unwrap()); // May destroy *this.
Copy.Map->Map.erase(Copy); // Definitely destroys *this.
}
void allUsesReplacedWith(Value *new_key) override {
assert(isa<KeySansPointerT>(new_key) &&
"Invalid RAUW on key of ValueMap<>");
@ -289,30 +297,34 @@ public:
};
template<typename KeyT, typename ValueT, typename Config>
struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config> > {
struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config>> {
typedef ValueMapCallbackVH<KeyT, ValueT, Config> VH;
static inline VH getEmptyKey() {
return VH(DenseMapInfo<Value *>::getEmptyKey());
}
static inline VH getTombstoneKey() {
return VH(DenseMapInfo<Value *>::getTombstoneKey());
}
static unsigned getHashValue(const VH &Val) {
return DenseMapInfo<KeyT>::getHashValue(Val.Unwrap());
}
static unsigned getHashValue(const KeyT &Val) {
return DenseMapInfo<KeyT>::getHashValue(Val);
}
static bool isEqual(const VH &LHS, const VH &RHS) {
return LHS == RHS;
}
static bool isEqual(const KeyT &LHS, const VH &RHS) {
return LHS == RHS.getValPtr();
}
};
template<typename DenseMapT, typename KeyT>
class ValueMapIterator :
public std::iterator<std::forward_iterator_tag,
@ -320,10 +332,11 @@ class ValueMapIterator :
ptrdiff_t> {
typedef typename DenseMapT::iterator BaseT;
typedef typename DenseMapT::mapped_type ValueT;
BaseT I;
public:
ValueMapIterator() : I() {}
ValueMapIterator(BaseT I) : I(I) {}
BaseT base() const { return I; }
@ -369,7 +382,9 @@ class ValueMapConstIterator :
ptrdiff_t> {
typedef typename DenseMapT::const_iterator BaseT;
typedef typename DenseMapT::mapped_type ValueT;
BaseT I;
public:
ValueMapConstIterator() : I() {}
ValueMapConstIterator(BaseT I) : I(I) {}
@ -414,4 +429,4 @@ public:
} // end namespace llvm
#endif
#endif // LLVM_IR_VALUEMAP_H

View File

@ -15,13 +15,21 @@
#ifndef LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H
#define LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/ValueMap.h"
#include "llvm/IR/Operator.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Casting.h"
#include <cstdint>
#include <tuple>
namespace llvm {
class GetElementPtrInst;
/// GlobalNumberState assigns an integer to each global value in the program,
/// which is used by the comparison routine to order references to globals. This
/// state must be preserved throughout the pass, because Functions and other
@ -44,20 +52,23 @@ class GlobalNumberState {
typedef ValueMap<GlobalValue *, uint64_t, Config> ValueNumberMap;
ValueNumberMap GlobalNumbers;
// The next unused serial number to assign to a global.
uint64_t NextNumber;
public:
GlobalNumberState() : GlobalNumbers(), NextNumber(0) {}
uint64_t getNumber(GlobalValue* Global) {
ValueNumberMap::iterator MapIter;
bool Inserted;
std::tie(MapIter, Inserted) = GlobalNumbers.insert({Global, NextNumber});
if (Inserted)
NextNumber++;
return MapIter->second;
}
void clear() {
GlobalNumbers.clear();
}
uint64_t NextNumber = 0;
public:
GlobalNumberState() = default;
uint64_t getNumber(GlobalValue* Global) {
ValueNumberMap::iterator MapIter;
bool Inserted;
std::tie(MapIter, Inserted) = GlobalNumbers.insert({Global, NextNumber});
if (Inserted)
NextNumber++;
return MapIter->second;
}
void clear() {
GlobalNumbers.clear();
}
};
/// FunctionComparator - Compares two functions to determine whether or not
@ -78,7 +89,6 @@ public:
static FunctionHash functionHash(Function &);
protected:
/// Start the comparison.
void beginCompare() {
sn_mapL.clear();
@ -302,7 +312,6 @@ protected:
const Function *FnL, *FnR;
private:
int cmpOrderings(AtomicOrdering L, AtomicOrdering R) const;
int cmpInlineAsm(const InlineAsm *L, const InlineAsm *R) const;
int cmpAttrs(const AttributeSet L, const AttributeSet R) const;
@ -362,6 +371,6 @@ private:
GlobalNumberState* GlobalNumbers;
};
}
} // end namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H