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

xionghu.luo at intel.com xionghu.luo at intel.com
Mon Mar 16 22:25:49 PDT 2015


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



More information about the Beignet mailing list