[Beignet] [patch v2] strip PointerCast for call instructions before use.

Zhigang Gong zhigang.gong at linux.intel.com
Tue Mar 17 01:58:30 PDT 2015


LGTM, pushed, thanks.

On Tue, Mar 17, 2015 at 01:25:49PM +0800, xionghu.luo at intel.com wrote:
> From: Luo Xionghu <xionghu.luo at intel.com>
> 
> the callInst may contains bitcast instruction if the function's is
> different with the decleration. strip the bitcast instruction to get
> the real name.
> 
> v2: remove printf message.
> Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
> ---
>  backend/src/llvm/llvm_bitcode_link.cpp | 3 +--
>  backend/src/llvm/llvm_gen_backend.cpp  | 4 ++--
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/backend/src/llvm/llvm_bitcode_link.cpp b/backend/src/llvm/llvm_bitcode_link.cpp
> index 3bf9613..ebf4386 100644
> --- a/backend/src/llvm/llvm_bitcode_link.cpp
> +++ b/backend/src/llvm/llvm_bitcode_link.cpp
> @@ -96,8 +96,7 @@ namespace gbe
>              call->getCalledFunction()->getIntrinsicID() != 0)
>            continue;
>  
> -        Value *Callee = call->getCalledValue();
> -        const std::string fnName = Callee->getName();
> +        std::string fnName = call->getCalledValue()->stripPointerCasts()->getName();
>  
>          if (!MFS.insert(fnName).second) {
>            continue;
> diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
> index 773300b..bf03a13 100644
> --- a/backend/src/llvm/llvm_gen_backend.cpp
> +++ b/backend/src/llvm/llvm_gen_backend.cpp
> @@ -2628,7 +2628,7 @@ namespace gbe
>        }
>      }
>      // Get the name of the called function and handle it
> -    const std::string fnName = Callee->getName();
> +    const std::string fnName = Callee->stripPointerCasts()->getName();
>      auto genIntrinsicID = intrinsicMap.find(fnName);
>      switch (genIntrinsicID) {
>        case GEN_OCL_GET_GROUP_ID0:
> @@ -3018,7 +3018,7 @@ namespace gbe
>        } else {
>          // Get the name of the called function and handle it
>          Value *Callee = I.getCalledValue();
> -        const std::string fnName = Callee->getName();
> +        const std::string fnName = Callee->stripPointerCasts()->getName();
>          auto genIntrinsicID = intrinsicMap.find(fnName);
>  
>          // Get the function arguments
> -- 
> 1.9.1
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list