[llvm-commits] [llvm] r164476 - in /llvm/trunk: lib/MC/MCObjectFileInfo.cpp test/MC/COFF/global_ctors.ll test/MC/COFF/global_ctors_dtors.ll
João Matos
ripzonetriton at gmail.com
Mon Sep 24 07:58:02 PDT 2012
Alright, then there should be no problem. Thanks for clarifying.
On Mon, Sep 24, 2012 at 6:00 AM, Kai <kai at redstar.de> wrote:
> Hi João!
>
> > Kai told this only works with the statically linked runtime. Since Clang
>
>> can also work with the DLL version of the runtime (and it's the most
>> usual runtime option used), how should we handle it in LLVM?
>>
>
> The point here is: clang does not use a global dtor. Instead the static
> global constructor uses atexit() to install the call to the destructor.
> That's also the way MSVC handles this case.
> So there is no issue...
>
>
>>
>> On Sun, Sep 23, 2012 at 4:53 PM, Anton Korobeynikov
>> <asl at math.spbu.ru
>> <mailto:asl at math.spbu.ru>> wrote:
>>
>> Author: asl
>> Date: Sun Sep 23 10:53:47 2012
>> New Revision: 164476
>>
>> URL: http://llvm.org/viewvc/llvm-**project?rev=164476&view=rev<http://llvm.org/viewvc/llvm-project?rev=164476&view=rev>
>> Log:
>> Emit dtors into proper section while compiling in vcpp-compatible
>> mode.
>> Patch by Kai!
>>
>> Added:
>> llvm/trunk/test/MC/COFF/**global_ctors_dtors.ll
>> Removed:
>> llvm/trunk/test/MC/COFF/**global_ctors.ll
>> Modified:
>> llvm/trunk/lib/MC/**MCObjectFileInfo.cpp
>>
>> Modified: llvm/trunk/lib/MC/**MCObjectFileInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-**project/llvm/trunk/lib/MC/**
>> MCObjectFileInfo.cpp?rev=**164476&r1=164475&r2=164476&**view=diff<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=164476&r1=164475&r2=164476&view=diff>
>> ==============================**==============================**
>> ==================
>> --- llvm/trunk/lib/MC/**MCObjectFileInfo.cpp (original)
>> +++ llvm/trunk/lib/MC/**MCObjectFileInfo.cpp Sun Sep 23 10:53:47 2012
>> @@ -430,12 +430,20 @@
>> }
>>
>>
>> - StaticDtorSection =
>> - Ctx->getCOFFSection(".dtors",
>> - COFF::IMAGE_SCN_CNT_**INITIALIZED_DATA |
>> - COFF::IMAGE_SCN_MEM_READ |
>> - COFF::IMAGE_SCN_MEM_WRITE,
>> - SectionKind::getDataRel());
>> + if (T.getOS() == Triple::Win32) {
>> + StaticDtorSection =
>> + Ctx->getCOFFSection(".CRT$XTX"**,
>> + COFF::IMAGE_SCN_CNT_**INITIALIZED_DATA |
>> + COFF::IMAGE_SCN_MEM_READ,
>> + SectionKind::getReadOnly());
>> + } else {
>> + StaticDtorSection =
>> + Ctx->getCOFFSection(".dtors",
>> + COFF::IMAGE_SCN_CNT_**INITIALIZED_DATA |
>> + COFF::IMAGE_SCN_MEM_READ |
>> + COFF::IMAGE_SCN_MEM_WRITE,
>> + SectionKind::getDataRel());
>> + }
>>
>> // FIXME: We're emitting LSDA info into a readonly section on
>> COFF, even
>> // though it contains relocatable pointers. In PIC mode, this
>> is probably a
>>
>> Removed: llvm/trunk/test/MC/COFF/**global_ctors.ll
>> URL:
>> http://llvm.org/viewvc/llvm-**project/llvm/trunk/test/MC/**
>> COFF/global_ctors.ll?rev=**164475&view=auto<http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/global_ctors.ll?rev=164475&view=auto>
>> ==============================**==============================**
>> ==================
>> --- llvm/trunk/test/MC/COFF/**global_ctors.ll (original)
>> +++ llvm/trunk/test/MC/COFF/**global_ctors.ll (removed)
>> @@ -1,28 +0,0 @@
>> -; Test that global ctors are emitted into the proper COFF section
>> for the
>> -; target. Mingw uses .ctors, whereas MSVC uses .CRT$XC*.
>> -; RUN: llc < %s -mtriple i686-pc-win32 | FileCheck %s
>> --check-prefix WIN32
>> -; RUN: llc < %s -mtriple x86_64-pc-win32 | FileCheck %s
>> --check-prefix WIN32
>> -; RUN: llc < %s -mtriple i686-pc-mingw32 | FileCheck %s
>> --check-prefix MINGW32
>> -; RUN: llc < %s -mtriple x86_64-pc-mingw32 | FileCheck %s
>> --check-prefix MINGW32
>> -
>> - at .str = private unnamed_addr constant [13 x i8] c"constructing\00",
>> align 1
>> - at .str2 = private unnamed_addr constant [5 x i8] c"main\00", align 1
>> -
>> - at llvm.global_ctors = appending global [1 x { i32, void ()* }] [{
>> i32, void ()* } { i32 65535, void ()* @a_global_ctor }]
>> -
>> -declare i32 @puts(i8*)
>> -
>> -define void @a_global_ctor() nounwind {
>> - %1 = call i32 @puts(i8* getelementptr inbounds ([13 x i8]* @.str,
>> i32 0, i32 0))
>> - ret void
>> -}
>> -
>> -define i32 @main() nounwind {
>> - %1 = call i32 @puts(i8* getelementptr inbounds ([5 x i8]* @.str2,
>> i32 0, i32 0))
>> - ret i32 0
>> -}
>> -
>> -; WIN32: .section .CRT$XCU,"r"
>> -; WIN32: a_global_ctor
>> -; MINGW32: .section .ctors,"w"
>> -; MINGW32: a_global_ctor
>>
>> Added: llvm/trunk/test/MC/COFF/**global_ctors_dtors.ll
>> URL:
>> http://llvm.org/viewvc/llvm-**project/llvm/trunk/test/MC/**
>> COFF/global_ctors_dtors.ll?**rev=164476&view=auto<http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/global_ctors_dtors.ll?rev=164476&view=auto>
>> ==============================**==============================**
>> ==================
>> --- llvm/trunk/test/MC/COFF/**global_ctors_dtors.ll (added)
>> +++ llvm/trunk/test/MC/COFF/**global_ctors_dtors.ll Sun Sep 23
>> 10:53:47 2012
>> @@ -0,0 +1,39 @@
>> +; Test that global ctors are emitted into the proper COFF section
>> for the
>> +; target. Mingw uses .ctors, whereas MSVC uses .CRT$XC*.
>> +; RUN: llc < %s -mtriple i686-pc-win32 | FileCheck %s
>> --check-prefix WIN32
>> +; RUN: llc < %s -mtriple x86_64-pc-win32 | FileCheck %s
>> --check-prefix WIN32
>> +; RUN: llc < %s -mtriple i686-pc-mingw32 | FileCheck %s
>> --check-prefix MINGW32
>> +; RUN: llc < %s -mtriple x86_64-pc-mingw32 | FileCheck %s
>> --check-prefix MINGW32
>> +
>> + at .str = private unnamed_addr constant [13 x i8] c"constructing\00",
>> align 1
>> + at .str2 = private unnamed_addr constant [12 x i8] c"destructing\00",
>> align 1
>> + at .str3 = private unnamed_addr constant [5 x i8] c"main\00", align 1
>> +
>> + at llvm.global_ctors = appending global [1 x { i32, void ()* }] [{
>> i32, void ()* } { i32 65535, void ()* @a_global_ctor }]
>> + at llvm.global_dtors = appending global [1 x { i32, void ()* }] [{
>> i32, void ()* } { i32 65535, void ()* @a_global_dtor }]
>> +
>> +declare i32 @puts(i8*)
>> +
>> +define void @a_global_ctor() nounwind {
>> + %1 = call i32 @puts(i8* getelementptr inbounds ([13 x i8]* @.str,
>> i32 0, i32 0))
>> + ret void
>> +}
>> +
>> +define void @a_global_dtor() nounwind {
>> + %1 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]*
>> @.str2, i32 0, i32 0))
>> + ret void
>> +}
>> +
>> +define i32 @main() nounwind {
>> + %1 = call i32 @puts(i8* getelementptr inbounds ([5 x i8]* @.str3,
>> i32 0, i32 0))
>> + ret i32 0
>> +}
>> +
>> +; WIN32: .section .CRT$XCU,"r"
>> +; WIN32: a_global_ctor
>> +; WIN32: .section .CRT$XTX,"r"
>> +; WIN32: a_global_dtor
>> +; MINGW32: .section .ctors,"w"
>> +; MINGW32: a_global_ctor
>> +; MINGW32: .section .dtors,"w"
>> +; MINGW32: a_global_dtor
>>
>>
>> ______________________________**_________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> <mailto:llvm-commits at cs.uiuc.**edu <llvm-commits at cs.uiuc.edu>>
>>
>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits<http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>>
>>
>>
>>
>> --
>> João Matos
>>
>>
>> ______________________________**_________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits<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<http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>
--
João Matos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120924/9462ab48/attachment.html>
More information about the llvm-commits
mailing list