GBE: show correct line number in build log
authorGuo Yejun <yejun.guo@intel.com>
Thu, 27 Feb 2014 17:58:20 +0000 (01:58 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Fri, 28 Feb 2014 05:34:06 +0000 (13:34 +0800)
Sometimes, we insert some code into the kernel,
it makes the line number reported in build log
mismatch with the line number in the kernel from
programer's view, use #line to correct it.

Signed-off-by: Guo Yejun <yejun.guo@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
backend/src/backend/program.cpp

index c2ac83d..f656299 100644 (file)
@@ -558,6 +558,7 @@ namespace gbe {
     llvm::raw_string_ostream ErrorInfo(ErrorString);
     llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> DiagOpts = new clang::DiagnosticOptions();
     DiagOpts->ShowCarets = false;
+    DiagOpts->ShowPresumedLoc = true;
 #if LLVM_VERSION_MINOR <= 1
     args.push_back("-triple");
     args.push_back("ptx32");
@@ -797,6 +798,10 @@ namespace gbe {
         fwrite(ocl_mathfunc_fastpath_str.c_str(), strlen(ocl_mathfunc_fastpath_str.c_str()), 1, clFile);
     }
 
+    // reset the file number in case we have inserted something into the kernel
+    std::string resetFileNum = "#line 1\n";
+    fwrite(resetFileNum.c_str(), strlen(resetFileNum.c_str()), 1, clFile);
+
     // Write the source to the cl file
     fwrite(source, strlen(source), 1, clFile);
     fclose(clFile);