summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordan sinclair <dj2@everburning.com>2018-07-12 11:13:32 -0400
committerGitHub <noreply@github.com>2018-07-12 11:13:32 -0400
commit6803e42bb502711cc21274dbba5a5279ba4d4652 (patch)
treecab470800cee7e3402b455f332d65ba7029a5581
parenta5e4a532170bbbdd2a8c57d827e71a0b111fdcf3 (diff)
Cleanup some pass code to get context directly. (#1714)
Instead of going through the instruction we can access the context() directly from the pass. Issue #1703
-rw-r--r--source/opt/inline_pass.cpp5
-rw-r--r--source/opt/private_to_local_pass.cpp2
-rw-r--r--source/opt/reduce_load_size.cpp6
3 files changed, 6 insertions, 7 deletions
diff --git a/source/opt/inline_pass.cpp b/source/opt/inline_pass.cpp
index 960baf67..a044fd37 100644
--- a/source/opt/inline_pass.cpp
+++ b/source/opt/inline_pass.cpp
@@ -134,7 +134,7 @@ void InlinePass::CloneAndMapLocals(
auto callee_var_itr = callee_block_itr->begin();
while (callee_var_itr->opcode() == SpvOp::SpvOpVariable) {
std::unique_ptr<opt::Instruction> var_inst(
- callee_var_itr->Clone(callee_var_itr->context()));
+ callee_var_itr->Clone(context()));
uint32_t newId = TakeNextId();
get_decoration_mgr()->CloneDecorations(callee_var_itr->result_id(), newId);
var_inst->SetResultId(newId);
@@ -185,8 +185,7 @@ void InlinePass::CloneSameBlockOps(
if (mapItr2 != (*preCallSB).end()) {
// Clone pre-call same-block ops, map result id.
const opt::Instruction* inInst = mapItr2->second;
- std::unique_ptr<opt::Instruction> sb_inst(
- inInst->Clone(inInst->context()));
+ std::unique_ptr<opt::Instruction> sb_inst(inInst->Clone(context()));
CloneSameBlockOps(&sb_inst, postCallSB, preCallSB, block_ptr);
const uint32_t rid = sb_inst->result_id();
const uint32_t nid = this->TakeNextId();
diff --git a/source/opt/private_to_local_pass.cpp b/source/opt/private_to_local_pass.cpp
index 20450892..f8b35c6e 100644
--- a/source/opt/private_to_local_pass.cpp
+++ b/source/opt/private_to_local_pass.cpp
@@ -170,7 +170,7 @@ void PrivateToLocalPass::UpdateUse(opt::Instruction* inst) {
}
void PrivateToLocalPass::UpdateUses(uint32_t id) {
std::vector<opt::Instruction*> uses;
- this->context()->get_def_use_mgr()->ForEachUser(
+ context()->get_def_use_mgr()->ForEachUser(
id, [&uses](opt::Instruction* use) { uses.push_back(use); });
for (opt::Instruction* use : uses) {
diff --git a/source/opt/reduce_load_size.cpp b/source/opt/reduce_load_size.cpp
index 346342d5..8c48cf50 100644
--- a/source/opt/reduce_load_size.cpp
+++ b/source/opt/reduce_load_size.cpp
@@ -48,9 +48,9 @@ Pass::Status ReduceLoadSize::Process() {
bool ReduceLoadSize::ReplaceExtract(opt::Instruction* inst) {
assert(inst->opcode() == SpvOpCompositeExtract &&
"Wrong opcode. Should be OpCompositeExtract.");
- analysis::DefUseManager* def_use_mgr = inst->context()->get_def_use_mgr();
- analysis::TypeManager* type_mgr = inst->context()->get_type_mgr();
- analysis::ConstantManager* const_mgr = inst->context()->get_constant_mgr();
+ analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr();
+ analysis::TypeManager* type_mgr = context()->get_type_mgr();
+ analysis::ConstantManager* const_mgr = context()->get_constant_mgr();
uint32_t composite_id =
inst->GetSingleWordInOperand(kExtractCompositeIdInIdx);