summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-11-19 20:06:13 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-11-19 20:06:13 +0000
commitc0981da47d5696fe36474fcf86b4ce03ae3ff818 (patch)
treef42add1021b9f2ac6a69ac7cf6c4499962739a45 /lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime
parent344a3780b2e33f6ca763666c380202b18aab72a3 (diff)
Diffstat (limited to 'lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime')
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp8
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h2
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp38
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h6
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp31
5 files changed, 31 insertions, 54 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
index 08a752eaa888..c990c733d24c 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
@@ -14,7 +14,7 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
-#include "llvm/Support/TargetRegistry.h"
+#include "llvm/MC/TargetRegistry.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
@@ -40,9 +40,8 @@ using namespace lldb_renderscript;
// perform a fixup pass that removes those assumptions right before the module
// is sent to be generated by the llvm backend.
-namespace {
-bool registerRSDefaultTargetOpts(clang::TargetOptions &proto,
- const llvm::Triple::ArchType &arch) {
+static bool registerRSDefaultTargetOpts(clang::TargetOptions &proto,
+ const llvm::Triple::ArchType &arch) {
switch (arch) {
case llvm::Triple::ArchType::x86:
proto.Triple = "i686--linux-android";
@@ -75,7 +74,6 @@ bool registerRSDefaultTargetOpts(clang::TargetOptions &proto,
}
return true;
}
-} // end anonymous namespace
bool RenderScriptRuntimeModulePass::runOnModule(llvm::Module &module) {
bool changed_module = false;
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h
index 52da677128e2..e0b4f388dcc5 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h
@@ -10,7 +10,7 @@
#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTEXPRESSIONOPTS_H
#include "llvm/IR/Module.h"
-#include "llvm/Support/TargetRegistry.h"
+#include "llvm/MC/TargetRegistry.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index 10ff5aa72b52..d6de65809c18 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -17,7 +17,6 @@
#include "lldb/DataFormatters/DumpValueObjectOptions.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -967,11 +966,6 @@ void RenderScriptRuntime::Terminate() {
PluginManager::UnregisterPlugin(CreateInstance);
}
-lldb_private::ConstString RenderScriptRuntime::GetPluginNameStatic() {
- static ConstString plugin_name("renderscript");
- return plugin_name;
-}
-
RenderScriptRuntime::ModuleKind
RenderScriptRuntime::GetModuleKind(const lldb::ModuleSP &module_sp) {
if (module_sp) {
@@ -1014,13 +1008,6 @@ void RenderScriptRuntime::ModulesDidLoad(const ModuleList &module_list) {
}
}
-// PluginInterface protocol
-lldb_private::ConstString RenderScriptRuntime::GetPluginName() {
- return GetPluginNameStatic();
-}
-
-uint32_t RenderScriptRuntime::GetPluginVersion() { return 1; }
-
bool RenderScriptRuntime::GetDynamicTypeAndAddress(
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name, Address &address,
@@ -2660,7 +2647,7 @@ bool RenderScriptRuntime::SaveAllocation(Stream &strm, const uint32_t alloc_id,
FileSpec file_spec(path);
FileSystem::Instance().Resolve(file_spec);
auto file = FileSystem::Instance().Open(
- file_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate |
+ file_spec, File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate |
File::eOpenOptionTruncate);
if (!file) {
@@ -4568,10 +4555,8 @@ public:
eLanguageTypeExtRenderScript));
const char *id_cstr = command.GetArgumentAtIndex(0);
- bool success = false;
- const uint32_t id =
- StringConvert::ToUInt32(id_cstr, UINT32_MAX, 0, &success);
- if (!success) {
+ uint32_t id;
+ if (!llvm::to_integer(id_cstr, id)) {
result.AppendErrorWithFormat("invalid allocation id argument '%s'",
id_cstr);
return false;
@@ -4585,8 +4570,9 @@ public:
if (outfile_spec) {
// Open output file
std::string path = outfile_spec.GetPath();
- auto file = FileSystem::Instance().Open(
- outfile_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate);
+ auto file = FileSystem::Instance().Open(outfile_spec,
+ File::eOpenOptionWriteOnly |
+ File::eOpenOptionCanCreate);
if (file) {
output_stream_storage =
std::make_unique<StreamFile>(std::move(file.get()));
@@ -4714,10 +4700,8 @@ public:
eLanguageTypeExtRenderScript));
const char *id_cstr = command.GetArgumentAtIndex(0);
- bool success = false;
- const uint32_t id =
- StringConvert::ToUInt32(id_cstr, UINT32_MAX, 0, &success);
- if (!success) {
+ uint32_t id;
+ if (!llvm::to_integer(id_cstr, id)) {
result.AppendErrorWithFormat("invalid allocation id argument '%s'",
id_cstr);
return false;
@@ -4763,10 +4747,8 @@ public:
eLanguageTypeExtRenderScript));
const char *id_cstr = command.GetArgumentAtIndex(0);
- bool success = false;
- const uint32_t id =
- StringConvert::ToUInt32(id_cstr, UINT32_MAX, 0, &success);
- if (!success) {
+ uint32_t id;
+ if (!llvm::to_integer(id_cstr, id)) {
result.AppendErrorWithFormat("invalid allocation id argument '%s'",
id_cstr);
return false;
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
index 2785c3b08125..4ddf996dedb2 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -318,7 +318,7 @@ public:
static lldb::CommandObjectSP
GetCommandObject(CommandInterpreter &interpreter);
- static lldb_private::ConstString GetPluginNameStatic();
+ static llvm::StringRef GetPluginNameStatic() { return "renderscript"; }
static char ID;
@@ -410,9 +410,7 @@ public:
bool GetOverrideExprOptions(clang::TargetOptions &prototype);
// PluginInterface protocol
- lldb_private::ConstString GetPluginName() override;
-
- uint32_t GetPluginVersion() override;
+ llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
static bool GetKernelCoordinate(lldb_renderscript::RSCoordinate &coord,
Thread *thread_ptr);
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
index f51190e0c82c..f3b7c9dd3edc 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
@@ -22,9 +22,8 @@
#include "lldb/Utility/Log.h"
using namespace lldb_private;
-namespace {
-bool isRSAPICall(llvm::Module &module, llvm::CallInst *call_inst) {
+static bool isRSAPICall(llvm::Module &module, llvm::CallInst *call_inst) {
// TODO get the list of renderscript modules from lldb and check if
// this llvm::Module calls into any of them.
(void)module;
@@ -38,7 +37,8 @@ bool isRSAPICall(llvm::Module &module, llvm::CallInst *call_inst) {
return true;
}
-bool isRSLargeReturnCall(llvm::Module &module, llvm::CallInst *call_inst) {
+static bool isRSLargeReturnCall(llvm::Module &module,
+ llvm::CallInst *call_inst) {
// i686 and x86_64 returns for large vectors in the RenderScript API are not
// handled as normal register pairs, but as a hidden sret type. This is not
// reflected in the debug info or mangled symbol name, and the android ABI
@@ -58,7 +58,7 @@ bool isRSLargeReturnCall(llvm::Module &module, llvm::CallInst *call_inst) {
->getPrimitiveSizeInBits() > 128;
}
-bool isRSAllocationPtrTy(const llvm::Type *type) {
+static bool isRSAllocationPtrTy(const llvm::Type *type) {
if (!type->isPointerTy())
return false;
auto ptr_type = type->getPointerElementType();
@@ -67,7 +67,8 @@ bool isRSAllocationPtrTy(const llvm::Type *type) {
ptr_type->getStructName().startswith("struct.rs_allocation");
}
-bool isRSAllocationTyCallSite(llvm::Module &module, llvm::CallInst *call_inst) {
+static bool isRSAllocationTyCallSite(llvm::Module &module,
+ llvm::CallInst *call_inst) {
(void)module;
if (!call_inst->hasByValArgument())
return false;
@@ -77,7 +78,7 @@ bool isRSAllocationTyCallSite(llvm::Module &module, llvm::CallInst *call_inst) {
return false;
}
-llvm::FunctionType *cloneToStructRetFnTy(llvm::CallInst *call_inst) {
+static llvm::FunctionType *cloneToStructRetFnTy(llvm::CallInst *call_inst) {
// on x86 StructReturn functions return a pointer to the return value, rather
// than the return value itself
// [ref](http://www.agner.org/optimize/calling_conventions.pdf section 6). We
@@ -122,9 +123,9 @@ llvm::FunctionType *cloneToStructRetFnTy(llvm::CallInst *call_inst) {
orig->isVarArg());
}
-bool findRSCallSites(llvm::Module &module,
- std::set<llvm::CallInst *> &rs_callsites,
- bool (*predicate)(llvm::Module &, llvm::CallInst *)) {
+static bool
+findRSCallSites(llvm::Module &module, std::set<llvm::CallInst *> &rs_callsites,
+ bool (*predicate)(llvm::Module &, llvm::CallInst *)) {
bool found = false;
for (auto &func : module.getFunctionList())
@@ -143,7 +144,7 @@ bool findRSCallSites(llvm::Module &module,
return found;
}
-bool fixupX86StructRetCalls(llvm::Module &module) {
+static bool fixupX86StructRetCalls(llvm::Module &module) {
bool changed = false;
// changing a basic block while iterating over it seems to have some
// undefined behaviour going on so we find all RS callsites first, then fix
@@ -207,7 +208,7 @@ bool fixupX86StructRetCalls(llvm::Module &module) {
return changed;
}
-bool fixupRSAllocationStructByValCalls(llvm::Module &module) {
+static bool fixupRSAllocationStructByValCalls(llvm::Module &module) {
// On x86_64, calls to functions in the RS runtime that take an
// `rs_allocation` type argument are actually handled as by-ref params by
// bcc, but appear to be passed by value by lldb (the callsite all use
@@ -237,12 +238,11 @@ bool fixupRSAllocationStructByValCalls(llvm::Module &module) {
llvm::AttributeList call_attribs = call_inst->getAttributes();
// iterate over the argument attributes
- for (unsigned I = call_attribs.index_begin(); I != call_attribs.index_end();
- I++) {
+ for (unsigned I : call_attribs.indexes()) {
// if this argument is passed by val
- if (call_attribs.hasAttribute(I, llvm::Attribute::ByVal)) {
+ if (call_attribs.hasAttributeAtIndex(I, llvm::Attribute::ByVal)) {
// strip away the byval attribute
- call_inst->removeAttribute(I, llvm::Attribute::ByVal);
+ call_inst->removeAttributeAtIndex(I, llvm::Attribute::ByVal);
changed = true;
}
}
@@ -260,7 +260,6 @@ bool fixupRSAllocationStructByValCalls(llvm::Module &module) {
}
return changed;
}
-} // end anonymous namespace
namespace lldb_private {
namespace lldb_renderscript {