[llvm] 85cb560 - ConstrainedFP: use API compatible with opaque pointers.

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 13:50:57 PST 2019


Author: Tim Northover
Date: 2019-12-19T21:50:47Z
New Revision: 85cb560b8a421d950ccea593b4ee0569249dc136

URL: https://github.com/llvm/llvm-project/commit/85cb560b8a421d950ccea593b4ee0569249dc136
DIFF: https://github.com/llvm/llvm-project/commit/85cb560b8a421d950ccea593b4ee0569249dc136.diff

LOG: ConstrainedFP: use API compatible with opaque pointers.

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.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGBuiltin.cpp
    llvm/include/llvm/IR/IRBuilder.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 37aca09bff5b..3b35fc23a1b9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -368,10 +368,10 @@ static Value *emitUnaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
   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 @@ static Value *emitBinaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
   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 @@ static Value *emitTernaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
   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 });
   }
 }

diff  --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 5d5f12d2c7c6..1abdf2242b58 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -2421,18 +2421,16 @@ class IRBuilder : public IRBuilderBase, public Inserter {
         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 @@ class IRBuilder : public IRBuilderBase, public Inserter {
       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;
   }


        


More information about the llvm-commits mailing list