Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 2924152

Browse files
committed
ScheduleTreeElemMapping: take isl::ctx in constructor
The constructor of ScheduleTreeElemMapping accepts as argument an unordered_map between isl objects, so the context may be extracted from any object unless the map is empty. While the constructor is throwing if the map is empty, the isl::ctx instance is passed to the superclass constructor, that is before it has an opportunity to throw. Request the context as a separate constructor argument instead of hoping on a non-empty map and potentially triggering an undefined behavior by dereferencing the one-past-end iterator.
1 parent 6a4ffc9 commit 2924152

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tc/core/polyhedral/schedule_tree.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ std::unique_ptr<ScheduleTree> ScheduleTree::makeMappingUnsafe(
286286
<< "some id is used more than once in the mapping";
287287
auto ctx = mappedIds[0].get_ctx();
288288
auto res =
289-
std::unique_ptr<ScheduleTree>(new ScheduleTreeElemMapping(mapping));
289+
std::unique_ptr<ScheduleTree>(new ScheduleTreeElemMapping(ctx, mapping));
290290
res->appendChildren(std::move(children));
291291
return res;
292292
}

tc/core/polyhedral/schedule_tree_elem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ struct ScheduleTreeElemMapping : public ScheduleTree {
120120
ScheduleTreeElemMapping() = delete;
121121
ScheduleTreeElemMapping(const ScheduleTreeElemMapping& eb)
122122
: ScheduleTree(eb), mapping(eb.mapping), filter_(eb.filter_) {}
123-
ScheduleTreeElemMapping(const Mapping& mapping)
124-
: ScheduleTree(mapping.cbegin()->second.get_ctx(), {}, NodeType),
123+
ScheduleTreeElemMapping(isl::ctx ctx, const Mapping& mapping)
124+
: ScheduleTree(ctx, {}, NodeType),
125125
mapping(mapping),
126126
filter_(isl::union_set()) {
127127
TC_CHECK_GT(mapping.size(), 0u) << "empty mapping filter";

0 commit comments

Comments
 (0)