[PATCH] Add comdat key field to llvm.global_ctors and llvm.global_dtors

Nick Lewycky nlewycky at google.com
Wed May 7 18:20:55 PDT 2014


On 6 May 2014 11:24, Reid Kleckner <rnk at google.com> wrote:

> ping
>

+ If the third field is present, non-null, and points to a global variable
+ or function, the initializer function will only run if the associated
+ data from the current module is included in the final linked image.

"included in the final linked image" isn't well-defined at the level of
LLVM IR. I think you mean "is not discarded", but I'm not certain.

-      Assert1(STy && STy->getNumElements() == 2 &&
+      Assert1(STy && (STy->getNumElements() == 2 ||
+                      STy->getNumElements() == 3) &&

So you're going to permit old-style and new-style in the IR. What happens
when I link the two? I think you need to autoupgrade to the new 3-argument
form.

+ namespace {
+ struct Structor {
+   Structor() : Priority(0), Func(0), ComdatKey(0) {}
+   int Priority;
+   llvm::Constant *Func;
+   llvm::GlobalValue *ComdatKey;
+ };
+ } // end namespace

C++11-ification: nullptr instead of 0, in-class initializers instead of a
constructor.

I'd appreciate if someone else reviewed the MC changes.

Overall this looks like a good language extension!

Nick


On Mon, Apr 28, 2014 at 1:36 PM, Reid Kleckner <rnk at google.com> wrote:
>
>> ping
>>
>>
>> On Thu, Apr 24, 2014 at 5:53 PM, Reid Kleckner <rnk at google.com> wrote:
>>
>>> Hi nicholas, nlewycky,
>>>
>>> This allows us to put dynamic initializers for weak data into the same
>>> comdat group as the data being initialized.  This is necessary for MSVC
>>> ABI compatibility.  It should also allow GlobalOpt to fire more often
>>> weak data on other platforms if we can sort out the initialization of
>>> the guard variable.
>>>
>>> http://reviews.llvm.org/D3499
>>>
>>> Files:
>>>   docs/LangRef.rst
>>>   include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
>>>   include/llvm/Target/TargetLoweringObjectFile.h
>>>   lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>>>   lib/CodeGen/TargetLoweringObjectFileImpl.cpp
>>>   lib/IR/Verifier.cpp
>>>   lib/Transforms/IPO/GlobalOpt.cpp
>>>   test/MC/COFF/global_ctors_dtors.ll
>>>   test/Transforms/GlobalOpt/ctor-list-opt.ll
>>>   test/Verifier/global-ctors.ll
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140507/7f60a59e/attachment.html>


More information about the llvm-commits mailing list