MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / PostModificationCleanup

Method PostModificationCleanup

source/opt/loop_descriptor.cpp:944–977  ·  view source on GitHub ↗

Add and remove loops which have been marked for addition and removal to maintain the state of the loop descriptor class.

Source from the content-addressed store, hash-verified

942// Add and remove loops which have been marked for addition and removal to
943// maintain the state of the loop descriptor class.
944void LoopDescriptor::PostModificationCleanup() {
945 LoopContainerType loops_to_remove_;
946 for (Loop* loop : loops_) {
947 if (loop->IsMarkedForRemoval()) {
948 loops_to_remove_.push_back(loop);
949 if (loop->HasParent()) {
950 loop->GetParent()->RemoveChildLoop(loop);
951 }
952 }
953 }
954
955 for (Loop* loop : loops_to_remove_) {
956 loops_.erase(std::find(loops_.begin(), loops_.end(), loop));
957 delete loop;
958 }
959
960 for (auto& pair : loops_to_add_) {
961 Loop* parent = pair.first;
962 std::unique_ptr<Loop> loop = std::move(pair.second);
963
964 if (parent) {
965 loop->SetParent(nullptr);
966 parent->AddNestedLoop(loop.get());
967
968 for (uint32_t block_id : loop->GetBlocks()) {
969 parent->AddBasicBlock(block_id);
970 }
971 }
972
973 loops_.emplace_back(loop.release());
974 }
975
976 loops_to_add_.clear();
977}
978
979void LoopDescriptor::ClearLoops() {
980 for (Loop* loop : loops_) {

Callers 2

FinalizeMethod · 0.80
ProcessMethod · 0.80

Calls 15

findFunction · 0.85
IsMarkedForRemovalMethod · 0.80
HasParentMethod · 0.80
RemoveChildLoopMethod · 0.80
AddNestedLoopMethod · 0.80
getMethod · 0.80
emplace_backMethod · 0.80
push_backMethod · 0.45
GetParentMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected