[llvm] r333443 - IRBuilder: Add overload for intrinsics without args

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue May 29 11:06:50 PDT 2018


Author: arsenm
Date: Tue May 29 11:06:50 2018
New Revision: 333443

URL: http://llvm.org/viewvc/llvm-project?rev=333443&view=rev
Log:
IRBuilder: Add overload for intrinsics without args

Modified:
    llvm/trunk/include/llvm/IR/IRBuilder.h
    llvm/trunk/lib/IR/IRBuilder.cpp
    llvm/trunk/unittests/IR/IRBuilderTest.cpp

Modified: llvm/trunk/include/llvm/IR/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/IRBuilder.h?rev=333443&r1=333442&r2=333443&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/IRBuilder.h Tue May 29 11:06:50 2018
@@ -632,6 +632,11 @@ public:
                                   Value *LHS, Value *RHS,
                                   const Twine &Name = "");
 
+  /// Create a call to intrinsic \p ID with no operands.
+  CallInst *CreateIntrinsic(Intrinsic::ID ID,
+                            Instruction *FMFSource = nullptr,
+                            const Twine &Name = "");
+
   /// Create a call to intrinsic \p ID with 1 or more operands assuming the
   /// intrinsic and all operands have the same type. If \p FMFSource is
   /// provided, copy fast-math-flags from that instruction to the intrinsic.

Modified: llvm/trunk/lib/IR/IRBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/IRBuilder.cpp?rev=333443&r1=333442&r2=333443&view=diff
==============================================================================
--- llvm/trunk/lib/IR/IRBuilder.cpp (original)
+++ llvm/trunk/lib/IR/IRBuilder.cpp Tue May 29 11:06:50 2018
@@ -669,6 +669,14 @@ CallInst *IRBuilderBase::CreateBinaryInt
 }
 
 CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID,
+                                         Instruction *FMFSource,
+                                         const Twine &Name) {
+  Module *M = BB->getModule();
+  Function *Fn = Intrinsic::getDeclaration(M, ID);
+  return createCallHelper(Fn, {}, this, Name);
+}
+
+CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID,
                                          ArrayRef<Value *> Args,
                                          Instruction *FMFSource,
                                          const Twine &Name) {

Modified: llvm/trunk/unittests/IR/IRBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/IRBuilderTest.cpp?rev=333443&r1=333442&r2=333443&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/IRBuilderTest.cpp (original)
+++ llvm/trunk/unittests/IR/IRBuilderTest.cpp Tue May 29 11:06:50 2018
@@ -63,6 +63,10 @@ TEST_F(IRBuilderTest, Intrinsics) {
   Call = Builder.CreateMaxNum(V, V);
   II = cast<IntrinsicInst>(Call);
   EXPECT_EQ(II->getIntrinsicID(), Intrinsic::maxnum);
+
+  Call = Builder.CreateIntrinsic(Intrinsic::readcyclecounter);
+  II = cast<IntrinsicInst>(Call);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::readcyclecounter);
 }
 
 TEST_F(IRBuilderTest, Lifetime) {




More information about the llvm-commits mailing list