This is an archive of the discontinued LLVM Phabricator instance.

[Polly] Allow arbitrary function calls for debugging purposes.
ClosedPublic

Authored by Meinersbur on Apr 17 2018, 10:41 AM.

Details

Summary

Add the switch -polly-debug-func to define the name of a debug function. This function is ignored for any validity check.

Its purpose is to allow to observe a value after transformation by a SCoP, and to follow which statements are executed in which order. For instance, consider the following code:

static void dbg_printf(int sum, int i) {
  fprintf(stderr, "The value of sum is %d, i=%d\n", sum, i);
  fflush(stderr);
}

void func(int n) {
  int sum = 0;
  for (int i = 0; i < 16; i+=1) {
    sum += i;
    dbg_printf(sum, i);
  }
}

Executing this after Polly's codegen reveals the new execution order and the assumed values at that point of execution.

Diff Detail

Repository
rL LLVM

Event Timeline

Meinersbur created this revision.Apr 17 2018, 10:41 AM

Use a ScopStmt's instruction list.

grosser accepted this revision.Apr 18 2018, 5:58 AM

LGTM.

include/polly/Support/ScopHelper.h
466 ↗(On Diff #142813)

Two white spaces?

This revision is now accepted and ready to land.Apr 18 2018, 5:58 AM
This revision was automatically updated to reflect the committed changes.
Meinersbur marked an inline comment as done.