From: Junyan He <[email protected]> In order to make the compiling error readable in the gen backend bebug info, we always need the line and column number. Rather than just give a ASSERT, we perfer to give more information to the kernel writer. We now append line and column numbers to every llvm-instruction, ir-instruction, selection-instruction and even ASM-instruction. So when we generate the ASSERT, we can at least give some hints about the location in the source code. -g opt seems do not have performance side effect for clang front end by now. One point needs to notice, before serialization, we need to strip out all the debug informattion, because the bitcode writter does not support to write the debug info.
Signed-off-by: Junyan He <[email protected]> --- backend/src/backend/program.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp index 59cfe39..b8da826 100644 --- a/backend/src/backend/program.cpp +++ b/backend/src/backend/program.cpp @@ -76,6 +76,7 @@ #if LLVM_VERSION_MINOR <= 2 #include <llvm/Module.h> #else +#include <llvm/IR/DebugInfo.h> #include <llvm/IR/Module.h> #endif /* LLVM_VERSION_MINOR <= 2 */ #include <llvm/Bitcode/ReaderWriter.h> @@ -118,6 +119,8 @@ namespace gbe { BVAR(OCL_STRICT_CONFORMANCE, true); BVAR(OCL_OUTPUT_BUILD_LOG, false); extern std::string OCL_PROFILING_LINES; + extern int32_t OCL_OUTPUT_SEL_IR; + extern int32_t OCL_OUTPUT_ASM; bool Program::buildFromLLVMFile(const char *fileName, const void* module, std::string &error, int optLevel, const char* source) { ir::Unit *unit = new ir::Unit(); @@ -537,7 +540,6 @@ namespace gbe { program->CleanLlvmResource(); } -BVAR(OCL_DEBUGINFO, false); #ifdef GBE_COMPILER_AVAILABLE static bool buildModuleFromSource(const char *source, llvm::Module** out_module, llvm::LLVMContext* llvm_ctx, std::string dumpLLVMFileName, std::string dumpSPIRBinaryName, std::vector<std::string>& options, size_t stringSize, char *err, @@ -553,6 +555,11 @@ BVAR(OCL_DEBUGINFO, false); args.push_back("-cl-kernel-arg-info"); args.push_back("-mllvm"); args.push_back("-inline-threshold=200000"); + /* We always want the debug line and col if output debug info. */ + if (OCL_PROFILING_LINES != "" || OCL_OUTPUT_BUILD_LOG || OCL_OUTPUT_GEN_IR + || OCL_OUTPUT_SEL_IR || OCL_OUTPUT_ASM) + args.push_back("-g"); + #ifdef GEN7_SAMPLER_CLAMP_BORDER_WORKAROUND args.push_back("-DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND"); #endif @@ -574,7 +581,6 @@ BVAR(OCL_DEBUGINFO, false); #endif /* LLVM_VERSION_MINOR <= 2 */ args.push_back("stringInput.cl"); args.push_back("-ffp-contract=off"); - if(OCL_DEBUGINFO) args.push_back("-g"); // The compiler invocation needs a DiagnosticsEngine so it can report problems std::string ErrorString; @@ -686,8 +692,10 @@ BVAR(OCL_DEBUGINFO, false); llvm::sys::fs::F_None #endif ); - if (err.empty()) + if (err.empty()) { + llvm::StripDebugInfo(**out_module); llvm::WriteBitcodeToFile(*out_module, ostream); + } } #else if (!dumpLLVMFileName.empty()) { @@ -703,8 +711,10 @@ BVAR(OCL_DEBUGINFO, false); std::error_code err; llvm::raw_fd_ostream ostream (dumpSPIRBinaryName.c_str(), err, llvm::sys::fs::F_None); - if (!err) + if (!err) { + llvm::StripDebugInfo(**out_module); llvm::WriteBitcodeToFile(*out_module, ostream); + } } #endif return true; -- 1.9.1 _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
