Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2807,7 +2807,11 @@ void AsmPrinter::emitXXStructorList(const DataLayout &DL, const Constant *List,

// Emit the structors in reverse order if we are using the .ctor/.dtor
// initialization scheme.
if (!TM.Options.UseInitArray)
bool UseCtorSection = !TM.Options.UseInitArray;
// MinGW targets always use the .ctors section.
if (TM.getTargetTriple().isWindowsGNUEnvironment())
UseCtorSection = true;
if (UseCtorSection)
std::reverse(Structors.begin(), Structors.end());

const Align Align = DL.getPointerPrefAlignment();
Expand Down
12 changes: 6 additions & 6 deletions llvm/test/CodeGen/X86/constructor.ll
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ entry:
; MCU-CTORS: .section .ctors,"aw",@progbits
; MCU-INIT-ARRAY: .section .init_array,"aw",@init_array

; COFF-CTOR: .section .ctors.65520,"dw",associative,v
; COFF-CTOR: .section .ctors,"dw"
; COFF-CTOR-NEXT: .p2align 3
; COFF-CTOR-NEXT: .quad g
; COFF-CTOR-NEXT: .quad j
; COFF-CTOR-NEXT: .quad i
; COFF-CTOR-NEXT: .quad f
; COFF-CTOR-NEXT: .section .ctors.09980,"dw",associative,v
; COFF-CTOR-NEXT: .p2align 3
; COFF-CTOR-NEXT: .quad h
; COFF-CTOR-NEXT: .section .ctors,"dw"
; COFF-CTOR-NEXT: .section .ctors.65520,"dw",associative,v
; COFF-CTOR-NEXT: .p2align 3
; COFF-CTOR-NEXT: .quad f
; COFF-CTOR-NEXT: .quad i
; COFF-CTOR-NEXT: .quad j
; COFF-CTOR-NEXT: .quad g
4 changes: 2 additions & 2 deletions llvm/test/MC/COFF/global_ctors_dtors.ll
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ define i32 @main() nounwind {
; WIN32-NOT: c_global_ctor
; WIN32: .section .CRT$XTX,"dr"
; WIN32: a_global_dtor
; MINGW32: .section .ctors,"dw"
; MINGW32: a_global_ctor
; MINGW32: .section .ctors,"dw",associative,{{_?}}b
; MINGW32: b_global_ctor
; MINGW32-NOT: c_global_ctor
; MINGW32: .section .ctors,"dw"
; MINGW32: a_global_ctor
; MINGW32: .section .dtors,"dw"
; MINGW32: a_global_dtor