Merge "Fix x86_64 issue with a missing "." in structure names."
diff --git a/include/bcc/Renderscript/RSUtils.h b/include/bcc/Renderscript/RSUtils.h
index d8e3684..fa1fb1a 100644
--- a/include/bcc/Renderscript/RSUtils.h
+++ b/include/bcc/Renderscript/RSUtils.h
@@ -61,6 +61,12 @@
return RS_TYPE_NONE;
}
+// Returns true if the input type is one of our RenderScript object types
+// (allocation, element, sampler, script, type) and false if it is not.
+static inline bool isRsObjectType(const llvm::Type *T) {
+ return getRsDataTypeForType(T) != RS_TYPE_NONE;
+}
+
} // end namespace
#endif // BCC_RS_UTILS_H
diff --git a/lib/Renderscript/RSX86CallConvPass.cpp b/lib/Renderscript/RSX86CallConvPass.cpp
index 301f55c..5a0c990 100644
--- a/lib/Renderscript/RSX86CallConvPass.cpp
+++ b/lib/Renderscript/RSX86CallConvPass.cpp
@@ -15,6 +15,7 @@
*/
#include "bcc/Assert.h"
+#include "bcc/Renderscript/RSUtils.h"
#include "bcc/Support/Log.h"
#include <algorithm>
@@ -40,14 +41,6 @@
*/
class RSX86_64CallConvPass: public llvm::ModulePass {
private:
- std::vector<std::string> Structs = {
- "struct.rs_element.",
- "struct.rs_type.",
- "struct.rs_allocation.",
- "struct.rs_sampler.",
- "struct.rs_script.",
- };
-
bool IsRSFunctionOfInterest(llvm::Function &F) {
// Only Renderscript functions that are not defined locally be considered
if (!F.empty()) // defined locally
@@ -63,18 +56,6 @@
return true;
}
- // Structure names can have a different integral suffix (.0, .1, etc) for
- // multiple definitions with the same name. So, we only match the prefix of
- // the structure name.
- bool IsRSStructOfInterest(llvm::Type *StructTy) {
- llvm::StringRef StructName = StructTy->getStructName();
- for (auto &S: Structs) {
- if (StructName.startswith(S))
- return true;
- }
- return false;
- }
-
// Test if this argument needs to be converted to pass-by-value.
bool IsDerefNeeded(llvm::Function *F, llvm::Argument &Arg) {
unsigned ArgNo = Arg.getArgNo();
@@ -91,7 +72,7 @@
// Dereference needed only for certain RS struct objects.
llvm::Type *StructTy = ArgTy->getPointerElementType();
- if (!IsRSStructOfInterest(StructTy))
+ if (!isRsObjectType(StructTy))
return false;
// TODO Find a better way to encode exceptions