Index: llvm-convert.cpp =================================================================== --- llvm-convert.cpp (revision 122083) +++ llvm-convert.cpp (working copy) @@ -551,26 +551,34 @@ // Binary Operators case LT_EXPR: Result = EmitCompare(exp, ICmpInst::ICMP_ULT, ICmpInst::ICMP_SLT, - FCmpInst::FCMP_OLT); break; + FCmpInst::FCMP_OLT); + break; case LE_EXPR: Result = EmitCompare(exp, ICmpInst::ICMP_ULE, ICmpInst::ICMP_SLE, - FCmpInst::FCMP_OLE); break; + FCmpInst::FCMP_OLE); + break; case GT_EXPR: Result = EmitCompare(exp, ICmpInst::ICMP_UGT, ICmpInst::ICMP_SGT, - FCmpInst::FCMP_OGT); break; + FCmpInst::FCMP_OGT); + break; case GE_EXPR: Result = EmitCompare(exp, ICmpInst::ICMP_UGE, ICmpInst::ICMP_SGE, - FCmpInst::FCMP_OGE); break; + FCmpInst::FCMP_OGE); + break; case EQ_EXPR: Result = EmitCompare(exp, ICmpInst::ICMP_EQ, ICmpInst::ICMP_EQ, - FCmpInst::FCMP_OEQ); break; + FCmpInst::FCMP_OEQ); + break; case NE_EXPR: Result = EmitCompare(exp, ICmpInst::ICMP_NE, ICmpInst::ICMP_NE, - FCmpInst::FCMP_UNE); break; + FCmpInst::FCMP_UNE); + break; case UNORDERED_EXPR: - Result = EmitCompare(exp, 0, 0, FCmpInst::FCMP_UNO); break; + Result = EmitCompare(exp, 0, 0, FCmpInst::FCMP_UNO); + break; case ORDERED_EXPR: - Result = EmitCompare(exp, 0, 0, FCmpInst::FCMP_ORD); break; + Result = EmitCompare(exp, 0, 0, FCmpInst::FCMP_ORD); + break; case UNLT_EXPR: Result = EmitCompare(exp, 0, 0, FCmpInst::FCMP_ULT); break; case UNLE_EXPR: Result = EmitCompare(exp, 0, 0, FCmpInst::FCMP_ULE); break; case UNGT_EXPR: Result = EmitCompare(exp, 0, 0, FCmpInst::FCMP_UGT); break; @@ -936,7 +944,7 @@ void TreeToLLVM::EmitMemCpy(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align) { const Type *SBP = PointerType::get(Type::Int8Ty); - static Function *MemCpy = 0; + static Constant *MemCpy = 0; const Type *IntPtr = TD.getIntPtrType(); if (!MemCpy) { const char *Name = IntPtr == Type::Int32Ty ? @@ -956,7 +964,7 @@ void TreeToLLVM::EmitMemMove(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align) { const Type *SBP = PointerType::get(Type::Int8Ty); - static Function *MemMove = 0; + static Constant *MemMove = 0; const Type *IntPtr = TD.getIntPtrType(); if (!MemMove) { const char *Name = IntPtr == Type::Int32Ty ? @@ -975,7 +983,7 @@ void TreeToLLVM::EmitMemSet(Value *DestPtr, Value *SrcVal, Value *Size, unsigned Align) { const Type *SBP = PointerType::get(Type::Int8Ty); - static Function *MemSet = 0; + static Constant *MemSet = 0; const Type *IntPtr = TD.getIntPtrType(); if (!MemSet) { const char *Name = IntPtr == Type::Int32Ty ? @@ -2409,32 +2417,9 @@ } // Handle floating point comparisons, if we get here. - Value *Result = 0; - if (FPPred) - Result = new FCmpInst(FCmpInst::Predicate(FPPred), LHS, RHS, "tmp", CurBB); + Value *Result = + new FCmpInst(FCmpInst::Predicate(FPPred), LHS, RHS, "tmp", CurBB); - if (CmpInst::isUnordered(FCmpInst::Predicate(FPPred))) { - static Function *IsUnordF = 0, *IsUnordD = 0; - Function *&Callee = LHS->getType() == Type::FloatTy ? IsUnordF : IsUnordD; - const char *Name = LHS->getType() == Type::FloatTy ? - "llvm.isunordered.f32" : "llvm.isunordered.f64"; - - if (Callee == 0) - Callee = TheModule->getOrInsertFunction(Name, - Type::BoolTy, LHS->getType(), - LHS->getType(), NULL); - - Value *IsUnord = new CallInst(Callee, LHS, RHS, "tmp", CurBB); - if (Result) - Result = BinaryOperator::createOr(Result, IsUnord, "tmp", CurBB); - else - Result = IsUnord; - - // If this is an ORDERED_EXPR, invert the result of the isunordered call. - if (TREE_CODE(exp) == ORDERED_EXPR) - Result = BinaryOperator::createNot(Result, "tmp", CurBB); - } - // The GCC type is probably an int, not a bool. return CastToUIntType(Result, ConvertType(TREE_TYPE(exp))); } @@ -3144,7 +3129,7 @@ Value *DestLoc, Value *&Result) { if (DECL_BUILT_IN_CLASS(fndecl) == BUILT_IN_MD) { unsigned FnCode = DECL_FUNCTION_CODE(fndecl); - static std::vector TargetBuiltinCache; + static std::vector TargetBuiltinCache; if (TargetBuiltinCache.size() <= FnCode) TargetBuiltinCache.resize(FnCode+1); @@ -3344,8 +3329,10 @@ } if (*FCache == 0) - *FCache = TheModule->getOrInsertFunction(Name, InVal->getType(), - InVal->getType(), NULL); + *FCache = cast(TheModule->getOrInsertFunction(Name, + InVal->getType(), + InVal->getType(), + NULL)); Result = new CallInst(*FCache, InVal, "tmp", CurBB); // The LLVM intrinsics for these return the same type as their operands. The @@ -3368,8 +3355,9 @@ } if (*FCache == 0) - *FCache = TheModule->getOrInsertFunction(Name, Amt->getType(), - Amt->getType(), NULL); + *FCache = cast(TheModule->getOrInsertFunction(Name,Amt->getType(), + Amt->getType(), + NULL)); return new CallInst(*FCache, Amt, "tmp", CurBB); } @@ -3382,9 +3370,9 @@ Value *Pow = Emit(TREE_VALUE(TREE_CHAIN(ArgList)), 0); Pow = CastToSIntType(Pow, Type::Int32Ty); - static Function *Fn32 = 0, *Fn64 = 0; + static Constant *Fn32 = 0, *Fn64 = 0; const char *Name; - Function **FCache; + Constant **FCache; switch (Val->getType()->getTypeID()) { default: assert(0 && "Unknown FP type!"); case Type::FloatTyID: Name = "llvm.powi.f32"; FCache = &Fn32; break; @@ -3394,7 +3382,8 @@ // First time we used this intrinsic? if (*FCache == 0) *FCache = TheModule->getOrInsertFunction(Name, Val->getType(), - Val->getType(), Type::Int32Ty, NULL); + Val->getType(), Type::Int32Ty, + NULL); return new CallInst(*FCache, Val, Pow, "tmp", CurBB); } @@ -3526,7 +3515,7 @@ Ptr = CastToType(Instruction::BitCast, Ptr, PointerType::get(Type::Int8Ty)); - static Function *llvm_prefetch_fn = 0; + static Constant *llvm_prefetch_fn = 0; if (!llvm_prefetch_fn) llvm_prefetch_fn = TheModule->getOrInsertFunction("llvm.prefetch", Type::VoidTy, @@ -3558,7 +3547,7 @@ } Value *Fn; - static Function *llvm_retaddr = 0, *llvm_frameaddr; + static Constant *llvm_retaddr = 0, *llvm_frameaddr; if (!isFrame) { if (!llvm_retaddr) llvm_retaddr = @@ -3585,7 +3574,7 @@ if (!validate_arglist(arglist, VOID_TYPE)) return false; - static Function *Fn = 0; + static Constant *Fn = 0; if (!Fn) Fn = TheModule->getOrInsertFunction("llvm.stacksave", PointerType::get(Type::Int8Ty), NULL); @@ -3598,7 +3587,7 @@ if (!validate_arglist(arglist, POINTER_TYPE, VOID_TYPE)) return false; - static Function *Fn = 0; + static Constant *Fn = 0; if (!Fn) Fn = TheModule->getOrInsertFunction("llvm.stackrestore", Type::VoidTy, PointerType::get(Type::Int8Ty), NULL); @@ -3634,7 +3623,7 @@ tree arglist = TREE_OPERAND(exp, 1); tree fntype = TREE_TYPE(current_function_decl); - static Function *llvm_va_start_fn = 0; + static Constant *llvm_va_start_fn = 0; if (!llvm_va_start_fn) { tree FnDecl = TREE_OPERAND(TREE_OPERAND(exp, 0), 0); const FunctionType *FnTy = @@ -3662,7 +3651,8 @@ Value *ArgVal = Emit(TREE_VALUE(arglist), 0); - const Type *FTy = llvm_va_start_fn->getType()->getElementType(); + const Type *FTy = + cast(llvm_va_start_fn->getType())->getElementType(); ArgVal = CastToType(Instruction::BitCast, ArgVal, cast(FTy)->getParamType(0)); new CallInst(llvm_va_start_fn, ArgVal, "", CurBB); @@ -3670,7 +3660,7 @@ } bool TreeToLLVM::EmitBuiltinVAEnd(tree exp) { - static Function *llvm_va_end_fn = 0; + static Constant *llvm_va_end_fn = 0; if (!llvm_va_end_fn) { tree FnDecl = TREE_OPERAND(TREE_OPERAND(exp, 0), 0); const FunctionType *VAEndTy = @@ -3679,7 +3669,8 @@ } Value *Arg = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0); - const Type *FTy = llvm_va_end_fn->getType()->getElementType(); + const Type *FTy = + cast(llvm_va_end_fn->getType())->getElementType(); Arg = CastToType(Instruction::BitCast, Arg, cast(FTy)->getParamType(0)); @@ -3688,7 +3679,7 @@ } bool TreeToLLVM::EmitBuiltinVACopy(tree exp) { - static Function *llvm_va_copy_fn = 0; + static Constant *llvm_va_copy_fn = 0; if (!llvm_va_copy_fn) { tree FnDecl = TREE_OPERAND(TREE_OPERAND(exp, 0), 0); const FunctionType *FnTy = @@ -3718,7 +3709,8 @@ Emit(Arg2T, Arg2); } - const Type *FTy = llvm_va_copy_fn->getType()->getElementType(); + const Type *FTy = + cast(llvm_va_copy_fn->getType())->getElementType(); const Type *PtrList = cast(FTy)->getParamType(0); Arg1 = CastToType(Instruction::BitCast, Arg1, PtrList); Arg2 = CastToType(Instruction::BitCast, Arg2, PtrList); Index: llvm-debug.cpp =================================================================== --- llvm-debug.cpp (revision 122081) +++ llvm-debug.cpp (working copy) @@ -274,8 +274,10 @@ // Lazily construct llvm.dbg.func.start. if (!FuncStartFn) { - FuncStartFn = M->getOrInsertFunction("llvm.dbg.func.start", - Type::VoidTy, SR.getEmptyStructPtrType(), NULL); + FuncStartFn = + cast(M->getOrInsertFunction("llvm.dbg.func.start", + Type::VoidTy, + SR.getEmptyStructPtrType(), NULL)); } // Call llvm.dbg.func.start. @@ -298,8 +300,9 @@ // Lazily construct llvm.dbg.region.start function. if (!RegionStartFn) { const PointerType *EmpPtr = SR.getEmptyStructPtrType(); - RegionStartFn = M->getOrInsertFunction("llvm.dbg.region.start", - Type::VoidTy, EmpPtr, NULL); + RegionStartFn = + cast(M->getOrInsertFunction("llvm.dbg.region.start", + Type::VoidTy, EmpPtr, NULL)); } // Call llvm.dbg.func.start. @@ -312,8 +315,9 @@ // Lazily construct llvm.dbg.region.end function. if (!RegionEndFn) { const PointerType *EmpPtr = SR.getEmptyStructPtrType(); - RegionEndFn = M->getOrInsertFunction("llvm.dbg.region.end", - Type::VoidTy, EmpPtr, NULL); + RegionEndFn = + cast(M->getOrInsertFunction("llvm.dbg.region.end", Type::VoidTy, + EmpPtr, NULL)); } // Provide an region stop point. @@ -331,8 +335,9 @@ // Lazily construct llvm.dbg.declare function. const PointerType *EmpPtr = SR.getEmptyStructPtrType(); if (!DeclareFn) { - DeclareFn = M->getOrInsertFunction("llvm.dbg.declare", - Type::VoidTy, EmpPtr, EmpPtr, NULL); + DeclareFn = + cast(M->getOrInsertFunction("llvm.dbg.declare", + Type::VoidTy, EmpPtr, EmpPtr,NULL)); } // Get type information. @@ -378,9 +383,11 @@ // Lazily construct llvm.dbg.stoppoint function. if (!StopPointFn) { - StopPointFn = M->getOrInsertFunction("llvm.dbg.stoppoint", - Type::VoidTy, Type::Int32Ty, Type::Int32Ty, - SR.getEmptyStructPtrType(), NULL); + StopPointFn = + cast(M->getOrInsertFunction("llvm.dbg.stoppoint", + Type::VoidTy, Type::Int32Ty, + Type::Int32Ty, + SR.getEmptyStructPtrType(), NULL)); } // Invoke llvm.dbg.stoppoint