Skip to content

Commit 682f0c3

Browse files
committed
Remove cover() coverage tracking
1 parent 10fd978 commit 682f0c3

File tree

8 files changed

+2
-555
lines changed

8 files changed

+2
-555
lines changed

Makefile

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ ENABLE_VERIFIC_HIER_TREE := 1
2121
ENABLE_VERIFIC_YOSYSHQ_EXTENSIONS := 0
2222
ENABLE_VERIFIC_EDIF := 0
2323
ENABLE_VERIFIC_LIBERTY := 0
24-
ENABLE_COVER := 1
2524
ENABLE_LIBYOSYS := 0
2625
ENABLE_ZLIB := 1
2726
ENABLE_HELP_SOURCE := 0
@@ -248,9 +247,6 @@ ifneq ($(SANITIZER),)
248247
$(info [Clang Sanitizer] $(SANITIZER))
249248
CXXFLAGS += -g -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=$(SANITIZER)
250249
LINKFLAGS += -g -fsanitize=$(SANITIZER)
251-
ifneq ($(findstring address,$(SANITIZER)),)
252-
ENABLE_COVER := 0
253-
endif
254250
ifneq ($(findstring memory,$(SANITIZER)),)
255251
CXXFLAGS += -fPIE -fsanitize-memory-track-origins
256252
LINKFLAGS += -fPIE -fsanitize-memory-track-origins
@@ -544,10 +540,6 @@ LIBS_VERIFIC += -Wl,--whole-archive $(patsubst %,$(VERIFIC_DIR)/%/*-linux.a,$(VE
544540
endif
545541
endif
546542

547-
ifeq ($(ENABLE_COVER),1)
548-
CXXFLAGS += -DYOSYS_ENABLE_COVER
549-
endif
550-
551543
ifeq ($(ENABLE_CCACHE),1)
552544
CXX := ccache $(CXX)
553545
else
@@ -725,7 +717,6 @@ OBJS += passes/hierarchy/hierarchy.o
725717
OBJS += passes/cmds/select.o
726718
OBJS += passes/cmds/show.o
727719
OBJS += passes/cmds/stat.o
728-
OBJS += passes/cmds/cover.o
729720
OBJS += passes/cmds/design.o
730721
OBJS += passes/cmds/plugin.o
731722

kernel/driver.cc

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -764,33 +764,6 @@ int main(int argc, char **argv)
764764
}
765765
}
766766

767-
#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
768-
if (getenv("YOSYS_COVER_DIR") || getenv("YOSYS_COVER_FILE"))
769-
{
770-
string filename;
771-
FILE *f;
772-
773-
if (getenv("YOSYS_COVER_DIR")) {
774-
filename = stringf("%s/yosys_cover_%d_XXXXXX.txt", getenv("YOSYS_COVER_DIR"), getpid());
775-
filename = make_temp_file(filename);
776-
} else {
777-
filename = getenv("YOSYS_COVER_FILE");
778-
}
779-
780-
f = fopen(filename.c_str(), "a+");
781-
782-
if (f == NULL)
783-
log_error("Can't create coverage file `%s'.\n", filename);
784-
785-
log("<writing coverage file \"%s\">\n", filename);
786-
787-
for (auto &it : get_coverage_data())
788-
fprintf(f, "%-60s %10d %s\n", it.second.first.c_str(), it.second.second, it.first.c_str());
789-
790-
fclose(f);
791-
}
792-
#endif
793-
794767
log_check_expected();
795768

796769
yosys_atexit();

kernel/log.cc

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -681,55 +681,4 @@ void log_check_expected()
681681
check_err("prefixed error", pattern, item);
682682
}
683683

684-
// ---------------------------------------------------
685-
// This is the magic behind the code coverage counters
686-
// ---------------------------------------------------
687-
#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
688-
689-
dict<std::string, std::pair<std::string, int>> extra_coverage_data;
690-
691-
void cover_extra(std::string parent, std::string id, bool increment) {
692-
if (extra_coverage_data.count(id) == 0) {
693-
for (CoverData *p = __start_yosys_cover_list; p != __stop_yosys_cover_list; p++)
694-
if (p->id == parent)
695-
extra_coverage_data[id].first = stringf("%s:%d:%s", p->file, p->line, p->func);
696-
log_assert(extra_coverage_data.count(id));
697-
}
698-
if (increment)
699-
extra_coverage_data[id].second++;
700-
}
701-
702-
dict<std::string, std::pair<std::string, int>> get_coverage_data()
703-
{
704-
dict<std::string, std::pair<std::string, int>> coverage_data;
705-
706-
for (auto &it : pass_register) {
707-
std::string key = stringf("passes.%s", it.first);
708-
coverage_data[key].first = stringf("%s:%d:%s", __FILE__, __LINE__, __FUNCTION__);
709-
coverage_data[key].second += it.second->call_counter;
710-
}
711-
712-
for (auto &it : extra_coverage_data) {
713-
if (coverage_data.count(it.first))
714-
log_warning("found duplicate coverage id \"%s\".\n", it.first);
715-
coverage_data[it.first].first = it.second.first;
716-
coverage_data[it.first].second += it.second.second;
717-
}
718-
719-
for (CoverData *p = __start_yosys_cover_list; p != __stop_yosys_cover_list; p++) {
720-
if (coverage_data.count(p->id))
721-
log_warning("found duplicate coverage id \"%s\".\n", p->id);
722-
coverage_data[p->id].first = stringf("%s:%d:%s", p->file, p->line, p->func);
723-
coverage_data[p->id].second += p->counter;
724-
}
725-
726-
for (auto &it : coverage_data)
727-
if (!it.second.first.compare(0, strlen(YOSYS_SRC "/"), YOSYS_SRC "/"))
728-
it.second.first = it.second.first.substr(strlen(YOSYS_SRC "/"));
729-
730-
return coverage_data;
731-
}
732-
733-
#endif
734-
735684
YOSYS_NAMESPACE_END

kernel/log.h

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -290,53 +290,6 @@ void log_abort_internal(const char *file, int line);
290290
#define log_ping() YOSYS_NAMESPACE_PREFIX log("-- %s:%d %s --\n", __FILE__, __LINE__, __PRETTY_FUNCTION__)
291291

292292

293-
// ---------------------------------------------------
294-
// This is the magic behind the code coverage counters
295-
// ---------------------------------------------------
296-
297-
#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
298-
299-
#define cover(_id) do { \
300-
static CoverData __d __attribute__((section("yosys_cover_list"), aligned(1), used)) = { __FILE__, __FUNCTION__, _id, __LINE__, 0 }; \
301-
__d.counter++; \
302-
} while (0)
303-
304-
struct CoverData {
305-
const char *file, *func, *id;
306-
int line, counter;
307-
} YS_ATTRIBUTE(packed);
308-
309-
// this two symbols are created by the linker for the "yosys_cover_list" ELF section
310-
extern "C" struct CoverData __start_yosys_cover_list[];
311-
extern "C" struct CoverData __stop_yosys_cover_list[];
312-
313-
extern dict<std::string, std::pair<std::string, int>> extra_coverage_data;
314-
315-
void cover_extra(std::string parent, std::string id, bool increment = true);
316-
dict<std::string, std::pair<std::string, int>> get_coverage_data();
317-
318-
#define cover_list(_id, ...) do { cover(_id); \
319-
std::string r = cover_list_worker(_id, __VA_ARGS__); \
320-
log_assert(r.empty()); \
321-
} while (0)
322-
323-
static inline std::string cover_list_worker(std::string, std::string last) {
324-
return last;
325-
}
326-
327-
template<typename... T>
328-
std::string cover_list_worker(std::string prefix, std::string first, T... rest) {
329-
std::string selected = cover_list_worker(prefix, rest...);
330-
cover_extra(prefix, prefix + "." + first, first == selected);
331-
return first == selected ? "" : selected;
332-
}
333-
334-
#else
335-
# define cover(...) do { } while (0)
336-
# define cover_list(...) do { } while (0)
337-
#endif
338-
339-
340293
// ------------------------------------------------------------
341294
// everything below this line are utilities for troubleshooting
342295
// ------------------------------------------------------------

0 commit comments

Comments
 (0)