[llvm-commits] [PATCH] removing a newline when printing a Global Variable

Duncan Sands baldrick at free.fr
Fri Sep 7 04:34:35 PDT 2012


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).

>
> I hope I was clear enough.

Yes, thanks!

Ciao, Duncan.

>
>
> Best regards,
> Saša
>
> On 09/07/2012 12:33 PM, Duncan Sands wrote:
>> Hi Saša, welcome to LLVM!
>>
>> On 07/09/12 10:25, Saša Tomić wrote:
>>> And of course, the first patch was wrong -- it included git color codes. :(
>>> Here's the correct one.
>>
>> Thanks for the patch, but: why is it correct - what is the issue you are fixing?
>> Can you give an example?  Also, please add a testcase.
>>
>> Best wishes, Duncan.
>>
>>>
>>> On 09/07/2012 10:23 AM, Saša Tomić wrote:
>>>> Hi to all,
>>>>
>>>> this is my first patch for LLVM. I'm not really aware of all the rules and the
>>>> norms that should be followed here.
>>>> I did read the text at http://llvm.org/docs/DeveloperPolicy.html
>>>>
>>>> This is just a minor fix, dropping a newline when a global variable is printed.
>>>> So here is the patch (in the attachment).
>>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list