[LLVMbugs] [Bug 10081] New: c backend emits multiple definitions of global variables

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 4 08:35:25 PDT 2011


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

           Summary: c backend emits multiple definitions of global
                    variables
           Product: new-bugs
           Version: 2.9
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: matt at pharr.org
                CC: llvmbugs at cs.uiuc.edu


There is a one-character typo in CBackend.cpp that causes global variable
definitions to be emitted multiple times (and thence, compilation of the
generated C code to fail when globals are present in the input IR.)  The loop
that is supposed to only emit declarations has an extra '!'; fix is below.

diff --git a/lib/Target/CBackend/CBackend.cpp
b/lib/Target/CBackend/CBackend.cpp
index fde2e29..70ea9b9 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -1885,7 +1885,7 @@ bool CWriter::doInitialization(Module &M) {
     Out << "\n\n/* Global Variable Declarations */\n";
     for (Module::global_iterator I = M.global_begin(), E = M.global_end();
          I != E; ++I)
-      if (!I->isDeclaration()) {
+      if (I->isDeclaration()) {
         // Ignore special globals, such as debug info.
         if (getGlobalVariableClass(I))
           continue;

(This bug is present in both 2.9 and TOT.)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list