Index: include/llvm-c/Core.h =================================================================== --- include/llvm-c/Core.h +++ include/llvm-c/Core.h @@ -69,6 +69,7 @@ /* Standard Unary Operators */ LLVMFNeg = 66, + LLVMFreeze = 68, /* Standard Binary Operators */ LLVMAdd = 8, @@ -3746,6 +3747,7 @@ 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); Index: include/llvm/Bitcode/LLVMBitCodes.h =================================================================== --- include/llvm/Bitcode/LLVMBitCodes.h +++ include/llvm/Bitcode/LLVMBitCodes.h @@ -391,7 +391,8 @@ /// have no fixed relation to the LLVM IR enum values. Changing these will /// break compatibility with old files. enum UnaryOpcodes { - UNOP_NEG = 0 + UNOP_NEG = 0, + UNOP_FREEZE = 1 }; /// BinaryOpcodes - These are values used in the bitcode files to encode which Index: include/llvm/CodeGen/GlobalISel/IRTranslator.h =================================================================== --- include/llvm/CodeGen/GlobalISel/IRTranslator.h +++ include/llvm/CodeGen/GlobalISel/IRTranslator.h @@ -483,6 +483,9 @@ bool translateUserOp2(const User &U, MachineIRBuilder &MIRBuilder) { return false; } + bool translateFreeze(const User &U, MachineIRBuilder &MIRBuilder) { + return false; + } /// @} Index: include/llvm/IR/IRBuilder.h =================================================================== --- include/llvm/IR/IRBuilder.h +++ include/llvm/IR/IRBuilder.h @@ -2371,6 +2371,10 @@ return Insert(LandingPadInst::Create(Ty, NumClauses), Name); } + Value *CreateFreeze(Value *V, const Twine &Name = "") { + return Insert(UnaryOperator::CreateFreeze(V, Name)); + } + //===--------------------------------------------------------------------===// // Utility creation methods //===--------------------------------------------------------------------===// Index: include/llvm/IR/Instruction.def =================================================================== --- include/llvm/IR/Instruction.def +++ include/llvm/IR/Instruction.def @@ -140,84 +140,85 @@ // Standard unary operators... FIRST_UNARY_INST(12) HANDLE_UNARY_INST(12, FNeg , UnaryOperator) - LAST_UNARY_INST(12) +HANDLE_UNARY_INST(13, Freeze, UnaryOperator) + LAST_UNARY_INST(13) // Standard binary operators... - 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) + 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) // Logical operators (integer operands) -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) +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) // Memory operators... - 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) + 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) // Cast operators ... // NOTE: The order matters here because CastInst::isEliminableCastPair // NOTE: (see Instructions.cpp) encodes a table based on this ordering. - 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(51) -HANDLE_FUNCLETPAD_INST(51, CleanupPad, CleanupPadInst) -HANDLE_FUNCLETPAD_INST(52, CatchPad , CatchPadInst) - LAST_FUNCLETPAD_INST(52) + 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_FUNCLETPAD_INST(52) +HANDLE_FUNCLETPAD_INST(52, CleanupPad, CleanupPadInst) +HANDLE_FUNCLETPAD_INST(53, CatchPad , CatchPadInst) + LAST_FUNCLETPAD_INST(53) // Other operators... - 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. - LAST_OTHER_INST(66) + 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. + LAST_OTHER_INST(67) #undef FIRST_TERM_INST #undef HANDLE_TERM_INST Index: include/llvm/IR/PatternMatch.h =================================================================== --- include/llvm/IR/PatternMatch.h +++ include/llvm/IR/PatternMatch.h @@ -816,6 +816,28 @@ return m_FSub(m_AnyZeroFP(), X); } +template struct Freeze_match { + Op_t X; + + Freeze_match(const Op_t &Op) : X(Op) {} + template bool match(OpTy *V) { + auto *I = dyn_cast(V); + if (!I) return false; + + if (I->getOpcode() == Instruction::Freeze) + return X.match(I->getOperand(0)); + + return false; + } +}; + +/// Matches freeze. +template +inline Freeze_match +m_Freeze(const OpTy &X) { + return Freeze_match(X); +} + template inline BinaryOp_match m_Mul(const LHS &L, const RHS &R) { Index: lib/AsmParser/LLLexer.cpp =================================================================== --- lib/AsmParser/LLLexer.cpp +++ lib/AsmParser/LLLexer.cpp @@ -835,6 +835,7 @@ } while (false) INSTKEYWORD(fneg, FNeg); + INSTKEYWORD(freeze, Freeze); INSTKEYWORD(add, Add); INSTKEYWORD(fadd, FAdd); INSTKEYWORD(sub, Sub); INSTKEYWORD(fsub, FSub); Index: lib/AsmParser/LLParser.h =================================================================== --- lib/AsmParser/LLParser.h +++ lib/AsmParser/LLParser.h @@ -576,7 +576,7 @@ bool ParseCallBr(Instruction *&Inst, PerFunctionState &PFS); bool ParseUnaryOp(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc, - bool IsFP); + bool IsFP, bool isInt); bool ParseArithmetic(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc, bool IsFP); bool ParseLogical(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc); Index: lib/AsmParser/LLParser.cpp =================================================================== --- lib/AsmParser/LLParser.cpp +++ lib/AsmParser/LLParser.cpp @@ -5706,13 +5706,14 @@ // Unary Operators. case lltok::kw_fneg: { FastMathFlags FMF = EatFastMathFlagsIfPresent(); - int Res = ParseUnaryOp(Inst, PFS, KeywordVal, /*IsFP*/true); + int Res = ParseUnaryOp(Inst, PFS, KeywordVal, /*IsFP*/true, /*IsInt*/false); if (Res != 0) return Res; if (FMF.any()) Inst->setFastMathFlags(FMF); return false; } + case lltok::kw_freeze: return ParseUnaryOp(Inst, PFS, KeywordVal, true, true); // Binary Operators. case lltok::kw_add: case lltok::kw_sub: @@ -6316,16 +6317,18 @@ /// ParseUnaryOp /// ::= UnaryOp TypeAndValue ',' Value /// -/// If IsFP is false, then any integer operand is allowed, if it is true, any fp -/// operand is allowed. +/// If IsFP is true, then any fp operand is allowed. +// If IsInt is true, then any integer operand is allowed. bool LLParser::ParseUnaryOp(Instruction *&Inst, PerFunctionState &PFS, - unsigned Opc, bool IsFP) { + unsigned Opc, bool IsFP, bool IsInt) { LocTy Loc; Value *LHS; if (ParseTypeAndValue(LHS, Loc, PFS)) return true; - bool Valid = IsFP ? LHS->getType()->isFPOrFPVectorTy() - : LHS->getType()->isIntOrIntVectorTy(); + bool FPCheck = LHS->getType()->isFPOrFPVectorTy(); + bool IntCheck = LHS->getType()->isIntOrIntVectorTy(); + bool Valid = (IsFP && IsInt && (FPCheck || IntCheck)) || + (IsFP && FPCheck) || (IsInt && IntCheck); if (!Valid) return Error(Loc, "invalid operand type for instruction"); Index: lib/AsmParser/LLToken.h =================================================================== --- lib/AsmParser/LLToken.h +++ lib/AsmParser/LLToken.h @@ -277,6 +277,7 @@ // Instruction Opcodes (Opcode in UIntVal). kw_fneg, + kw_freeze, kw_add, kw_fadd, kw_sub, Index: lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- lib/Bitcode/Reader/BitcodeReader.cpp +++ lib/Bitcode/Reader/BitcodeReader.cpp @@ -1065,6 +1065,8 @@ return -1; case bitc::UNOP_NEG: return IsFP ? Instruction::FNeg : -1; + case bitc::UNOP_FREEZE: + return Instruction::Freeze; } } Index: lib/Bitcode/Writer/BitcodeWriter.cpp =================================================================== --- lib/Bitcode/Writer/BitcodeWriter.cpp +++ lib/Bitcode/Writer/BitcodeWriter.cpp @@ -521,6 +521,7 @@ switch (Opcode) { default: llvm_unreachable("Unknown binary instruction!"); case Instruction::FNeg: return bitc::UNOP_NEG; + case Instruction::Freeze: return bitc::UNOP_FREEZE; } } @@ -2611,6 +2612,17 @@ AbbrevToUse = FUNCTION_INST_CAST_ABBREV; Vals.push_back(VE.getTypeID(I.getType())); Vals.push_back(getEncodedCastOpcode(I.getOpcode())); + } else if (isa(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(I) && "Unknown instruction!"); Code = bitc::FUNC_CODE_INST_BINOP; @@ -2626,19 +2638,6 @@ } } 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; Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -668,6 +668,7 @@ 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); Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -10541,3 +10541,8 @@ lowerWorkItem(W, SI.getCondition(), SwitchMBB, DefaultMBB); } } + +void SelectionDAGBuilder::visitFreeze(const User &I) { + SDValue N = getValue(I.getOperand(0)); + setValue(&I, N); +} Index: lib/CodeGen/TargetLoweringBase.cpp =================================================================== --- lib/CodeGen/TargetLoweringBase.cpp +++ lib/CodeGen/TargetLoweringBase.cpp @@ -1629,6 +1629,7 @@ case ExtractValue: return ISD::MERGE_VALUES; case InsertValue: return ISD::MERGE_VALUES; case LandingPad: return 0; + case Freeze: return 0; } llvm_unreachable("Unknown instruction type encountered!"); Index: lib/IR/ConstantFold.cpp =================================================================== --- lib/IR/ConstantFold.cpp +++ lib/IR/ConstantFold.cpp @@ -928,6 +928,7 @@ switch (static_cast(Opcode)) { case Instruction::FNeg: return C; // -undef -> undef + case Instruction::Freeze: case Instruction::UnaryOpsEnd: llvm_unreachable("Invalid UnaryOp"); } Index: lib/IR/Core.cpp =================================================================== --- lib/IR/Core.cpp +++ lib/IR/Core.cpp @@ -3410,6 +3410,11 @@ 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)); } Index: lib/IR/Instruction.cpp =================================================================== --- lib/IR/Instruction.cpp +++ lib/IR/Instruction.cpp @@ -307,6 +307,7 @@ // Standard unary operators... case FNeg: return "fneg"; + case Freeze: return "freeze"; // Standard binary operators... case Add: return "add"; Index: lib/IR/Instructions.cpp =================================================================== --- lib/IR/Instructions.cpp +++ lib/IR/Instructions.cpp @@ -2234,6 +2234,13 @@ "Tried to create a floating-point operation on a " "non-floating-point type!"); break; + case Freeze: + assert(getType() == LHS->getType() && + "Unary operation should return same type as operand!"); + assert((getType()->isIntOrIntVectorTy() || getType()->isFPOrFPVectorTy()) && + "Tried to create a freeze operation on a " + "non-integer, non-floating-point type!"); + break; default: llvm_unreachable("Invalid opcode provided"); } #endif Index: lib/IR/Verifier.cpp =================================================================== --- lib/IR/Verifier.cpp +++ lib/IR/Verifier.cpp @@ -3138,6 +3138,10 @@ Assert(U.getType()->isFPOrFPVectorTy(), "FNeg operator only works with float types!", &U); break; + case Instruction::Freeze: + Assert(U.getType()->isIntOrIntVectorTy() || U.getType()->isFPOrFPVectorTy(), + "Freeze operator only works with float/int types!", &U); + break; default: llvm_unreachable("Unknown UnaryOperator opcode!"); } Index: test/Bindings/llvm-c/freeze.ll =================================================================== --- /dev/null +++ test/Bindings/llvm-c/freeze.ll @@ -0,0 +1,13 @@ +; RUN: llvm-as < %s | llvm-dis > %t.orig +; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo +; RUN: diff -w %t.orig %t.echo + +define i32 @f(i32 %arg, <2 x i32> %arg2, float %arg3, <2 x float> %arg4) { + %1 = freeze i32 %arg + %2 = freeze i32 10 + %3 = freeze i32 %1 + %4 = freeze <2 x i32> %arg2 + %5 = freeze float %arg3 + %6 = freeze <2 x float> %arg4 + ret i32 %1 +} Index: test/Bitcode/compatibility.ll =================================================================== --- test/Bitcode/compatibility.ll +++ test/Bitcode/compatibility.ll @@ -1102,9 +1102,15 @@ } ; Instructions -- Unary Operations -define void @instructions.unops(double %op1) { +define void @instructions.unops(double %op1, i32 %op2, <2 x i32> %op3) { 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 ret void } Index: test/Bitcode/freeze-pointer.ll =================================================================== --- /dev/null +++ test/Bitcode/freeze-pointer.ll @@ -0,0 +1,7 @@ +; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s + +; CHECK: freeze-pointer.ll:[[@LINE+2]]:15: error: invalid operand type for instruction +define i32* @ptr(i32* %x) { + %y = freeze i32* %x + ret i32* %y +} Index: tools/llvm-c-test/echo.cpp =================================================================== --- tools/llvm-c-test/echo.cpp +++ tools/llvm-c-test/echo.cpp @@ -748,6 +748,11 @@ Dst = LLVMBuildInsertValue(Builder, Agg, V, I, Name); break; } + case LLVMFreeze: { + LLVMValueRef Arg = CloneValue(LLVMGetOperand(Src, 0)); + Dst = LLVMBuildFreeze(Builder, Arg, Name); + break; + } default: break; }