From 94ee7a3de83c2471a09be83bc860ce3763ce73a2 Mon Sep 17 00:00:00 2001 From: Ruiling Song Date: Fri, 11 Apr 2014 14:48:18 +0800 Subject: [PATCH] GBE: Enable CFG printer. export OCL_OUTPUT_CFG=1 or export OCL_OUTPUT_CFG_ONLY=1 then it will output .dot file of CFG for the compiled kernels. The CFG_ONLY means pure cfg without llvm IR. You can use xdot to view .dot file. Signed-off-by: Ruiling Song Reviewed-by: Zhigang Gong --- backend/src/llvm/llvm_to_gen.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/llvm/llvm_to_gen.cpp b/backend/src/llvm/llvm_to_gen.cpp index 50b84ce..37a5b2b 100644 --- a/backend/src/llvm/llvm_to_gen.cpp +++ b/backend/src/llvm/llvm_to_gen.cpp @@ -55,6 +55,7 @@ #include "llvm/Assembly/PrintModulePass.h" #endif +#include "llvm/Analysis/CFGPrinter.h" #include "llvm/llvm_gen_backend.hpp" #include "llvm/llvm_to_gen.hpp" #include "sys/cvar.hpp" @@ -68,6 +69,8 @@ namespace gbe { BVAR(OCL_OUTPUT_LLVM, false); + BVAR(OCL_OUTPUT_CFG, false); + BVAR(OCL_OUTPUT_CFG_ONLY, false); BVAR(OCL_OUTPUT_LLVM_BEFORE_EXTRA_PASS, false); using namespace llvm; @@ -204,6 +207,11 @@ namespace gbe passes.add(createDeadInstEliminationPass()); // Remove simplified instructions passes.add(createCFGSimplificationPass()); // Merge & remove BBs passes.add(createScalarizePass()); // Expand all vector ops + + if(OCL_OUTPUT_CFG) + passes.add(createCFGPrinterPass()); + if(OCL_OUTPUT_CFG_ONLY) + passes.add(createCFGOnlyPrinterPass()); passes.add(createGenPass(unit)); // Print the code extra optimization passes -- 2.7.4