diff options
| author | Michael Kruse <llvm@meinersbur.de> | 2018-04-25 19:43:49 +0000 |
|---|---|---|
| committer | Michael Kruse <llvm@meinersbur.de> | 2018-04-25 19:43:49 +0000 |
| commit | e819fffee3b948c7699ce3948b35624bf6cc63ae (patch) | |
| tree | 79845af0f5f0e535085dac7244a7010bfa29813a /polly/include | |
| parent | 152060275fd43196bc34648d1a264e6478555860 (diff) | |
| download | bcm5719-llvm-e819fffee3b948c7699ce3948b35624bf6cc63ae.tar.gz bcm5719-llvm-e819fffee3b948c7699ce3948b35624bf6cc63ae.zip | |
[CodeGen] Print executed statement instances at runtime.
Add the options -polly-codegen-trace-stmts and
-polly-codegen-trace-scalars. When enabled, adds a call to the
beginning of every generated statement that prints the executed
statement instance. With -polly-codegen-trace-scalars, it also prints
the value of all scalars that are used in the statement, and PHIs
defined in the beginning of the statement.
Differential Revision: https://reviews.llvm.org/D45743
llvm-svn: 330864
Diffstat (limited to 'polly/include')
| -rw-r--r-- | polly/include/polly/CodeGen/BlockGenerators.h | 19 | ||||
| -rw-r--r-- | polly/include/polly/CodeGen/RuntimeDebugBuilder.h | 24 |
2 files changed, 42 insertions, 1 deletions
diff --git a/polly/include/polly/CodeGen/BlockGenerators.h b/polly/include/polly/CodeGen/BlockGenerators.h index 35f23c46932..23ebf058120 100644 --- a/polly/include/polly/CodeGen/BlockGenerators.h +++ b/polly/include/polly/CodeGen/BlockGenerators.h @@ -329,6 +329,25 @@ protected: ValueMapT &BBMap, __isl_keep isl_id_to_ast_expr *NewAccesses); + /// When statement tracing is enable, build the print instructions for + /// printing the current statement instance and its input scalars. + /// + /// The printed output looks like: + /// + /// Stmt1(0) + /// + /// If printing of scalars is enabled, it also appends the value of each + /// scalar to the line: + /// + /// Stmt1(0) %i=1 %sum=5 + /// + /// @param Stmt The statement we generate code for. + /// @param LTS A mapping from loops virtual canonical induction + /// variable to their new values. + /// @param BBMap A mapping from old values to their new values in this block. + void generateBeginStmtTrace(ScopStmt &Stmt, LoopToScevMapT <S, + ValueMapT &BBMap); + /// Generate instructions that compute whether one instance of @p Set is /// executed. /// diff --git a/polly/include/polly/CodeGen/RuntimeDebugBuilder.h b/polly/include/polly/CodeGen/RuntimeDebugBuilder.h index 334030fd3c3..a0820f9b628 100644 --- a/polly/include/polly/CodeGen/RuntimeDebugBuilder.h +++ b/polly/include/polly/CodeGen/RuntimeDebugBuilder.h @@ -30,6 +30,28 @@ namespace polly { /// run time. struct RuntimeDebugBuilder { + /// Generate a constant string into the builder's llvm::Module which can be + /// passed to createGPUPrinter() or createGPUPrinter(). + /// + /// @param Builder The builder used to emit the printer calls. + /// @param Str The string to be printed. + + /// @return A global containing @p Str. + static llvm::Value *getPrintableString(PollyIRBuilder &Builder, + llvm::StringRef Str) { + // TODO: Get rid of magic number 4. It it NVPTX's constant address space and + // works on X86 (CPU) only because its backend ignores the address space. + return Builder.CreateGlobalStringPtr(Str, "", 4); + } + + /// Return whether an llvm::Value of the type @p Ty is printable for + /// debugging. + /// + /// That is, whether such a value can be passed to createGPUPrinter() or + /// createGPUPrinter() to be dumped as runtime. If false is returned, those + /// functions will fail. + static bool isPrintable(llvm::Type *Ty); + /// Print a set of LLVM-IR Values or StringRefs via printf /// /// This function emits a call to printf that will print the given arguments. @@ -78,7 +100,7 @@ private: static void createPrinter(PollyIRBuilder &Builder, bool UseGPU, std::vector<llvm::Value *> &Values, llvm::StringRef String, Args... args) { - Values.push_back(Builder.CreateGlobalStringPtr(String, "", 4)); + Values.push_back(getPrintableString(Builder, String)); createPrinter(Builder, UseGPU, Values, args...); } |

