[llvm-commits] [PATCH] removing a newline when printing a Global Variable
Saša Tomić
tomic80 at gmail.com
Fri Sep 7 05:17:19 PDT 2012
Hi Duncan,
On 09/07/2012 01:34 PM, Duncan Sands wrote:
> Hi Saša,
>
>> I'm not sure how to add a testcase, but I'll try to explain the issue
>> at hand.
>>
>> // You have: Value *a, *b, *c; And you call:
>> dbgs() << *a << "\n";
>> dbgs() << *b << "\n";
>> dbgs() << *c << "\n";
>>
>> This should print *a, *b, and *c with consistent formatting. For
>> example:
>> ---------
>> @shared = common global i32** null, align 8
>> %arrayidx = getelementptr inbounds i32** %4, i64 %idxprom, !dbg !26
>> %i = alloca i32, align 4
>> ---------
>>
>> However, if 'a' happens to be a global variable, its .print() method
>> will append
>> one more newline, like this:
>> ---------
>> @shared = common global i32** null, align 8
>>
>> %arrayidx = getelementptr inbounds i32** %4, i64 %idxprom, !dbg !26
>> %i = alloca i32, align 4
>> ---------
>
> OK, but this method is also using by llvm-dis and friends to turn
> bitcode into
> human readable IR. I think your patch is going to break that because all
> globals will now end up on the same line. Did you run the testsuite?
> In short,
> if you remove the newline here (which sounds like a good idea) then
> you will
> need to put an extra newline somewhere else to fix module printing (I
> don't
> know where, but hopefully you can find it).
You seem to be right, the change did break a lot of tests.
I tried tracing down from where a global variable is printed, but it
wasn't that straightforward.
I'll have to put it aside for until I have more free time.
--
best regards,
Saša
More information about the llvm-commits
mailing list