[llvm-commits] bug fix to get lto-bugpoint to compile

Erick Tryzelaar idadesub at users.sourceforge.net
Fri Oct 10 01:13:35 PDT 2008


Good morning. I was trying to build lto-bugpoint this morning, and it
seems that it was missed in revision 55092 changing the argument types
for addPassesToEmitFile. This patch copies what happens in llc when
calling addPassesToEmitFile, so hopefully it's alright. I'm not sure
how to test this to confirm it works though:


diff --git tools/lto-bugpoint/LTOBugPoint.cpp tools/lto-bugpoint/LTOBugPoint.cpp
index 587e360..96acf4a 100644
--- tools/lto-bugpoint/LTOBugPoint.cpp
+++ tools/lto-bugpoint/LTOBugPoint.cpp
@@ -24,6 +24,7 @@
 #include "llvm/Target/TargetMachineRegistry.h"
 #include "llvm/Support/SystemUtils.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/Config/config.h"
 #include <fstream>
@@ -189,7 +190,13 @@ bool LTOBugPoint::assembleBitcode(llvm::Module
*M, const char *AsmFileName) {
   CGPasses->add(new TargetData(*Target->getTargetData()));
   MachineCodeEmitter* mce = NULL;

-  std::ofstream *Out = new std::ofstream(AsmFileName, std::ios::out);
+  std::string error;
+  raw_ostream *Out = new raw_fd_ostream(AsmFileName, error);
+  if (!error.empty()) {
+    std::cerr << error << '\n';
+    delete Out;
+    return false;
+  }

   switch (Target->addPassesToEmitFile(*CGPasses, *Out,
                                       TargetMachine::AssemblyFile, true)) {



More information about the llvm-commits mailing list