[LLVMbugs] [Bug 1515] NEW: llvm2cpp generates incorrect code when -funcname parameter is used.

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Jun 16 02:15:12 PDT 2007


http://llvm.org/bugs/show_bug.cgi?id=1515

           Summary: llvm2cpp generates incorrect code when -funcname
                    parameter is used.
           Product: new-bugs
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: letz at grame.fr


When llvm2cpp is used to generated a program *and* -funcname parameter is used, the generated 
code is incorrect:  

llvm2cpp -f   -funcname=LLVMBackend template.bc gives:

Module* LLVMBackend();

int main(int argc, char**argv) {
  Module* Mod = makeLLVMModule();
  verifyModule(*Mod, PrintMessageAction);
  std::cerr.flush();
  std::cout.flush();
  PassManager PM;
  PM.add(new PrintModulePass(&llvm::cout));
  PM.run(*Mod);
  return 0;
}
...

main call the "generic" makeLLVMModule() function where LLVMBackend() should be used instead. The 
following patch for current CVS fix the problem:


? cppwritter.patch
Index: tools/llvm2cpp/CppWriter.cpp
===============================================================
====
RCS file: /var/cvs/llvm/llvm/tools/llvm2cpp/CppWriter.cpp,v
retrieving revision 1.49
diff -u -r1.49 CppWriter.cpp
--- tools/llvm2cpp/CppWriter.cpp	5 Jun 2007 05:28:26 -0000
	1.49
+++ tools/llvm2cpp/CppWriter.cpp	16 Jun 2007 09:03:50 -0000
@@ -1690,7 +1690,7 @@
   Out << "using namespace llvm;\n\n";
   Out << "Module* " << fname << "();\n\n";
   Out << "int main(int argc, char**argv) {\n";
-  Out << "  Module* Mod = makeLLVMModule();\n";
+  Out << "  Module* Mod =" << fname << "();\n";
   Out << "  verifyModule(*Mod, PrintMessageAction);\n";
   Out << "  std::cerr.flush();\n";
   Out << "  std::cout.flush();\n";



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the llvm-bugs mailing list