Use CreateCall instead of CreateCall2 because llvm3.7 has removed CreateCall2.

Submitted by Yan Wang on Nov. 18, 2015, 10:47 a.m.

Details

Message ID 1447843635-30210-1-git-send-email-yan.wang@linux.intel.com
State New
Headers show
Series "Use CreateCall instead of CreateCall2 because llvm3.7 has removed CreateCall2." ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Yan Wang Nov. 18, 2015, 10:47 a.m.
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
---
 backend/src/llvm/llvm_profiling.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Patch hide | download patch | download mbox

diff --git a/backend/src/llvm/llvm_profiling.cpp b/backend/src/llvm/llvm_profiling.cpp
index 8c9157c..e548305 100644
--- a/backend/src/llvm/llvm_profiling.cpp
+++ b/backend/src/llvm/llvm_profiling.cpp
@@ -177,12 +177,21 @@  namespace gbe
       builder->SetInsertPoint(instI);
       /* Add the timestamp store function call. */
       // __gen_ocl_store_timestamp(int nth, int type);
+#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+      builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
+              "__gen_ocl_calc_timestamp", Type::getVoidTy(module->getContext()),
+              IntegerType::getInt32Ty(module->getContext()),
+              IntegerType::getInt32Ty(module->getContext()),
+              NULL)),
+          /* the args */ {ConstantInt::get(intTy, pointNum++), ConstantInt::get(intTy, profilingType)});
+#else
       builder->CreateCall2(cast<llvm::Function>(module->getOrInsertFunction(
               "__gen_ocl_calc_timestamp", Type::getVoidTy(module->getContext()),
               IntegerType::getInt32Ty(module->getContext()),
               IntegerType::getInt32Ty(module->getContext()),
               NULL)),
           /* the args */ ConstantInt::get(intTy, pointNum++), ConstantInt::get(intTy, profilingType));
+#endif
     }
     /* We insert one store_profiling at the end of the last block to hold the place. */
     llvm::Function::iterator BE = F.end();
@@ -190,12 +199,21 @@  namespace gbe
     BasicBlock::iterator retInst = BE->end();
     retInst--;
     builder->SetInsertPoint(retInst);
+#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
+    builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
+            "__gen_ocl_store_profiling", Type::getVoidTy(module->getContext()),
+            ptrTy,
+            IntegerType::getInt32Ty(module->getContext()),
+            NULL)),
+        /* the args */{profilingBuf, ConstantInt::get(intTy, profilingType)});
+#else
     builder->CreateCall2(cast<llvm::Function>(module->getOrInsertFunction(
             "__gen_ocl_store_profiling", Type::getVoidTy(module->getContext()),
             ptrTy,
             IntegerType::getInt32Ty(module->getContext()),
             NULL)),
         /* the args */profilingBuf, ConstantInt::get(intTy, profilingType));
+#endif
 
     delete builder;
     return changed;

Comments

> -----Original Message-----

> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf Of

> Yan Wang

> Sent: Wednesday, November 18, 2015 6:47 PM

> To: beignet@lists.freedesktop.org

> Cc: Yan Wang <yan.wang@linux.intel.com>

> Subject: [Beignet] [PATCH] Use CreateCall instead of CreateCall2 because

> llvm3.7 has removed CreateCall2.

> 

> Signed-off-by: Yan Wang <yan.wang@linux.intel.com>

> ---

>  backend/src/llvm/llvm_profiling.cpp | 18 ++++++++++++++++++

>  1 file changed, 18 insertions(+)

> 

> diff --git a/backend/src/llvm/llvm_profiling.cpp

> b/backend/src/llvm/llvm_profiling.cpp

> index 8c9157c..e548305 100644

> --- a/backend/src/llvm/llvm_profiling.cpp

> +++ b/backend/src/llvm/llvm_profiling.cpp

> @@ -177,12 +177,21 @@ namespace gbe

>        builder->SetInsertPoint(instI);

>        /* Add the timestamp store function call. */

>        // __gen_ocl_store_timestamp(int nth, int type);

> +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7

> +      builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(

> +              "__gen_ocl_calc_timestamp", Type::getVoidTy(module-

> >getContext()),

> +              IntegerType::getInt32Ty(module->getContext()),

> +              IntegerType::getInt32Ty(module->getContext()),

> +              NULL)),

> +          /* the args */ {ConstantInt::get(intTy, pointNum++),

> ConstantInt::get(intTy, profilingType)});


I think you can directly remove CreateCall2 verion.
llvm supports CreateCall((Value *Callee, ArrayRef<Value *> Args = None, const Twine &Name = "") through all llvm version.
So, let's keep code simple.

Thanks!
Ruiling

> +#else

>        builder->CreateCall2(cast<llvm::Function>(module-

> >getOrInsertFunction(

>                "__gen_ocl_calc_timestamp", Type::getVoidTy(module-

> >getContext()),

>                IntegerType::getInt32Ty(module->getContext()),

>                IntegerType::getInt32Ty(module->getContext()),

>                NULL)),

>            /* the args */ ConstantInt::get(intTy, pointNum++),

> ConstantInt::get(intTy, profilingType));

> +#endif

>      }

>      /* We insert one store_profiling at the end of the last block to hold the

> place. */

>      llvm::Function::iterator BE = F.end();

> @@ -190,12 +199,21 @@ namespace gbe

>      BasicBlock::iterator retInst = BE->end();

>      retInst--;

>      builder->SetInsertPoint(retInst);

> +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7

> +    builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(

> +            "__gen_ocl_store_profiling", Type::getVoidTy(module-

> >getContext()),

> +            ptrTy,

> +            IntegerType::getInt32Ty(module->getContext()),

> +            NULL)),

> +        /* the args */{profilingBuf, ConstantInt::get(intTy, profilingType)});

> +#else

>      builder->CreateCall2(cast<llvm::Function>(module->getOrInsertFunction(

>              "__gen_ocl_store_profiling", Type::getVoidTy(module->getContext()),

>              ptrTy,

>              IntegerType::getInt32Ty(module->getContext()),

>              NULL)),

>          /* the args */profilingBuf, ConstantInt::get(intTy, profilingType));

> +#endif

> 

>      delete builder;

>      return changed;

> --

> 1.9.3

> 

> _______________________________________________

> Beignet mailing list

> Beignet@lists.freedesktop.org

> http://lists.freedesktop.org/mailman/listinfo/beignet
>
>
>> -----Original Message-----
>> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf
>> Of
>> Yan Wang
>> Sent: Wednesday, November 18, 2015 6:47 PM
>> To: beignet@lists.freedesktop.org
>> Cc: Yan Wang <yan.wang@linux.intel.com>
>> Subject: [Beignet] [PATCH] Use CreateCall instead of CreateCall2
>> because
>> llvm3.7 has removed CreateCall2.
>>
>> Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
>> ---
>>  backend/src/llvm/llvm_profiling.cpp | 18 ++++++++++++++++++
>>  1 file changed, 18 insertions(+)
>>
>> diff --git a/backend/src/llvm/llvm_profiling.cpp
>> b/backend/src/llvm/llvm_profiling.cpp
>> index 8c9157c..e548305 100644
>> --- a/backend/src/llvm/llvm_profiling.cpp
>> +++ b/backend/src/llvm/llvm_profiling.cpp
>> @@ -177,12 +177,21 @@ namespace gbe
>>        builder->SetInsertPoint(instI);
>>        /* Add the timestamp store function call. */
>>        // __gen_ocl_store_timestamp(int nth, int type);
>> +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
>> +
>> builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
>> +              "__gen_ocl_calc_timestamp", Type::getVoidTy(module-
>> >getContext()),
>> +              IntegerType::getInt32Ty(module->getContext()),
>> +              IntegerType::getInt32Ty(module->getContext()),
>> +              NULL)),
>> +          /* the args */ {ConstantInt::get(intTy, pointNum++),
>> ConstantInt::get(intTy, profilingType)});
>
> I think you can directly remove CreateCall2 verion.
> llvm supports CreateCall((Value *Callee, ArrayRef<Value *> Args = None,
> const Twine &Name = "") through all llvm version.
> So, let's keep code simple.
>
> Thanks!
> Ruiling

Sure. I will submit it again after modified it.
Thanks.

Yan Wang

>
>> +#else
>>        builder->CreateCall2(cast<llvm::Function>(module-
>> >getOrInsertFunction(
>>                "__gen_ocl_calc_timestamp", Type::getVoidTy(module-
>> >getContext()),
>>                IntegerType::getInt32Ty(module->getContext()),
>>                IntegerType::getInt32Ty(module->getContext()),
>>                NULL)),
>>            /* the args */ ConstantInt::get(intTy, pointNum++),
>> ConstantInt::get(intTy, profilingType));
>> +#endif
>>      }
>>      /* We insert one store_profiling at the end of the last block to
>> hold the
>> place. */
>>      llvm::Function::iterator BE = F.end();
>> @@ -190,12 +199,21 @@ namespace gbe
>>      BasicBlock::iterator retInst = BE->end();
>>      retInst--;
>>      builder->SetInsertPoint(retInst);
>> +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
>> +
>> builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
>> +            "__gen_ocl_store_profiling", Type::getVoidTy(module-
>> >getContext()),
>> +            ptrTy,
>> +            IntegerType::getInt32Ty(module->getContext()),
>> +            NULL)),
>> +        /* the args */{profilingBuf, ConstantInt::get(intTy,
>> profilingType)});
>> +#else
>>      builder->CreateCall2(cast<llvm::Function>(module->getOrInsertFunction(
>>              "__gen_ocl_store_profiling",
>> Type::getVoidTy(module->getContext()),
>>              ptrTy,
>>              IntegerType::getInt32Ty(module->getContext()),
>>              NULL)),
>>          /* the args */profilingBuf, ConstantInt::get(intTy,
>> profilingType));
>> +#endif
>>
>>      delete builder;
>>      return changed;
>> --
>> 1.9.3
>>
>> _______________________________________________
>> Beignet mailing list
>> Beignet@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/beignet
>