aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-25 22:11:20 +0000
committerDan Gohman <gohman@apple.com>2009-08-25 22:11:20 +0000
commit58cfa3b13752579c86cf85270d49f9ced0942f2f (patch)
treee2d88c43f06255610357c7c9ee6caa8883523454 /include/llvm
parent415c8cf837439401f2df75d992d7e296d1d6746a (diff)
downloadexternal_llvm-58cfa3b13752579c86cf85270d49f9ced0942f2f.zip
external_llvm-58cfa3b13752579c86cf85270d49f9ced0942f2f.tar.gz
external_llvm-58cfa3b13752579c86cf85270d49f9ced0942f2f.tar.bz2
Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined,
and introduce a new Instruction::isIdenticalTo which tests for full identity, including the SubclassOptionalData flags. Also, fix the Instruction::clone implementations to preserve the SubclassOptionalData flags. Finally, teach several optimizations how to handle SubclassOptionalData correctly, given these changes. This fixes the counterintuitive behavior of isIdenticalTo not comparing the full value, and clone not returning an identical clone, as well as some subtle bugs that could be caused by these. Thanks to Nick Lewycky for reporting this, and for an initial patch! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/InstrTypes.h7
-rw-r--r--include/llvm/Instruction.h5
-rw-r--r--include/llvm/Instructions.h81
-rw-r--r--include/llvm/Value.h12
4 files changed, 19 insertions, 86 deletions
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index 35fec63..9b59c80 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -90,7 +90,6 @@ public:
class UnaryInstruction : public Instruction {
void *operator new(size_t, unsigned); // Do not implement
- UnaryInstruction(const UnaryInstruction&); // Do not implement
protected:
UnaryInstruction(const Type *Ty, unsigned iType, Value *V,
@@ -315,12 +314,6 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryOperator, Value)
/// if (isa<CastInst>(Instr)) { ... }
/// @brief Base class of casting instructions.
class CastInst : public UnaryInstruction {
- /// @brief Copy constructor
- CastInst(const CastInst &CI)
- : UnaryInstruction(CI.getType(), CI.getOpcode(), CI.getOperand(0)) {
- }
- /// @brief Do not allow default construction
- CastInst();
protected:
/// @brief Constructor with insert-before-instruction semantics for subclasses
CastInst(const Type *Ty, unsigned iType, Value *S,
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h
index 924b195..189c34a 100644
--- a/include/llvm/Instruction.h
+++ b/include/llvm/Instruction.h
@@ -54,6 +54,11 @@ public:
/// extra information (e.g. load is volatile) agree.
bool isIdenticalTo(const Instruction *I) const;
+ /// isIdenticalToWhenDefined - This is like isIdenticalTo, except that it
+ /// ignores the SubclassOptionalData flags, which specify conditions
+ /// under which the instruction's result is undefined.
+ bool isIdenticalToWhenDefined(const Instruction *I) const;
+
/// This function determines if the specified instruction executes the same
/// operation as the current one. This means that the opcodes, type, operand
/// types and any other factors affecting the operation must be the same. This
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 33af5bc..5163342 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -99,7 +99,6 @@ public:
/// MallocInst - an instruction to allocated memory on the heap
///
class MallocInst : public AllocationInst {
- MallocInst(const MallocInst &MI);
public:
explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
const Twine &NameStr = "",
@@ -148,7 +147,6 @@ public:
/// AllocaInst - an instruction to allocate memory on the stack
///
class AllocaInst : public AllocationInst {
- AllocaInst(const AllocaInst &);
public:
explicit AllocaInst(const Type *Ty,
Value *ArraySize = 0,
@@ -234,16 +232,6 @@ public:
/// SubclassData field in Value to store whether or not the load is volatile.
///
class LoadInst : public UnaryInstruction {
-
- LoadInst(const LoadInst &LI)
- : UnaryInstruction(LI.getType(), Load, LI.getOperand(0)) {
- setVolatile(LI.isVolatile());
- setAlignment(LI.getAlignment());
-
-#ifndef NDEBUG
- AssertOK();
-#endif
- }
void AssertOK();
public:
LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore);
@@ -308,18 +296,6 @@ public:
///
class StoreInst : public Instruction {
void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
-
- StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store,
- &Op<0>(), 2) {
- Op<0>() = SI.Op<0>();
- Op<1>() = SI.Op<1>();
- setVolatile(SI.isVolatile());
- setAlignment(SI.getAlignment());
-
-#ifndef NDEBUG
- AssertOK();
-#endif
- }
void AssertOK();
public:
// allocate space for exactly two operands
@@ -1196,10 +1172,6 @@ class SelectInst : public Instruction {
Op<2>() = S2;
}
- SelectInst(const SelectInst &SI)
- : Instruction(SI.getType(), SI.getOpcode(), &Op<0>(), 3) {
- init(SI.Op<0>(), SI.Op<1>(), SI.Op<2>());
- }
SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr,
Instruction *InsertBefore)
: Instruction(S1->getType(), Instruction::Select,
@@ -1267,8 +1239,6 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectInst, Value)
/// an argument of the specified type given a va_list and increments that list
///
class VAArgInst : public UnaryInstruction {
- VAArgInst(const VAArgInst &VAA)
- : UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {}
public:
VAArgInst(Value *List, const Type *Ty, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
@@ -1301,19 +1271,13 @@ public:
/// element from a VectorType value
///
class ExtractElementInst : public Instruction {
- ExtractElementInst(const ExtractElementInst &EE) :
- Instruction(EE.getType(), ExtractElement, &Op<0>(), 2) {
- Op<0>() = EE.Op<0>();
- Op<1>() = EE.Op<1>();
- }
-
ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr = "",
Instruction *InsertBefore = 0);
ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr,
BasicBlock *InsertAtEnd);
public:
static ExtractElementInst *Create(const ExtractElementInst &EE) {
- return new(EE.getNumOperands()) ExtractElementInst(EE);
+ return Create(EE.getOperand(0), EE.getOperand(1));
}
static ExtractElementInst *Create(Value *Vec, Value *Idx,
@@ -1360,7 +1324,6 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementInst, Value)
/// element into a VectorType value
///
class InsertElementInst : public Instruction {
- InsertElementInst(const InsertElementInst &IE);
InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
const Twine &NameStr = "",
Instruction *InsertBefore = 0);
@@ -1368,7 +1331,7 @@ class InsertElementInst : public Instruction {
const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
static InsertElementInst *Create(const InsertElementInst &IE) {
- return new(IE.getNumOperands()) InsertElementInst(IE);
+ return Create(IE.getOperand(0), IE.getOperand(1), IE.getOperand(2));
}
static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
const Twine &NameStr = "",
@@ -1421,7 +1384,6 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementInst, Value)
/// input vectors.
///
class ShuffleVectorInst : public Instruction {
- ShuffleVectorInst(const ShuffleVectorInst &IE);
public:
// allocate space for exactly three operands
void *operator new(size_t s) {
@@ -2658,10 +2620,6 @@ private:
/// @brief This class represents a truncation of integer types.
class TruncInst : public CastInst {
- /// Private copy constructor
- TruncInst(const TruncInst &CI)
- : CastInst(CI.getType(), Trunc, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
TruncInst(
@@ -2698,10 +2656,6 @@ public:
/// @brief This class represents zero extension of integer types.
class ZExtInst : public CastInst {
- /// @brief Private copy constructor
- ZExtInst(const ZExtInst &CI)
- : CastInst(CI.getType(), ZExt, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
ZExtInst(
@@ -2738,10 +2692,6 @@ public:
/// @brief This class represents a sign extension of integer types.
class SExtInst : public CastInst {
- /// @brief Private copy constructor
- SExtInst(const SExtInst &CI)
- : CastInst(CI.getType(), SExt, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
SExtInst(
@@ -2778,9 +2728,6 @@ public:
/// @brief This class represents a truncation of floating point types.
class FPTruncInst : public CastInst {
- FPTruncInst(const FPTruncInst &CI)
- : CastInst(CI.getType(), FPTrunc, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
FPTruncInst(
@@ -2817,9 +2764,6 @@ public:
/// @brief This class represents an extension of floating point types.
class FPExtInst : public CastInst {
- FPExtInst(const FPExtInst &CI)
- : CastInst(CI.getType(), FPExt, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
FPExtInst(
@@ -2856,9 +2800,6 @@ public:
/// @brief This class represents a cast unsigned integer to floating point.
class UIToFPInst : public CastInst {
- UIToFPInst(const UIToFPInst &CI)
- : CastInst(CI.getType(), UIToFP, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
UIToFPInst(
@@ -2895,9 +2836,6 @@ public:
/// @brief This class represents a cast from signed integer to floating point.
class SIToFPInst : public CastInst {
- SIToFPInst(const SIToFPInst &CI)
- : CastInst(CI.getType(), SIToFP, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
SIToFPInst(
@@ -2934,9 +2872,6 @@ public:
/// @brief This class represents a cast from floating point to unsigned integer
class FPToUIInst : public CastInst {
- FPToUIInst(const FPToUIInst &CI)
- : CastInst(CI.getType(), FPToUI, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
FPToUIInst(
@@ -2973,9 +2908,6 @@ public:
/// @brief This class represents a cast from floating point to signed integer.
class FPToSIInst : public CastInst {
- FPToSIInst(const FPToSIInst &CI)
- : CastInst(CI.getType(), FPToSI, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
FPToSIInst(
@@ -3012,9 +2944,6 @@ public:
/// @brief This class represents a cast from an integer to a pointer.
class IntToPtrInst : public CastInst {
- IntToPtrInst(const IntToPtrInst &CI)
- : CastInst(CI.getType(), IntToPtr, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
IntToPtrInst(
@@ -3051,9 +2980,6 @@ public:
/// @brief This class represents a cast from a pointer to an integer
class PtrToIntInst : public CastInst {
- PtrToIntInst(const PtrToIntInst &CI)
- : CastInst(CI.getType(), PtrToInt, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
PtrToIntInst(
@@ -3090,9 +3016,6 @@ public:
/// @brief This class represents a no-op cast from one type to another.
class BitCastInst : public CastInst {
- BitCastInst(const BitCastInst &CI)
- : CastInst(CI.getType(), BitCast, CI.getOperand(0)) {
- }
public:
/// @brief Constructor with insert-before-instruction semantics
BitCastInst(
diff --git a/include/llvm/Value.h b/include/llvm/Value.h
index 47933f0..fdc3aeb 100644
--- a/include/llvm/Value.h
+++ b/include/llvm/Value.h
@@ -240,6 +240,18 @@ public:
return SubclassID;
}
+ /// hasSameSubclassOptionalData - Test whether the optional flags contained
+ /// in this value are equal to the optional flags in the given value.
+ bool hasSameSubclassOptionalData(const Value *V) const {
+ return SubclassOptionalData == V->SubclassOptionalData;
+ }
+
+ /// intersectOptionalDataWith - Clear any optional flags in this value
+ /// that are not also set in the given value.
+ void intersectOptionalDataWith(const Value *V) {
+ SubclassOptionalData &= V->SubclassOptionalData;
+ }
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Value *) {
return true; // Values are always values.