mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[IR] Redefine Freeze instruction
Summary: This patch redefines freeze instruction from being UnaryOperator to a subclass of UnaryInstruction. ConstantExpr freeze is removed, as discussed in the previous review. FreezeOperator is not added because there's no ConstantExpr freeze. `freeze i8* null` test is added to `test/Bindings/llvm-c/freeze.ll` as well, because the null pointer-related bug in `tools/llvm-c/echo.cpp` is now fixed. InstVisitor has visitFreeze now because freeze is not unaryop anymore. Reviewers: whitequark, deadalnix, craig.topper, jdoerfert, lebedev.ri Reviewed By: craig.topper, lebedev.ri Subscribers: regehr, nlopes, mehdi_amini, hiraditya, steven_wu, dexonsmith, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69932
This commit is contained in:
parent
167dae6eb8
commit
8a733b9297
@ -69,7 +69,6 @@ typedef enum {
|
||||
|
||||
/* Standard Unary Operators */
|
||||
LLVMFNeg = 66,
|
||||
LLVMFreeze = 68,
|
||||
|
||||
/* Standard Binary Operators */
|
||||
LLVMAdd = 8,
|
||||
@ -128,6 +127,7 @@ typedef enum {
|
||||
LLVMShuffleVector = 52,
|
||||
LLVMExtractValue = 53,
|
||||
LLVMInsertValue = 54,
|
||||
LLVMFreeze = 68,
|
||||
|
||||
/* Atomic operators */
|
||||
LLVMFence = 55,
|
||||
@ -1601,6 +1601,7 @@ LLVMTypeRef LLVMX86MMXType(void);
|
||||
macro(ExtractValueInst) \
|
||||
macro(LoadInst) \
|
||||
macro(VAArgInst) \
|
||||
macro(FreezeInst) \
|
||||
macro(AtomicCmpXchgInst) \
|
||||
macro(AtomicRMWInst) \
|
||||
macro(FenceInst)
|
||||
@ -3748,7 +3749,6 @@ LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
|
||||
const char *Name);
|
||||
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
|
||||
LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
|
||||
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef V, const char *Name);
|
||||
|
||||
/* Memory */
|
||||
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
|
||||
@ -3909,6 +3909,8 @@ LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
|
||||
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
|
||||
LLVMValueRef EltVal, unsigned Index,
|
||||
const char *Name);
|
||||
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val,
|
||||
const char *Name);
|
||||
|
||||
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
|
||||
const char *Name);
|
||||
|
@ -391,8 +391,7 @@ enum CastOpcodes {
|
||||
/// have no fixed relation to the LLVM IR enum values. Changing these will
|
||||
/// break compatibility with old files.
|
||||
enum UnaryOpcodes {
|
||||
UNOP_FNEG = 0,
|
||||
UNOP_FREEZE = 1
|
||||
UNOP_FNEG = 0
|
||||
};
|
||||
|
||||
/// BinaryOpcodes - These are values used in the bitcode files to encode which
|
||||
@ -560,6 +559,7 @@ enum FunctionCodes {
|
||||
FUNC_CODE_INST_UNOP = 56, // UNOP: [opcode, ty, opval]
|
||||
FUNC_CODE_INST_CALLBR = 57, // CALLBR: [attr, cc, norm, transfs,
|
||||
// fnty, fnid, args...]
|
||||
FUNC_CODE_INST_FREEZE = 58, // FREEZE: [opty, opval]
|
||||
};
|
||||
|
||||
enum UseListCodes {
|
||||
|
@ -2393,7 +2393,7 @@ public:
|
||||
}
|
||||
|
||||
Value *CreateFreeze(Value *V, const Twine &Name = "") {
|
||||
return Insert(UnaryOperator::CreateFreeze(V, Name));
|
||||
return Insert(new FreezeInst(V), Name);
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -199,6 +199,7 @@ public:
|
||||
RetTy visitFuncletPadInst(FuncletPadInst &I) { DELEGATE(Instruction); }
|
||||
RetTy visitCleanupPadInst(CleanupPadInst &I) { DELEGATE(FuncletPadInst); }
|
||||
RetTy visitCatchPadInst(CatchPadInst &I) { DELEGATE(FuncletPadInst); }
|
||||
RetTy visitFreezeInst(FreezeInst &I) { DELEGATE(Instruction); }
|
||||
|
||||
// Handle the special instrinsic instruction classes.
|
||||
RetTy visitDbgDeclareInst(DbgDeclareInst &I) { DELEGATE(DbgVariableIntrinsic);}
|
||||
|
@ -140,84 +140,84 @@ HANDLE_TERM_INST (11, CallBr , CallBrInst) // A call-site terminator
|
||||
// Standard unary operators...
|
||||
FIRST_UNARY_INST(12)
|
||||
HANDLE_UNARY_INST(12, FNeg , UnaryOperator)
|
||||
HANDLE_UNARY_INST(13, Freeze, UnaryOperator)
|
||||
LAST_UNARY_INST(13)
|
||||
LAST_UNARY_INST(12)
|
||||
|
||||
// Standard binary operators...
|
||||
FIRST_BINARY_INST(14)
|
||||
HANDLE_BINARY_INST(14, Add , BinaryOperator)
|
||||
HANDLE_BINARY_INST(15, FAdd , BinaryOperator)
|
||||
HANDLE_BINARY_INST(16, Sub , BinaryOperator)
|
||||
HANDLE_BINARY_INST(17, FSub , BinaryOperator)
|
||||
HANDLE_BINARY_INST(18, Mul , BinaryOperator)
|
||||
HANDLE_BINARY_INST(19, FMul , BinaryOperator)
|
||||
HANDLE_BINARY_INST(20, UDiv , BinaryOperator)
|
||||
HANDLE_BINARY_INST(21, SDiv , BinaryOperator)
|
||||
HANDLE_BINARY_INST(22, FDiv , BinaryOperator)
|
||||
HANDLE_BINARY_INST(23, URem , BinaryOperator)
|
||||
HANDLE_BINARY_INST(24, SRem , BinaryOperator)
|
||||
HANDLE_BINARY_INST(25, FRem , BinaryOperator)
|
||||
FIRST_BINARY_INST(13)
|
||||
HANDLE_BINARY_INST(13, Add , BinaryOperator)
|
||||
HANDLE_BINARY_INST(14, FAdd , BinaryOperator)
|
||||
HANDLE_BINARY_INST(15, Sub , BinaryOperator)
|
||||
HANDLE_BINARY_INST(16, FSub , BinaryOperator)
|
||||
HANDLE_BINARY_INST(17, Mul , BinaryOperator)
|
||||
HANDLE_BINARY_INST(18, FMul , BinaryOperator)
|
||||
HANDLE_BINARY_INST(19, UDiv , BinaryOperator)
|
||||
HANDLE_BINARY_INST(20, SDiv , BinaryOperator)
|
||||
HANDLE_BINARY_INST(21, FDiv , BinaryOperator)
|
||||
HANDLE_BINARY_INST(22, URem , BinaryOperator)
|
||||
HANDLE_BINARY_INST(23, SRem , BinaryOperator)
|
||||
HANDLE_BINARY_INST(24, FRem , BinaryOperator)
|
||||
|
||||
// Logical operators (integer operands)
|
||||
HANDLE_BINARY_INST(26, Shl , BinaryOperator) // Shift left (logical)
|
||||
HANDLE_BINARY_INST(27, LShr , BinaryOperator) // Shift right (logical)
|
||||
HANDLE_BINARY_INST(28, AShr , BinaryOperator) // Shift right (arithmetic)
|
||||
HANDLE_BINARY_INST(29, And , BinaryOperator)
|
||||
HANDLE_BINARY_INST(30, Or , BinaryOperator)
|
||||
HANDLE_BINARY_INST(31, Xor , BinaryOperator)
|
||||
LAST_BINARY_INST(31)
|
||||
HANDLE_BINARY_INST(25, Shl , BinaryOperator) // Shift left (logical)
|
||||
HANDLE_BINARY_INST(26, LShr , BinaryOperator) // Shift right (logical)
|
||||
HANDLE_BINARY_INST(27, AShr , BinaryOperator) // Shift right (arithmetic)
|
||||
HANDLE_BINARY_INST(28, And , BinaryOperator)
|
||||
HANDLE_BINARY_INST(29, Or , BinaryOperator)
|
||||
HANDLE_BINARY_INST(30, Xor , BinaryOperator)
|
||||
LAST_BINARY_INST(30)
|
||||
|
||||
// Memory operators...
|
||||
FIRST_MEMORY_INST(32)
|
||||
HANDLE_MEMORY_INST(32, Alloca, AllocaInst) // Stack management
|
||||
HANDLE_MEMORY_INST(33, Load , LoadInst ) // Memory manipulation instrs
|
||||
HANDLE_MEMORY_INST(34, Store , StoreInst )
|
||||
HANDLE_MEMORY_INST(35, GetElementPtr, GetElementPtrInst)
|
||||
HANDLE_MEMORY_INST(36, Fence , FenceInst )
|
||||
HANDLE_MEMORY_INST(37, AtomicCmpXchg , AtomicCmpXchgInst )
|
||||
HANDLE_MEMORY_INST(38, AtomicRMW , AtomicRMWInst )
|
||||
LAST_MEMORY_INST(38)
|
||||
FIRST_MEMORY_INST(31)
|
||||
HANDLE_MEMORY_INST(31, Alloca, AllocaInst) // Stack management
|
||||
HANDLE_MEMORY_INST(32, Load , LoadInst ) // Memory manipulation instrs
|
||||
HANDLE_MEMORY_INST(33, Store , StoreInst )
|
||||
HANDLE_MEMORY_INST(34, GetElementPtr, GetElementPtrInst)
|
||||
HANDLE_MEMORY_INST(35, Fence , FenceInst )
|
||||
HANDLE_MEMORY_INST(36, AtomicCmpXchg , AtomicCmpXchgInst )
|
||||
HANDLE_MEMORY_INST(37, AtomicRMW , AtomicRMWInst )
|
||||
LAST_MEMORY_INST(37)
|
||||
|
||||
// Cast operators ...
|
||||
// NOTE: The order matters here because CastInst::isEliminableCastPair
|
||||
// NOTE: (see Instructions.cpp) encodes a table based on this ordering.
|
||||
FIRST_CAST_INST(39)
|
||||
HANDLE_CAST_INST(39, Trunc , TruncInst ) // Truncate integers
|
||||
HANDLE_CAST_INST(40, ZExt , ZExtInst ) // Zero extend integers
|
||||
HANDLE_CAST_INST(41, SExt , SExtInst ) // Sign extend integers
|
||||
HANDLE_CAST_INST(42, FPToUI , FPToUIInst ) // floating point -> UInt
|
||||
HANDLE_CAST_INST(43, FPToSI , FPToSIInst ) // floating point -> SInt
|
||||
HANDLE_CAST_INST(44, UIToFP , UIToFPInst ) // UInt -> floating point
|
||||
HANDLE_CAST_INST(45, SIToFP , SIToFPInst ) // SInt -> floating point
|
||||
HANDLE_CAST_INST(46, FPTrunc , FPTruncInst ) // Truncate floating point
|
||||
HANDLE_CAST_INST(47, FPExt , FPExtInst ) // Extend floating point
|
||||
HANDLE_CAST_INST(48, PtrToInt, PtrToIntInst) // Pointer -> Integer
|
||||
HANDLE_CAST_INST(49, IntToPtr, IntToPtrInst) // Integer -> Pointer
|
||||
HANDLE_CAST_INST(50, BitCast , BitCastInst ) // Type cast
|
||||
HANDLE_CAST_INST(51, AddrSpaceCast, AddrSpaceCastInst) // addrspace cast
|
||||
LAST_CAST_INST(51)
|
||||
FIRST_CAST_INST(38)
|
||||
HANDLE_CAST_INST(38, Trunc , TruncInst ) // Truncate integers
|
||||
HANDLE_CAST_INST(39, ZExt , ZExtInst ) // Zero extend integers
|
||||
HANDLE_CAST_INST(40, SExt , SExtInst ) // Sign extend integers
|
||||
HANDLE_CAST_INST(41, FPToUI , FPToUIInst ) // floating point -> UInt
|
||||
HANDLE_CAST_INST(42, FPToSI , FPToSIInst ) // floating point -> SInt
|
||||
HANDLE_CAST_INST(43, UIToFP , UIToFPInst ) // UInt -> floating point
|
||||
HANDLE_CAST_INST(44, SIToFP , SIToFPInst ) // SInt -> floating point
|
||||
HANDLE_CAST_INST(45, FPTrunc , FPTruncInst ) // Truncate floating point
|
||||
HANDLE_CAST_INST(46, FPExt , FPExtInst ) // Extend floating point
|
||||
HANDLE_CAST_INST(47, PtrToInt, PtrToIntInst) // Pointer -> Integer
|
||||
HANDLE_CAST_INST(48, IntToPtr, IntToPtrInst) // Integer -> Pointer
|
||||
HANDLE_CAST_INST(49, BitCast , BitCastInst ) // Type cast
|
||||
HANDLE_CAST_INST(50, AddrSpaceCast, AddrSpaceCastInst) // addrspace cast
|
||||
LAST_CAST_INST(50)
|
||||
|
||||
FIRST_FUNCLETPAD_INST(52)
|
||||
HANDLE_FUNCLETPAD_INST(52, CleanupPad, CleanupPadInst)
|
||||
HANDLE_FUNCLETPAD_INST(53, CatchPad , CatchPadInst)
|
||||
LAST_FUNCLETPAD_INST(53)
|
||||
FIRST_FUNCLETPAD_INST(51)
|
||||
HANDLE_FUNCLETPAD_INST(51, CleanupPad, CleanupPadInst)
|
||||
HANDLE_FUNCLETPAD_INST(52, CatchPad , CatchPadInst)
|
||||
LAST_FUNCLETPAD_INST(52)
|
||||
|
||||
// Other operators...
|
||||
FIRST_OTHER_INST(54)
|
||||
HANDLE_OTHER_INST(54, ICmp , ICmpInst ) // Integer comparison instruction
|
||||
HANDLE_OTHER_INST(55, FCmp , FCmpInst ) // Floating point comparison instr.
|
||||
HANDLE_OTHER_INST(56, PHI , PHINode ) // PHI node instruction
|
||||
HANDLE_OTHER_INST(57, Call , CallInst ) // Call a function
|
||||
HANDLE_OTHER_INST(58, Select , SelectInst ) // select instruction
|
||||
HANDLE_USER_INST (59, UserOp1, Instruction) // May be used internally in a pass
|
||||
HANDLE_USER_INST (60, UserOp2, Instruction) // Internal to passes only
|
||||
HANDLE_OTHER_INST(61, VAArg , VAArgInst ) // vaarg instruction
|
||||
HANDLE_OTHER_INST(62, ExtractElement, ExtractElementInst)// extract from vector
|
||||
HANDLE_OTHER_INST(63, InsertElement, InsertElementInst) // insert into vector
|
||||
HANDLE_OTHER_INST(64, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
|
||||
HANDLE_OTHER_INST(65, ExtractValue, ExtractValueInst)// extract from aggregate
|
||||
HANDLE_OTHER_INST(66, InsertValue, InsertValueInst) // insert into aggregate
|
||||
HANDLE_OTHER_INST(67, LandingPad, LandingPadInst) // Landing pad instruction.
|
||||
FIRST_OTHER_INST(53)
|
||||
HANDLE_OTHER_INST(53, ICmp , ICmpInst ) // Integer comparison instruction
|
||||
HANDLE_OTHER_INST(54, FCmp , FCmpInst ) // Floating point comparison instr.
|
||||
HANDLE_OTHER_INST(55, PHI , PHINode ) // PHI node instruction
|
||||
HANDLE_OTHER_INST(56, Call , CallInst ) // Call a function
|
||||
HANDLE_OTHER_INST(57, Select , SelectInst ) // select instruction
|
||||
HANDLE_USER_INST (58, UserOp1, Instruction) // May be used internally in a pass
|
||||
HANDLE_USER_INST (59, UserOp2, Instruction) // Internal to passes only
|
||||
HANDLE_OTHER_INST(60, VAArg , VAArgInst ) // vaarg instruction
|
||||
HANDLE_OTHER_INST(61, ExtractElement, ExtractElementInst)// extract from vector
|
||||
HANDLE_OTHER_INST(62, InsertElement, InsertElementInst) // insert into vector
|
||||
HANDLE_OTHER_INST(63, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
|
||||
HANDLE_OTHER_INST(64, ExtractValue, ExtractValueInst)// extract from aggregate
|
||||
HANDLE_OTHER_INST(65, InsertValue, InsertValueInst) // insert into aggregate
|
||||
HANDLE_OTHER_INST(66, LandingPad, LandingPadInst) // Landing pad instruction.
|
||||
HANDLE_OTHER_INST(67, Freeze, FreezeInst) // Freeze instruction.
|
||||
LAST_OTHER_INST(67)
|
||||
|
||||
#undef FIRST_TERM_INST
|
||||
|
@ -5290,6 +5290,35 @@ inline unsigned getLoadStoreAddressSpace(Value *I) {
|
||||
return cast<StoreInst>(I)->getPointerAddressSpace();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// FreezeInst Class
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// This class represents a freeze function that returns random concrete
|
||||
/// value if an operand is either a poison value or an undef value
|
||||
class FreezeInst : public UnaryInstruction {
|
||||
protected:
|
||||
// Note: Instruction needs to be a friend here to call cloneImpl.
|
||||
friend class Instruction;
|
||||
|
||||
/// Clone an identical FreezeInst
|
||||
FreezeInst *cloneImpl() const;
|
||||
|
||||
public:
|
||||
explicit FreezeInst(Value *S,
|
||||
const Twine &NameStr = "",
|
||||
Instruction *InsertBefore = nullptr);
|
||||
FreezeInst(Value *S, const Twine &NameStr, BasicBlock *InsertAtEnd);
|
||||
|
||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static inline bool classof(const Instruction *I) {
|
||||
return I->getOpcode() == Freeze;
|
||||
}
|
||||
static inline bool classof(const Value *V) {
|
||||
return isa<Instruction>(V) && classof(cast<Instruction>(V));
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_IR_INSTRUCTIONS_H
|
||||
|
@ -598,9 +598,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class FreezeOperator : public ConcreteOperator<Operator, Instruction::Freeze>
|
||||
{};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_IR_OPERATOR_H
|
||||
|
@ -825,28 +825,6 @@ m_FNegNSZ(const RHS &X) {
|
||||
return m_FSub(m_AnyZeroFP(), X);
|
||||
}
|
||||
|
||||
template <typename Op_t> struct Freeze_match {
|
||||
Op_t X;
|
||||
|
||||
Freeze_match(const Op_t &Op) : X(Op) {}
|
||||
template <typename OpTy> bool match(OpTy *V) {
|
||||
auto *I = dyn_cast<UnaryOperator>(V);
|
||||
if (!I) return false;
|
||||
|
||||
if (isa<FreezeOperator>(I))
|
||||
return X.match(I->getOperand(0));
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/// Matches freeze.
|
||||
template <typename OpTy>
|
||||
inline Freeze_match<OpTy>
|
||||
m_Freeze(const OpTy &X) {
|
||||
return Freeze_match<OpTy>(X);
|
||||
}
|
||||
|
||||
template <typename LHS, typename RHS>
|
||||
inline BinaryOp_match<LHS, RHS, Instruction::Mul> m_Mul(const LHS &L,
|
||||
const RHS &R) {
|
||||
@ -1255,6 +1233,12 @@ m_SelectCst(const Cond &C) {
|
||||
return m_Select(C, m_ConstantInt<L>(), m_ConstantInt<R>());
|
||||
}
|
||||
|
||||
/// Matches FreezeInst.
|
||||
template <typename OpTy>
|
||||
inline OneOps_match<OpTy, Instruction::Freeze> m_Freeze(const OpTy &Op) {
|
||||
return OneOps_match<OpTy, Instruction::Freeze>(Op);
|
||||
}
|
||||
|
||||
/// Matches InsertElementInst.
|
||||
template <typename Val_t, typename Elt_t, typename Idx_t>
|
||||
inline ThreeOps_match<Val_t, Elt_t, Idx_t, Instruction::InsertElement>
|
||||
|
@ -839,7 +839,6 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
} while (false)
|
||||
|
||||
INSTKEYWORD(fneg, FNeg);
|
||||
INSTKEYWORD(freeze, Freeze);
|
||||
|
||||
INSTKEYWORD(add, Add); INSTKEYWORD(fadd, FAdd);
|
||||
INSTKEYWORD(sub, Sub); INSTKEYWORD(fsub, FSub);
|
||||
@ -896,6 +895,8 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
INSTKEYWORD(catchpad, CatchPad);
|
||||
INSTKEYWORD(cleanuppad, CleanupPad);
|
||||
|
||||
INSTKEYWORD(freeze, Freeze);
|
||||
|
||||
#undef INSTKEYWORD
|
||||
|
||||
#define DWKEYWORD(TYPE, TOKEN) \
|
||||
|
@ -3418,8 +3418,7 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
|
||||
}
|
||||
|
||||
// Unary Operators.
|
||||
case lltok::kw_fneg:
|
||||
case lltok::kw_freeze: {
|
||||
case lltok::kw_fneg: {
|
||||
unsigned Opc = Lex.getUIntVal();
|
||||
Constant *Val;
|
||||
Lex.Lex();
|
||||
@ -3434,8 +3433,6 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
|
||||
if (!Val->getType()->isFPOrFPVectorTy())
|
||||
return Error(ID.Loc, "constexpr requires fp operands");
|
||||
break;
|
||||
case Instruction::Freeze:
|
||||
break;
|
||||
default: llvm_unreachable("Unknown unary operator!");
|
||||
}
|
||||
unsigned Flags = 0;
|
||||
@ -5729,7 +5726,6 @@ int LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB,
|
||||
Inst->setFastMathFlags(FMF);
|
||||
return false;
|
||||
}
|
||||
case lltok::kw_freeze: return ParseUnaryOp(Inst, PFS, KeywordVal, false);
|
||||
// Binary Operators.
|
||||
case lltok::kw_add:
|
||||
case lltok::kw_sub:
|
||||
@ -5833,6 +5829,7 @@ int LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB,
|
||||
return 0;
|
||||
}
|
||||
case lltok::kw_landingpad: return ParseLandingPad(Inst, PFS);
|
||||
case lltok::kw_freeze: return ParseFreeze(Inst, PFS);
|
||||
// Call.
|
||||
case lltok::kw_call: return ParseCall(Inst, PFS, CallInst::TCK_None);
|
||||
case lltok::kw_tail: return ParseCall(Inst, PFS, CallInst::TCK_Tail);
|
||||
@ -6333,14 +6330,16 @@ bool LLParser::ParseCleanupPad(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
/// ParseUnaryOp
|
||||
/// ::= UnaryOp TypeAndValue ',' Value
|
||||
///
|
||||
/// If IsFP is true, then fp operand is only allowed.
|
||||
/// If IsFP is false, then any integer operand is allowed, if it is true, any fp
|
||||
/// operand is allowed.
|
||||
bool LLParser::ParseUnaryOp(Instruction *&Inst, PerFunctionState &PFS,
|
||||
unsigned Opc, bool IsFP) {
|
||||
LocTy Loc; Value *LHS;
|
||||
if (ParseTypeAndValue(LHS, Loc, PFS))
|
||||
return true;
|
||||
|
||||
bool Valid = !IsFP || LHS->getType()->isFPOrFPVectorTy();
|
||||
bool Valid = IsFP ? LHS->getType()->isFPOrFPVectorTy()
|
||||
: LHS->getType()->isIntOrIntVectorTy();
|
||||
|
||||
if (!Valid)
|
||||
return Error(Loc, "invalid operand type for instruction");
|
||||
@ -6754,6 +6753,18 @@ bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// ParseFreeze
|
||||
/// ::= 'freeze' Type Value
|
||||
bool LLParser::ParseFreeze(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
LocTy Loc;
|
||||
Value *Op;
|
||||
if (ParseTypeAndValue(Op, Loc, PFS))
|
||||
return true;
|
||||
|
||||
Inst = new FreezeInst(Op);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// ParseCall
|
||||
/// ::= 'call' OptionalFastMathFlags OptionalCallingConv
|
||||
/// OptionalAttrs Type Value ParameterList OptionalAttrs
|
||||
|
@ -600,6 +600,7 @@ namespace llvm {
|
||||
int ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS);
|
||||
int ParseExtractValue(Instruction *&Inst, PerFunctionState &PFS);
|
||||
int ParseInsertValue(Instruction *&Inst, PerFunctionState &PFS);
|
||||
bool ParseFreeze(Instruction *&I, PerFunctionState &PFS);
|
||||
|
||||
// Use-list order directives.
|
||||
bool ParseUseListOrder(PerFunctionState *PFS = nullptr);
|
||||
|
@ -280,7 +280,6 @@ enum Kind {
|
||||
|
||||
// Instruction Opcodes (Opcode in UIntVal).
|
||||
kw_fneg,
|
||||
kw_freeze,
|
||||
kw_add,
|
||||
kw_fadd,
|
||||
kw_sub,
|
||||
@ -355,6 +354,8 @@ enum Kind {
|
||||
kw_insertvalue,
|
||||
kw_blockaddress,
|
||||
|
||||
kw_freeze,
|
||||
|
||||
// Metadata types.
|
||||
kw_distinct,
|
||||
|
||||
|
@ -1056,13 +1056,16 @@ static int getDecodedCastOpcode(unsigned Val) {
|
||||
}
|
||||
|
||||
static int getDecodedUnaryOpcode(unsigned Val, Type *Ty) {
|
||||
bool IsFP = Ty->isFPOrFPVectorTy();
|
||||
// UnOps are only valid for int/fp or vector of int/fp types
|
||||
if (!IsFP && !Ty->isIntOrIntVectorTy())
|
||||
return -1;
|
||||
|
||||
switch (Val) {
|
||||
default:
|
||||
return -1;
|
||||
case bitc::UNOP_FNEG:
|
||||
return Ty->isFPOrFPVectorTy() ? Instruction::FNeg : -1;
|
||||
case bitc::UNOP_FREEZE:
|
||||
return Instruction::Freeze;
|
||||
return IsFP ? Instruction::FNeg : -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3863,7 +3866,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
|
||||
case bitc::FUNC_CODE_INST_UNOP: { // UNOP: [opval, ty, opcode]
|
||||
unsigned OpNum = 0;
|
||||
Value *LHS;
|
||||
if (getValueTypePair(Record, OpNum, NextValueNo, LHS, &FullTy) ||
|
||||
if (getValueTypePair(Record, OpNum, NextValueNo, LHS) ||
|
||||
OpNum+1 > Record.size())
|
||||
return error("Invalid record");
|
||||
|
||||
@ -5116,6 +5119,19 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
|
||||
OperandBundles.emplace_back(BundleTags[Record[0]], std::move(Inputs));
|
||||
continue;
|
||||
}
|
||||
|
||||
case bitc::FUNC_CODE_INST_FREEZE: { // FREEZE: [opty,opval]
|
||||
unsigned OpNum = 0;
|
||||
Value *Op = nullptr;
|
||||
if (getValueTypePair(Record, OpNum, NextValueNo, Op, &FullTy))
|
||||
return error("Invalid record");
|
||||
if (OpNum != Record.size())
|
||||
return error("Invalid record");
|
||||
|
||||
I = new FreezeInst(Op);
|
||||
InstructionList.push_back(I);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add instruction to end of current BB. If there is no current BB, reject
|
||||
|
@ -521,7 +521,6 @@ static unsigned getEncodedUnaryOpcode(unsigned Opcode) {
|
||||
switch (Opcode) {
|
||||
default: llvm_unreachable("Unknown binary instruction!");
|
||||
case Instruction::FNeg: return bitc::UNOP_FNEG;
|
||||
case Instruction::Freeze: return bitc::UNOP_FREEZE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2435,17 +2434,6 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal,
|
||||
Record.push_back(VE.getTypeID(C->getOperand(0)->getType()));
|
||||
Record.push_back(VE.getValueID(C->getOperand(0)));
|
||||
AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
|
||||
} else if (Instruction::isUnaryOp(CE->getOpcode())) {
|
||||
assert(CE->getNumOperands() == 1 && "Unknown constant expr!");
|
||||
Code = bitc::CST_CODE_CE_UNOP;
|
||||
Record.push_back(getEncodedUnaryOpcode(CE->getOpcode()));
|
||||
Record.push_back(VE.getValueID(C->getOperand(0)));
|
||||
uint64_t Flags = getOptimizationFlags(CE);
|
||||
if (Flags != 0) {
|
||||
assert(CE->getOpcode() == Instruction::FNeg);
|
||||
Record.push_back(Flags);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
assert(CE->getNumOperands() == 2 && "Unknown constant expr!");
|
||||
Code = bitc::CST_CODE_CE_BINOP;
|
||||
@ -2457,6 +2445,16 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal,
|
||||
Record.push_back(Flags);
|
||||
}
|
||||
break;
|
||||
case Instruction::FNeg: {
|
||||
assert(CE->getNumOperands() == 1 && "Unknown constant expr!");
|
||||
Code = bitc::CST_CODE_CE_UNOP;
|
||||
Record.push_back(getEncodedUnaryOpcode(CE->getOpcode()));
|
||||
Record.push_back(VE.getValueID(C->getOperand(0)));
|
||||
uint64_t Flags = getOptimizationFlags(CE);
|
||||
if (Flags != 0)
|
||||
Record.push_back(Flags);
|
||||
break;
|
||||
}
|
||||
case Instruction::GetElementPtr: {
|
||||
Code = bitc::CST_CODE_CE_GEP;
|
||||
const auto *GO = cast<GEPOperator>(C);
|
||||
@ -2614,17 +2612,6 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
|
||||
AbbrevToUse = FUNCTION_INST_CAST_ABBREV;
|
||||
Vals.push_back(VE.getTypeID(I.getType()));
|
||||
Vals.push_back(getEncodedCastOpcode(I.getOpcode()));
|
||||
} else if (isa<UnaryOperator>(I)) {
|
||||
Code = bitc::FUNC_CODE_INST_UNOP;
|
||||
if (!pushValueAndType(I.getOperand(0), InstID, Vals))
|
||||
AbbrevToUse = FUNCTION_INST_UNOP_ABBREV;
|
||||
Vals.push_back(getEncodedUnaryOpcode(I.getOpcode()));
|
||||
uint64_t Flags = getOptimizationFlags(&I);
|
||||
if (Flags != 0) {
|
||||
if (AbbrevToUse == FUNCTION_INST_UNOP_ABBREV)
|
||||
AbbrevToUse = FUNCTION_INST_UNOP_FLAGS_ABBREV;
|
||||
Vals.push_back(Flags);
|
||||
}
|
||||
} else {
|
||||
assert(isa<BinaryOperator>(I) && "Unknown instruction!");
|
||||
Code = bitc::FUNC_CODE_INST_BINOP;
|
||||
@ -2640,6 +2627,19 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Instruction::FNeg: {
|
||||
Code = bitc::FUNC_CODE_INST_UNOP;
|
||||
if (!pushValueAndType(I.getOperand(0), InstID, Vals))
|
||||
AbbrevToUse = FUNCTION_INST_UNOP_ABBREV;
|
||||
Vals.push_back(getEncodedUnaryOpcode(I.getOpcode()));
|
||||
uint64_t Flags = getOptimizationFlags(&I);
|
||||
if (Flags != 0) {
|
||||
if (AbbrevToUse == FUNCTION_INST_UNOP_ABBREV)
|
||||
AbbrevToUse = FUNCTION_INST_UNOP_FLAGS_ABBREV;
|
||||
Vals.push_back(Flags);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Instruction::GetElementPtr: {
|
||||
Code = bitc::FUNC_CODE_INST_GEP;
|
||||
AbbrevToUse = FUNCTION_INST_GEP_ABBREV;
|
||||
@ -3034,6 +3034,10 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
|
||||
pushValue(I.getOperand(0), InstID, Vals); // valist.
|
||||
Vals.push_back(VE.getTypeID(I.getType())); // restype.
|
||||
break;
|
||||
case Instruction::Freeze:
|
||||
Code = bitc::FUNC_CODE_INST_FREEZE;
|
||||
pushValueAndType(I.getOperand(0), InstID, Vals);
|
||||
break;
|
||||
}
|
||||
|
||||
Stream.EmitRecord(Code, Vals, AbbrevToUse);
|
||||
|
@ -10593,7 +10593,7 @@ void SelectionDAGBuilder::visitSwitch(const SwitchInst &SI) {
|
||||
}
|
||||
}
|
||||
|
||||
void SelectionDAGBuilder::visitFreeze(const User &I) {
|
||||
void SelectionDAGBuilder::visitFreeze(const FreezeInst &I) {
|
||||
SDValue N = getValue(I.getOperand(0));
|
||||
setValue(&I, N);
|
||||
}
|
||||
|
@ -668,7 +668,6 @@ private:
|
||||
|
||||
void visitUnary(const User &I, unsigned Opcode);
|
||||
void visitFNeg(const User &I) { visitUnary(I, ISD::FNEG); }
|
||||
void visitFreeze(const User &I);
|
||||
|
||||
void visitBinary(const User &I, unsigned Opcode);
|
||||
void visitShift(const User &I, unsigned Opcode);
|
||||
@ -743,6 +742,7 @@ private:
|
||||
void visitAtomicStore(const StoreInst &I);
|
||||
void visitLoadFromSwiftError(const LoadInst &I);
|
||||
void visitStoreToSwiftError(const StoreInst &I);
|
||||
void visitFreeze(const FreezeInst &I);
|
||||
|
||||
void visitInlineAsm(ImmutableCallSite CS);
|
||||
void visitIntrinsicCall(const CallInst &I, unsigned Intrinsic);
|
||||
|
@ -941,22 +941,31 @@ Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg,
|
||||
Constant *llvm::ConstantFoldUnaryInstruction(unsigned Opcode, Constant *C) {
|
||||
assert(Instruction::isUnaryOp(Opcode) && "Non-unary instruction detected");
|
||||
|
||||
switch (static_cast<Instruction::UnaryOps>(Opcode)) {
|
||||
case Instruction::FNeg: {
|
||||
// Handle scalar UndefValue. Vectors are always evaluated per element.
|
||||
bool HasScalarUndef = !C->getType()->isVectorTy() && isa<UndefValue>(C);
|
||||
|
||||
if (HasScalarUndef) {
|
||||
switch (static_cast<Instruction::UnaryOps>(Opcode)) {
|
||||
case Instruction::FNeg:
|
||||
return C; // -undef -> undef
|
||||
case Instruction::UnaryOpsEnd:
|
||||
llvm_unreachable("Invalid UnaryOp");
|
||||
}
|
||||
}
|
||||
|
||||
// Constant should not be UndefValue, unless these are vector constants.
|
||||
assert(!HasScalarUndef && "Unexpected UndefValue");
|
||||
// We only have FP UnaryOps right now.
|
||||
assert(!isa<ConstantInt>(C) && "Unexpected Integer UnaryOp");
|
||||
|
||||
if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
|
||||
const APFloat &CV = CFP->getValueAPF();
|
||||
switch (Opcode) {
|
||||
default:
|
||||
break;
|
||||
case Instruction::FNeg:
|
||||
return ConstantFP::get(C->getContext(), neg(CV));
|
||||
}
|
||||
} else if (VectorType *VTy = dyn_cast<VectorType>(C->getType())) {
|
||||
// Fold each element and create a vector constant from those constants.
|
||||
SmallVector<Constant*, 16> Result;
|
||||
@ -970,22 +979,6 @@ Constant *llvm::ConstantFoldUnaryInstruction(unsigned Opcode, Constant *C) {
|
||||
|
||||
return ConstantVector::get(Result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Instruction::Freeze: {
|
||||
if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
|
||||
return CFP;
|
||||
} else if (ConstantInt *CINT = dyn_cast<ConstantInt>(C)) {
|
||||
return CINT;
|
||||
} else if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
|
||||
// A global variable is neither undef nor poison.
|
||||
return GV;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Instruction::UnaryOpsEnd:
|
||||
llvm_unreachable("Invalid UnaryOp");
|
||||
}
|
||||
|
||||
// We don't know how to fold this.
|
||||
return nullptr;
|
||||
|
@ -3410,11 +3410,6 @@ LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name) {
|
||||
return wrap(unwrap(B)->CreateFNeg(unwrap(V), Name));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef B, LLVMValueRef V,
|
||||
const char *Name) {
|
||||
return wrap(unwrap(B)->CreateFreeze(unwrap(V), Name));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMBuildNot(LLVMBuilderRef B, LLVMValueRef V, const char *Name) {
|
||||
return wrap(unwrap(B)->CreateNot(unwrap(V), Name));
|
||||
}
|
||||
@ -3902,6 +3897,11 @@ LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef B, LLVMValueRef AggVal,
|
||||
Index, Name));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef B, LLVMValueRef Val,
|
||||
const char *Name) {
|
||||
return wrap(unwrap(B)->CreateFreeze(unwrap(Val), Name));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef B, LLVMValueRef Val,
|
||||
const char *Name) {
|
||||
return wrap(unwrap(B)->CreateIsNull(unwrap(Val), Name));
|
||||
|
@ -307,7 +307,6 @@ const char *Instruction::getOpcodeName(unsigned OpCode) {
|
||||
|
||||
// Standard unary operators...
|
||||
case FNeg: return "fneg";
|
||||
case Freeze: return "freeze";
|
||||
|
||||
// Standard binary operators...
|
||||
case Add: return "add";
|
||||
@ -369,6 +368,7 @@ const char *Instruction::getOpcodeName(unsigned OpCode) {
|
||||
case InsertValue: return "insertvalue";
|
||||
case LandingPad: return "landingpad";
|
||||
case CleanupPad: return "cleanuppad";
|
||||
case Freeze: return "freeze";
|
||||
|
||||
default: return "<Invalid operator> ";
|
||||
}
|
||||
|
@ -2232,9 +2232,6 @@ void UnaryOperator::AssertOK() {
|
||||
"Tried to create a floating-point operation on a "
|
||||
"non-floating-point type!");
|
||||
break;
|
||||
case Freeze:
|
||||
// Freeze can take any type as an argument.
|
||||
break;
|
||||
default: llvm_unreachable("Invalid opcode provided");
|
||||
}
|
||||
#endif
|
||||
@ -4094,6 +4091,22 @@ void IndirectBrInst::removeDestination(unsigned idx) {
|
||||
setNumHungOffUseOperands(NumOps-1);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// FreezeInst Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
FreezeInst::FreezeInst(Value *S,
|
||||
const Twine &Name, Instruction *InsertBefore)
|
||||
: UnaryInstruction(S->getType(), Freeze, S, InsertBefore) {
|
||||
setName(Name);
|
||||
}
|
||||
|
||||
FreezeInst::FreezeInst(Value *S,
|
||||
const Twine &Name, BasicBlock *InsertAtEnd)
|
||||
: UnaryInstruction(S->getType(), Freeze, S, InsertAtEnd) {
|
||||
setName(Name);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// cloneImpl() implementations
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -4310,3 +4323,7 @@ UnreachableInst *UnreachableInst::cloneImpl() const {
|
||||
LLVMContext &Context = getContext();
|
||||
return new UnreachableInst(Context);
|
||||
}
|
||||
|
||||
FreezeInst *FreezeInst::cloneImpl() const {
|
||||
return new FreezeInst(getOperand(0));
|
||||
}
|
||||
|
@ -3145,9 +3145,6 @@ void Verifier::visitUnaryOperator(UnaryOperator &U) {
|
||||
Assert(U.getType()->isFPOrFPVectorTy(),
|
||||
"FNeg operator only works with float types!", &U);
|
||||
break;
|
||||
case Instruction::Freeze:
|
||||
// Freeze can take all kinds of types.
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unknown UnaryOperator opcode!");
|
||||
}
|
||||
|
@ -267,7 +267,6 @@ let test_constants () =
|
||||
* CHECK: @const_nsw_neg = global i64 sub nsw
|
||||
* CHECK: @const_nuw_neg = global i64 sub nuw
|
||||
* CHECK: @const_fneg = global double fneg
|
||||
* CHECK: @const_freeze = global i64 freeze
|
||||
* CHECK: @const_not = global i64 xor
|
||||
* CHECK: @const_add = global i64 add
|
||||
* CHECK: @const_nsw_add = global i64 add nsw
|
||||
@ -304,7 +303,6 @@ let test_constants () =
|
||||
ignore (define_global "const_nsw_neg" (const_nsw_neg foldbomb) m);
|
||||
ignore (define_global "const_nuw_neg" (const_nuw_neg foldbomb) m);
|
||||
ignore (define_global "const_fneg" (const_fneg ffoldbomb) m);
|
||||
ignore (define_global "const_freeze" (const_freeze foldbomb) m);
|
||||
ignore (define_global "const_not" (const_not foldbomb) m);
|
||||
ignore (define_global "const_add" (const_add foldbomb five) m);
|
||||
ignore (define_global "const_nsw_add" (const_nsw_add foldbomb five) m);
|
||||
@ -1402,8 +1400,8 @@ let test_builder () =
|
||||
ignore (build_nsw_neg p1 "build_nsw_neg" b);
|
||||
ignore (build_nuw_neg p1 "build_nuw_neg" b);
|
||||
ignore (build_fneg f1 "build_fneg" b);
|
||||
ignore (build_freeze f1 "build_freeze" b);
|
||||
ignore (build_not p1 "build_not" b);
|
||||
ignore (build_freeze p1 "build_freeze" b);
|
||||
ignore (build_unreachable b)
|
||||
end;
|
||||
|
||||
|
@ -18,5 +18,6 @@ define i32 @f(i32 %arg, <2 x i32> %arg2, float %arg3, <2 x float> %arg4,
|
||||
%10 = freeze %struct.T %arg6
|
||||
%11 = freeze [2 x i32] %arg7
|
||||
%12 = freeze { i32, i32 } %arg8
|
||||
%13 = freeze i8* null
|
||||
ret i32 %1
|
||||
}
|
||||
|
@ -1172,17 +1172,9 @@ continue:
|
||||
}
|
||||
|
||||
; Instructions -- Unary Operations
|
||||
define void @instructions.unops(double %op1, i32 %op2, <2 x i32> %op3, i8* %op4) {
|
||||
define void @instructions.unops(double %op1) {
|
||||
fneg double %op1
|
||||
; CHECK: fneg double %op1
|
||||
freeze i32 %op2
|
||||
; CHECK: freeze i32 %op2
|
||||
freeze double %op1
|
||||
; CHECK: freeze double %op1
|
||||
freeze <2 x i32> %op3
|
||||
; CHECK: freeze <2 x i32> %op3
|
||||
freeze i8* %op4
|
||||
; CHECK: freeze i8* %op4
|
||||
ret void
|
||||
}
|
||||
|
||||
@ -1377,7 +1369,7 @@ define void @instructions.conversions() {
|
||||
}
|
||||
|
||||
; Instructions -- Other Operations
|
||||
define void @instructions.other(i32 %op1, i32 %op2, half %fop1, half %fop2) {
|
||||
define void @instructions.other(i32 %op1, i32 %op2, half %fop1, half %fop2, <2 x i32> %vop, i8* %pop) {
|
||||
entry:
|
||||
icmp eq i32 %op1, %op2
|
||||
; CHECK: icmp eq i32 %op1, %op2
|
||||
@ -1457,6 +1449,16 @@ exit:
|
||||
tail call ghccc nonnull i32* @f.nonnull() minsize
|
||||
; CHECK: tail call ghccc nonnull i32* @f.nonnull() #7
|
||||
|
||||
freeze i32 %op1
|
||||
; CHECK: freeze i32 %op1
|
||||
freeze i32 10
|
||||
; CHECK: freeze i32 10
|
||||
freeze half %fop1
|
||||
; CHECK: freeze half %fop1
|
||||
freeze <2 x i32> %vop
|
||||
; CHECK: freeze <2 x i32> %vop
|
||||
freeze i8* %pop
|
||||
; CHECK: freeze i8* %pop
|
||||
ret void
|
||||
}
|
||||
|
||||
@ -1834,10 +1836,6 @@ define void @instructions.strictfp() strictfp {
|
||||
ret void
|
||||
}
|
||||
|
||||
define i64 @constexpr_freeze() {
|
||||
ret i64 freeze (i64 32)
|
||||
}
|
||||
|
||||
; immarg attribute
|
||||
declare void @llvm.test.immarg.intrinsic(i32 immarg)
|
||||
; CHECK: declare void @llvm.test.immarg.intrinsic(i32 immarg)
|
||||
|
@ -3,13 +3,13 @@
|
||||
; CHECK-LABEL: @int_ptr_arg_different
|
||||
; CHECK-NEXT: call void asm
|
||||
|
||||
; CHECK-LABEL: @int_ptr_null
|
||||
; CHECK-NEXT: tail call void @float_ptr_null()
|
||||
|
||||
; CHECK-LABEL: @int_ptr_arg_same
|
||||
; CHECK-NEXT: %2 = bitcast i32* %0 to float*
|
||||
; CHECK-NEXT: tail call void @float_ptr_arg_same(float* %2)
|
||||
|
||||
; CHECK-LABEL: @int_ptr_null
|
||||
; CHECK-NEXT: tail call void @float_ptr_null()
|
||||
|
||||
; Used to satisfy minimum size limit
|
||||
declare void @stuff()
|
||||
|
||||
|
@ -45,6 +45,54 @@ TEST(VerifierTest, Branch_i1) {
|
||||
EXPECT_TRUE(verifyFunction(*F));
|
||||
}
|
||||
|
||||
TEST(VerifierTest, Freeze) {
|
||||
LLVMContext C;
|
||||
Module M("M", C);
|
||||
FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false);
|
||||
Function *F = Function::Create(FTy, Function::ExternalLinkage, "foo", M);
|
||||
BasicBlock *Entry = BasicBlock::Create(C, "entry", F);
|
||||
ReturnInst *RI = ReturnInst::Create(C, Entry);
|
||||
|
||||
IntegerType *ITy = IntegerType::get(C, 32);
|
||||
ConstantInt *CI = ConstantInt::get(ITy, 0);
|
||||
|
||||
// Valid type : freeze(<2 x i32>)
|
||||
Constant *CV = ConstantVector::getSplat(2, CI);
|
||||
FreezeInst *FI_vec = new FreezeInst(CV);
|
||||
FI_vec->insertBefore(RI);
|
||||
|
||||
EXPECT_FALSE(verifyFunction(*F));
|
||||
|
||||
FI_vec->eraseFromParent();
|
||||
|
||||
// Valid type : freeze(float)
|
||||
Constant *CFP = ConstantFP::get(Type::getDoubleTy(C), 0.0);
|
||||
FreezeInst *FI_dbl = new FreezeInst(CFP);
|
||||
FI_dbl->insertBefore(RI);
|
||||
|
||||
EXPECT_FALSE(verifyFunction(*F));
|
||||
|
||||
FI_dbl->eraseFromParent();
|
||||
|
||||
// Valid type : freeze(i32*)
|
||||
PointerType *PT = PointerType::get(ITy, 0);
|
||||
ConstantPointerNull *CPN = ConstantPointerNull::get(PT);
|
||||
FreezeInst *FI_ptr = new FreezeInst(CPN);
|
||||
FI_ptr->insertBefore(RI);
|
||||
|
||||
EXPECT_FALSE(verifyFunction(*F));
|
||||
|
||||
FI_ptr->eraseFromParent();
|
||||
|
||||
// Valid type : freeze(int)
|
||||
FreezeInst *FI = new FreezeInst(CI);
|
||||
FI->insertBefore(RI);
|
||||
|
||||
EXPECT_FALSE(verifyFunction(*F));
|
||||
|
||||
FI_ptr->eraseFromParent();
|
||||
}
|
||||
|
||||
TEST(VerifierTest, InvalidRetAttribute) {
|
||||
LLVMContext C;
|
||||
Module M("M", C);
|
||||
|
Loading…
x
Reference in New Issue
Block a user