From ac9ef182b6269124dcd2c4cca5fa5368927c4c96 Mon Sep 17 00:00:00 2001 From: Homer Hsing Date: Tue, 16 Apr 2013 11:12:01 +0800 Subject: [PATCH] make raw_fd_ostream not close stdout stdout was closed by llvm::raw_fd_ostream. Now let llvm::raw_fd_ostream not close stdout. Signed-off-by: Homer Hsing Reviewed-by: Zhigang Gong --- backend/src/llvm/llvm_to_gen.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/backend/src/llvm/llvm_to_gen.cpp b/backend/src/llvm/llvm_to_gen.cpp index 21193a5..ea3d9eb 100644 --- a/backend/src/llvm/llvm_to_gen.cpp +++ b/backend/src/llvm/llvm_to_gen.cpp @@ -55,7 +55,7 @@ namespace gbe std::string errInfo; std::unique_ptr o = NULL; if (OCL_OUTPUT_LLVM_BEFORE_EXTRA_PASS || OCL_OUTPUT_LLVM) - o = std::unique_ptr(new llvm::raw_fd_ostream("-", errInfo)); + o = std::unique_ptr(new llvm::raw_fd_ostream(fileno(stdout), false)); // Get the module from its file SMDiagnostic Err; @@ -83,13 +83,6 @@ namespace gbe passes.add(createPrintModulePass(&*o)); passes.run(mod); - // raw_fd_ostream closes stdout. We must reopen it - if (OCL_OUTPUT_LLVM_BEFORE_EXTRA_PASS || OCL_OUTPUT_LLVM) { - o = NULL; - const int fd = open("/dev/tty", O_WRONLY); - stdout = fdopen(fd, "w"); - } - return true; } } /* namespace gbe */ -- 2.7.4