t.p.northover created this revision. t.p.northover added a reviewer: kpn. Herald added a subscriber: mcrosier. Herald added projects: clang, LLVM.
This just updates an IRBuilder interface to take Functions instead of Values so the type can be derived, and fixes some callsites in Clang to call the updated API. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D71723 Files: clang/lib/CodeGen/CGBuiltin.cpp llvm/include/llvm/IR/IRBuilder.h Index: llvm/include/llvm/IR/IRBuilder.h =================================================================== --- llvm/include/llvm/IR/IRBuilder.h +++ llvm/include/llvm/IR/IRBuilder.h @@ -2421,18 +2421,16 @@ Args, OpBundles, Name, FPMathTag); } - // Deprecated [opaque pointer types] CallInst *CreateConstrainedFPCall( - Value *Callee, ArrayRef<Value *> Args, const Twine &Name = "", + Function *Callee, ArrayRef<Value *> Args, const Twine &Name = "", Optional<fp::RoundingMode> Rounding = None, Optional<fp::ExceptionBehavior> Except = None) { llvm::SmallVector<Value *, 6> UseArgs; for (auto *OneArg : Args) UseArgs.push_back(OneArg); - Function *F = cast<Function>(Callee); bool HasRoundingMD = false; - switch (F->getIntrinsicID()) { + switch (Callee->getIntrinsicID()) { default: break; #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \ @@ -2445,9 +2443,7 @@ UseArgs.push_back(getConstrainedFPRounding(Rounding)); UseArgs.push_back(getConstrainedFPExcept(Except)); - CallInst *C = CreateCall( - cast<FunctionType>(Callee->getType()->getPointerElementType()), Callee, - UseArgs, Name); + CallInst *C = CreateCall(Callee, UseArgs, Name); setConstrainedFPCallAttr(C); return C; } Index: clang/lib/CodeGen/CGBuiltin.cpp =================================================================== --- clang/lib/CodeGen/CGBuiltin.cpp +++ clang/lib/CodeGen/CGBuiltin.cpp @@ -368,10 +368,10 @@ llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); if (CGF.Builder.getIsFPConstrained()) { - Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); return CGF.Builder.CreateConstrainedFPCall(F, { Src0 }); } else { - Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); return CGF.Builder.CreateCall(F, Src0); } } @@ -385,10 +385,10 @@ llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); if (CGF.Builder.getIsFPConstrained()) { - Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1 }); } else { - Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); return CGF.Builder.CreateCall(F, { Src0, Src1 }); } } @@ -403,10 +403,10 @@ llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); if (CGF.Builder.getIsFPConstrained()) { - Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1, Src2 }); } else { - Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); } }
Index: llvm/include/llvm/IR/IRBuilder.h =================================================================== --- llvm/include/llvm/IR/IRBuilder.h +++ llvm/include/llvm/IR/IRBuilder.h @@ -2421,18 +2421,16 @@ Args, OpBundles, Name, FPMathTag); } - // Deprecated [opaque pointer types] CallInst *CreateConstrainedFPCall( - Value *Callee, ArrayRef<Value *> Args, const Twine &Name = "", + Function *Callee, ArrayRef<Value *> Args, const Twine &Name = "", Optional<fp::RoundingMode> Rounding = None, Optional<fp::ExceptionBehavior> Except = None) { llvm::SmallVector<Value *, 6> UseArgs; for (auto *OneArg : Args) UseArgs.push_back(OneArg); - Function *F = cast<Function>(Callee); bool HasRoundingMD = false; - switch (F->getIntrinsicID()) { + switch (Callee->getIntrinsicID()) { default: break; #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \ @@ -2445,9 +2443,7 @@ UseArgs.push_back(getConstrainedFPRounding(Rounding)); UseArgs.push_back(getConstrainedFPExcept(Except)); - CallInst *C = CreateCall( - cast<FunctionType>(Callee->getType()->getPointerElementType()), Callee, - UseArgs, Name); + CallInst *C = CreateCall(Callee, UseArgs, Name); setConstrainedFPCallAttr(C); return C; } Index: clang/lib/CodeGen/CGBuiltin.cpp =================================================================== --- clang/lib/CodeGen/CGBuiltin.cpp +++ clang/lib/CodeGen/CGBuiltin.cpp @@ -368,10 +368,10 @@ llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); if (CGF.Builder.getIsFPConstrained()) { - Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); return CGF.Builder.CreateConstrainedFPCall(F, { Src0 }); } else { - Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); return CGF.Builder.CreateCall(F, Src0); } } @@ -385,10 +385,10 @@ llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); if (CGF.Builder.getIsFPConstrained()) { - Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1 }); } else { - Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); return CGF.Builder.CreateCall(F, { Src0, Src1 }); } } @@ -403,10 +403,10 @@ llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); if (CGF.Builder.getIsFPConstrained()) { - Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1, Src2 }); } else { - Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); } }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits