Skip to content

Commit

Permalink
Update some language usage. (KhronosGroup#3611)
Browse files Browse the repository at this point in the history
This CL updates various bits of language in line with the guidelines
provided by Android
(https://source.android.com/setup/contribute/respectful-code)
  • Loading branch information
dj2 authored Jul 29, 2020
1 parent 863b8e3 commit a1ea15c
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 131 deletions.
6 changes: 3 additions & 3 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ v2020.4 2020-07-22

v2020.3 2020-05-27
- General
- Prevent Effcee install his things when build spirv-tools with testing enabled (#3256)
- Prevent Effcee from installing things when building spirv-tools with testing enabled (#3256)
- Update acorn version (#3294)
- If SPIRV-Headers is in our tree, include it as subproject (#3299)
- allow cross compiling for Windows Store, UWP, etc. (#3330)
Expand Down Expand Up @@ -111,7 +111,7 @@ v2020.1 2020-02-03
- Optimizer
- Change default version for CreatInstBindlessCheckPass to 2 (#3096, #3119)
- Better handling of OpLine on merge blocks (#3130)
- Use dummy switch instead of dummy loop in MergeReturn pass. (#3151)
- Use placeholder switch instead of placeholder loop in MergeReturn pass. (#3151)
- Handle TimeAMD in AmdExtensionToKhrPass. (#3168)
- Validator
- Fix structured exit validation (#3141)
Expand Down Expand Up @@ -438,7 +438,7 @@ v2018.6 2018-11-07
- Optimizer
- Unrolling loops marked for unrolling in the legalization passes.
- Improved the compile time of loop unrolling.
- Changee merge-return to create a dummy loop around the function.
- Changee merge-return to create a placeholder loop around the function.
- Small improvement to merge-blocks to allow it to merge more often.
- Enforce an upper bound for the ids, and add option to set it.
- #1966: Report error if there are unreachable block before running merge return
Expand Down
2 changes: 1 addition & 1 deletion source/fuzz/transformation_outline_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class TransformationOutlineFunction : public Transformation {
// - Unless the type required for the new function is already known,
// |message_.new_function_type_id| is used as the type id for a new function
// type, and the new function uses this type.
// - The new function starts with a dummy block with id
// - The new function starts with a placeholder block with id
// |message_.new_function_first_block|, which jumps straight to a successor
// block, to avoid violating rules on what the first block in a function may
// look like.
Expand Down
2 changes: 1 addition & 1 deletion source/name_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ std::string FriendlyNameMapper::NameForEnumOperand(spv_operand_type_t type,
if (SPV_SUCCESS == grammar_.lookupOperand(type, word, &desc)) {
return desc->name;
} else {
// Invalid input. Just give something sane.
// Invalid input. Just give something.
return std::string("StorageClass") + to_string(word);
}
}
Expand Down
54 changes: 28 additions & 26 deletions source/opt/dominator_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

// Calculates the dominator or postdominator tree for a given function.
// 1 - Compute the successors and predecessors for each BasicBlock. We add a
// dummy node for the start node or for postdominators the exit. This node will
// point to all entry or all exit nodes.
// placeholder node for the start node or for postdominators the exit. This node
// will point to all entry or all exit nodes.
// 2 - Using the CFA::DepthFirstTraversal get a depth first postordered list of
// all BasicBlocks. Using the successors (or for postdominator, predecessors)
// calculated in step 1 to traverse the tree.
Expand Down Expand Up @@ -107,8 +107,9 @@ class BasicBlockSuccessorHelper {

public:
// For compliance with the dominance tree computation, entry nodes are
// connected to a single dummy node.
BasicBlockSuccessorHelper(Function& func, const BasicBlock* dummy_start_node,
// connected to a single placeholder node.
BasicBlockSuccessorHelper(Function& func,
const BasicBlock* placeholder_start_node,
bool post);

// CFA::CalculateDominators requires std::vector<BasicBlock*>.
Expand Down Expand Up @@ -139,23 +140,24 @@ class BasicBlockSuccessorHelper {
// Build the successors and predecessors map for each basic blocks |f|.
// If |invert_graph_| is true, all edges are reversed (successors becomes
// predecessors and vice versa).
// For convenience, the start of the graph is |dummy_start_node|.
// For convenience, the start of the graph is |placeholder_start_node|.
// The dominator tree construction requires a unique entry node, which cannot
// be guaranteed for the postdominator graph. The |dummy_start_node| BB is
// here to gather all entry nodes.
void CreateSuccessorMap(Function& f, const BasicBlock* dummy_start_node);
// be guaranteed for the postdominator graph. The |placeholder_start_node| BB
// is here to gather all entry nodes.
void CreateSuccessorMap(Function& f,
const BasicBlock* placeholder_start_node);
};

template <typename BBType>
BasicBlockSuccessorHelper<BBType>::BasicBlockSuccessorHelper(
Function& func, const BasicBlock* dummy_start_node, bool invert)
Function& func, const BasicBlock* placeholder_start_node, bool invert)
: invert_graph_(invert) {
CreateSuccessorMap(func, dummy_start_node);
CreateSuccessorMap(func, placeholder_start_node);
}

template <typename BBType>
void BasicBlockSuccessorHelper<BBType>::CreateSuccessorMap(
Function& f, const BasicBlock* dummy_start_node) {
Function& f, const BasicBlock* placeholder_start_node) {
std::map<uint32_t, BasicBlock*> id_to_BB_map;
auto GetSuccessorBasicBlock = [&f, &id_to_BB_map](uint32_t successor_id) {
BasicBlock*& Succ = id_to_BB_map[successor_id];
Expand All @@ -173,11 +175,10 @@ void BasicBlockSuccessorHelper<BBType>::CreateSuccessorMap(
if (invert_graph_) {
// For the post dominator tree, we see the inverted graph.
// successors_ in the inverted graph are the predecessors in the CFG.
// The tree construction requires 1 entry point, so we add a dummy node
// that is connected to all function exiting basic blocks.
// An exiting basic block is a block with an OpKill, OpUnreachable,
// OpReturn, OpReturnValue, or OpTerminateInvocation as terminator
// instruction.
// The tree construction requires 1 entry point, so we add a placeholder
// node that is connected to all function exiting basic blocks. An exiting
// basic block is a block with an OpKill, OpUnreachable, OpReturn,
// OpReturnValue, or OpTerminateInvocation as terminator instruction.
for (BasicBlock& bb : f) {
if (bb.hasSuccessor()) {
BasicBlockListTy& pred_list = predecessors_[&bb];
Expand All @@ -192,14 +193,15 @@ void BasicBlockSuccessorHelper<BBType>::CreateSuccessorMap(
pred_list.push_back(succ);
});
} else {
successors_[dummy_start_node].push_back(&bb);
predecessors_[&bb].push_back(const_cast<BasicBlock*>(dummy_start_node));
successors_[placeholder_start_node].push_back(&bb);
predecessors_[&bb].push_back(
const_cast<BasicBlock*>(placeholder_start_node));
}
}
} else {
successors_[dummy_start_node].push_back(f.entry().get());
successors_[placeholder_start_node].push_back(f.entry().get());
predecessors_[f.entry().get()].push_back(
const_cast<BasicBlock*>(dummy_start_node));
const_cast<BasicBlock*>(placeholder_start_node));
for (BasicBlock& bb : f) {
BasicBlockListTy& succ_list = successors_[&bb];

Expand Down Expand Up @@ -288,7 +290,7 @@ DominatorTreeNode* DominatorTree::GetOrInsertNode(BasicBlock* bb) {
}

void DominatorTree::GetDominatorEdges(
const Function* f, const BasicBlock* dummy_start_node,
const Function* f, const BasicBlock* placeholder_start_node,
std::vector<std::pair<BasicBlock*, BasicBlock*>>* edges) {
// Each time the depth first traversal calls the postorder callback
// std::function we push that node into the postorder vector to create our
Expand All @@ -302,7 +304,7 @@ void DominatorTree::GetDominatorEdges(
// BB are derived from F, so we need to const cast it at some point
// no modification is made on F.
BasicBlockSuccessorHelper<BasicBlock> helper{
*const_cast<Function*>(f), dummy_start_node, postdominator_};
*const_cast<Function*>(f), placeholder_start_node, postdominator_};

// The successor function tells DepthFirstTraversal how to move to successive
// nodes by providing an interface to get a list of successor nodes from any
Expand All @@ -316,7 +318,7 @@ void DominatorTree::GetDominatorEdges(
// If we're building a post dominator tree we traverse the tree in reverse
// using the predecessor function in place of the successor function and vice
// versa.
DepthFirstSearchPostOrder(dummy_start_node, successor_functor,
DepthFirstSearchPostOrder(placeholder_start_node, successor_functor,
postorder_function);
*edges = CFA<BasicBlock>::CalculateDominators(postorder, predecessor_functor);
}
Expand All @@ -329,12 +331,12 @@ void DominatorTree::InitializeTree(const CFG& cfg, const Function* f) {
return;
}

const BasicBlock* dummy_start_node =
const BasicBlock* placeholder_start_node =
postdominator_ ? cfg.pseudo_exit_block() : cfg.pseudo_entry_block();

// Get the immediate dominator for each node.
std::vector<std::pair<BasicBlock*, BasicBlock*>> edges;
GetDominatorEdges(f, dummy_start_node, &edges);
GetDominatorEdges(f, placeholder_start_node, &edges);

// Transform the vector<pair> into the tree structure which we can use to
// efficiently query dominance.
Expand Down Expand Up @@ -380,7 +382,7 @@ void DominatorTree::DumpTreeAsDot(std::ostream& out_stream) const {
}

// Print the arrow from the parent to this node. Entry nodes will not have
// parents so draw them as children from the dummy node.
// parents so draw them as children from the placeholder node.
if (node->parent_) {
out_stream << node->parent_->bb_->id() << " -> " << node->bb_->id()
<< ";\n";
Expand Down
8 changes: 4 additions & 4 deletions source/opt/ir_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,15 +601,15 @@ class InstructionBuilder {
return preserved_analyses_ & analysis;
}

// Updates the def/use manager if the user requested it. If he did not request
// an update, this function does nothing.
// Updates the def/use manager if the user requested it. If an update was not
// requested, this function does nothing.
inline void UpdateDefUseMgr(Instruction* insn) {
if (IsAnalysisUpdateRequested(IRContext::kAnalysisDefUse))
GetContext()->get_def_use_mgr()->AnalyzeInstDefUse(insn);
}

// Updates the instruction to block analysis if the user requested it. If he
// did not request an update, this function does nothing.
// Updates the instruction to block analysis if the user requested it. If
// an update was not requested, this function does nothing.
inline void UpdateInstrToBlockMapping(Instruction* insn) {
if (IsAnalysisUpdateRequested(IRContext::kAnalysisInstrToBlockMapping) &&
parent_)
Expand Down
8 changes: 4 additions & 4 deletions source/opt/loop_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ void Loop::ComputeLoopStructuredOrder(
}

LoopDescriptor::LoopDescriptor(IRContext* context, const Function* f)
: loops_(), dummy_top_loop_(nullptr) {
: loops_(), placeholder_top_loop_(nullptr) {
PopulateList(context, f);
}

Expand Down Expand Up @@ -592,7 +592,7 @@ void LoopDescriptor::PopulateList(IRContext* context, const Function* f) {
}
}
for (Loop* loop : loops_) {
if (!loop->HasParent()) dummy_top_loop_.nested_loops_.push_back(loop);
if (!loop->HasParent()) placeholder_top_loop_.nested_loops_.push_back(loop);
}
}

Expand Down Expand Up @@ -986,7 +986,7 @@ void LoopDescriptor::ClearLoops() {
// Adds a new loop nest to the descriptor set.
Loop* LoopDescriptor::AddLoopNest(std::unique_ptr<Loop> new_loop) {
Loop* loop = new_loop.release();
if (!loop->HasParent()) dummy_top_loop_.nested_loops_.push_back(loop);
if (!loop->HasParent()) placeholder_top_loop_.nested_loops_.push_back(loop);
// Iterate from inner to outer most loop, adding basic block to loop mapping
// as we go.
for (Loop& current_loop :
Expand All @@ -1000,7 +1000,7 @@ Loop* LoopDescriptor::AddLoopNest(std::unique_ptr<Loop> new_loop) {
}

void LoopDescriptor::RemoveLoop(Loop* loop) {
Loop* parent = loop->GetParent() ? loop->GetParent() : &dummy_top_loop_;
Loop* parent = loop->GetParent() ? loop->GetParent() : &placeholder_top_loop_;
parent->nested_loops_.erase(std::find(parent->nested_loops_.begin(),
parent->nested_loops_.end(), loop));
std::for_each(
Expand Down
36 changes: 19 additions & 17 deletions source/opt/loop_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ class Loop {
// the iterators.
bool loop_is_marked_for_removal_;

// This is only to allow LoopDescriptor::dummy_top_loop_ to add top level
// loops as child.
// This is only to allow LoopDescriptor::placeholder_top_loop_ to add top
// level loops as child.
friend class LoopDescriptor;
friend class LoopUtils;
};
Expand All @@ -430,14 +430,14 @@ class LoopDescriptor {
// Disable copy constructor, to avoid double-free on destruction.
LoopDescriptor(const LoopDescriptor&) = delete;
// Move constructor.
LoopDescriptor(LoopDescriptor&& other) : dummy_top_loop_(nullptr) {
LoopDescriptor(LoopDescriptor&& other) : placeholder_top_loop_(nullptr) {
// We need to take ownership of the Loop objects in the other
// LoopDescriptor, to avoid double-free.
loops_ = std::move(other.loops_);
other.loops_.clear();
basic_block_to_loop_ = std::move(other.basic_block_to_loop_);
other.basic_block_to_loop_.clear();
dummy_top_loop_ = std::move(other.dummy_top_loop_);
placeholder_top_loop_ = std::move(other.placeholder_top_loop_);
}

// Destructor
Expand Down Expand Up @@ -470,25 +470,27 @@ class LoopDescriptor {

// Iterators for post order depth first traversal of the loops.
// Inner most loops will be visited first.
inline iterator begin() { return iterator::begin(&dummy_top_loop_); }
inline iterator end() { return iterator::end(&dummy_top_loop_); }
inline iterator begin() { return iterator::begin(&placeholder_top_loop_); }
inline iterator end() { return iterator::end(&placeholder_top_loop_); }
inline const_iterator begin() const { return cbegin(); }
inline const_iterator end() const { return cend(); }
inline const_iterator cbegin() const {
return const_iterator::begin(&dummy_top_loop_);
return const_iterator::begin(&placeholder_top_loop_);
}
inline const_iterator cend() const {
return const_iterator::end(&dummy_top_loop_);
return const_iterator::end(&placeholder_top_loop_);
}

// Iterators for pre-order depth first traversal of the loops.
// Inner most loops will be visited first.
inline pre_iterator pre_begin() { return ++pre_iterator(&dummy_top_loop_); }
inline pre_iterator pre_begin() {
return ++pre_iterator(&placeholder_top_loop_);
}
inline pre_iterator pre_end() { return pre_iterator(); }
inline const_pre_iterator pre_begin() const { return pre_cbegin(); }
inline const_pre_iterator pre_end() const { return pre_cend(); }
inline const_pre_iterator pre_cbegin() const {
return ++const_pre_iterator(&dummy_top_loop_);
return ++const_pre_iterator(&placeholder_top_loop_);
}
inline const_pre_iterator pre_cend() const { return const_pre_iterator(); }

Expand Down Expand Up @@ -524,14 +526,14 @@ class LoopDescriptor {
void RemoveLoop(Loop* loop);

void SetAsTopLoop(Loop* loop) {
assert(std::find(dummy_top_loop_.begin(), dummy_top_loop_.end(), loop) ==
dummy_top_loop_.end() &&
assert(std::find(placeholder_top_loop_.begin(), placeholder_top_loop_.end(),
loop) == placeholder_top_loop_.end() &&
"already registered");
dummy_top_loop_.nested_loops_.push_back(loop);
placeholder_top_loop_.nested_loops_.push_back(loop);
}

Loop* GetDummyRootLoop() { return &dummy_top_loop_; }
const Loop* GetDummyRootLoop() const { return &dummy_top_loop_; }
Loop* GetPlaceholderRootLoop() { return &placeholder_top_loop_; }
const Loop* GetPlaceholderRootLoop() const { return &placeholder_top_loop_; }

private:
// TODO(dneto): This should be a vector of unique_ptr. But VisualStudio 2013
Expand All @@ -558,8 +560,8 @@ class LoopDescriptor {
// objects.
LoopContainerType loops_;

// Dummy root: this "loop" is only there to help iterators creation.
Loop dummy_top_loop_;
// Placeholder root: this "loop" is only there to help iterators creation.
Loop placeholder_top_loop_;

std::unordered_map<uint32_t, Loop*> basic_block_to_loop_;

Expand Down
10 changes: 5 additions & 5 deletions source/opt/loop_unroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,21 +674,21 @@ void LoopUnrollerUtilsImpl::CopyBody(Loop* loop, bool eliminate_conditions) {
std::vector<Instruction*> inductions;
loop->GetInductionVariables(inductions);
for (size_t index = 0; index < inductions.size(); ++index) {
Instruction* master_copy = inductions[index];
Instruction* primary_copy = inductions[index];

assert(master_copy->result_id() != 0);
assert(primary_copy->result_id() != 0);
Instruction* induction_clone =
state_.ids_to_new_inst[state_.new_inst[master_copy->result_id()]];
state_.ids_to_new_inst[state_.new_inst[primary_copy->result_id()]];

state_.new_phis_.push_back(induction_clone);
assert(induction_clone->result_id() != 0);

if (!state_.previous_phis_.empty()) {
state_.new_inst[master_copy->result_id()] = GetPhiDefID(
state_.new_inst[primary_copy->result_id()] = GetPhiDefID(
state_.previous_phis_[index], state_.previous_latch_block_->id());
} else {
// Do not replace the first phi block ids.
state_.new_inst[master_copy->result_id()] = master_copy->result_id();
state_.new_inst[primary_copy->result_id()] = primary_copy->result_id();
}
}

Expand Down
6 changes: 3 additions & 3 deletions source/opt/loop_unswitch_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,9 @@ bool LoopUnswitchPass::ProcessFunction(Function* f) {
bool loop_changed = true;
while (loop_changed) {
loop_changed = false;
for (Loop& loop :
make_range(++TreeDFIterator<Loop>(loop_descriptor.GetDummyRootLoop()),
TreeDFIterator<Loop>())) {
for (Loop& loop : make_range(
++TreeDFIterator<Loop>(loop_descriptor.GetPlaceholderRootLoop()),
TreeDFIterator<Loop>())) {
if (processed_loop.count(&loop)) continue;
processed_loop.insert(&loop);

Expand Down
Loading

0 comments on commit a1ea15c

Please sign in to comment.