[llvm-commits] [llvm] r137134 - in /llvm/trunk: lib/Target/CBackend/CBackend.cpp test/CodeGen/CBackend/pr10081.ll
Bill Wendling
isanbard at gmail.com
Tue Aug 9 11:57:40 PDT 2011
On Aug 9, 2011, at 11:44 AM, Eli Friedman wrote:
> On Tue, Aug 9, 2011 at 11:31 AM, Bill Wendling <isanbard at gmail.com> wrote:
>> Author: void
>> Date: Tue Aug 9 13:31:50 2011
>> New Revision: 137134
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=137134&view=rev
>> Log:
>> Print out the variable declaration only if it is a declaration. Otherwise, a
>> 'static' variable will be emitted twice.
>> PR10081
>>
>> Added:
>> llvm/trunk/test/CodeGen/CBackend/pr10081.ll
>> Modified:
>> llvm/trunk/lib/Target/CBackend/CBackend.cpp
>>
>> Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=137134&r1=137133&r2=137134&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
>> +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Tue Aug 9 13:31:50 2011
>> @@ -1817,7 +1817,7 @@
>> 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;
>
> I'm pretty sure the original code was correct... and works as long as
> you don't try to compile the output of the C backend as C++. Consider
> something like the following C code:
> static void* x;
> static void* y = &x;
> static void* x = &y;
> void* z = &y;
>
Doh!! You're right…
-bw
More information about the llvm-commits
mailing list