[llvm-commits] [llvm] r58727 - in /llvm/trunk: include/llvm/Module.h lib/CodeGen/StackProtector.cpp lib/VMCore/Module.cpp

Chris Lattner clattner at apple.com
Fri Nov 7 11:27:17 PST 2008


On Nov 6, 2008, at 4:06 PM, Bill Wendling wrote:

> On Thu, Nov 6, 2008 at 9:57 AM, Chris Lattner <clattner at apple.com>  
> wrote:
>> On Nov 5, 2008, at 4:19 PM, Bill Wendling wrote:
>>>> Awesome, thanks Bill!  One minor nit: getOrInsertFunction takes a
>>>> function, not a pointer to the function.  Do you think it makes  
>>>> sense
>>>> for getOrInsertGlobal to take the "contained" type of the global,
>>>> instead of the pointer?
>>>>
>>> If I understand correctly, that's what this change is doing. :-)  
>>> Or do
>>> you want to create another "derived type" called GlobalType  
>>> similar to
>>> FunctionType and use that?
>>
>> I believe that if you pass in an i32 to the current implementation
>> that it will get an assert fail or invalid IR, not a global that  
>> holds
>> an i32.  To get a global that holds an i32, you have to pass in i32*
>> (which is different than how the globalvariable ctor works, which is
>> confusing).
>>
>> If it doesn't work like this, then please ignore me :)
>>
> I did a quick test with this code:
>
>  Constant *C = M->getOrInsertGlobal("__fnord", Type::Int32Ty);
>  new LoadInst(C, "C", false, InsertPt);
>
> and the LLVM IR looks like this:
>
> @__fnord = external global i32          ; <i32*> [#uses=1]
>
> define i32 @foo() nounwind {
> entry:
>        %C = load i32* @__fnord         ; <i32> [#uses=0]
>
> So ignore you? ;-)

Yep, totally ignore me.  Thanks for verifying Bill!

-Chris



More information about the llvm-commits mailing list