From d81b53817b1509216ac694d4bd68f145fa28ef8d Mon Sep 17 00:00:00 2001 From: Boris Ulasevich Date: Tue, 17 Jan 2017 13:27:28 +0000 Subject: BrainF example: fixing output buffering issue Differential Revision: https://reviews.llvm.org/D27824 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292216 91177308-0d34-0410-b5e6-96231b3b80d8 --- examples/BrainF/BrainFDriver.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'examples') diff --git a/examples/BrainF/BrainFDriver.cpp b/examples/BrainF/BrainFDriver.cpp index 57a86fbf521..d704506d244 100644 --- a/examples/BrainF/BrainFDriver.cpp +++ b/examples/BrainF/BrainFDriver.cpp @@ -166,6 +166,10 @@ int main(int argc, char **argv) { std::vector args; Function *brainf_func = M.getFunction("brainf"); GenericValue gv = ee->runFunction(brainf_func, args); + // Genereated code calls putchar, and output is not guaranteed without fflush. + // The better place for fflush(stdout) call would be the generated code, but it + // is unmanageable because stdout linkage name depends on stdlib implementation. + fflush(stdout); } else { WriteBitcodeToFile(Mod.get(), *out); } -- cgit v1.2.3