<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - In Windows global_dtors calls before main or fails program after main"
href="https://bugs.llvm.org/show_bug.cgi?id=46500">46500</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>In Windows global_dtors calls before main or fails program after main
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>release blocker
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>tarasber@yandex.ru
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23654" name="attach_23654" title="file to compile">attachment 23654</a> <a href="attachment.cgi?id=23654&action=edit" title="file to compile">[details]</a></span>
file to compile
Here is .ll code:
;---------------------------------------------------------------------
; ModuleID = 't.ll'
source_filename = "t.ll"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.24.28316"
%type.3 = type { i32 }
@string.2 = private unnamed_addr constant { i32, [2 x i8] } { i32 2, [2 x i8]
c"A\00" }
@global.95 = private local_unnamed_addr global %type.3 zeroinitializer
@string.4 = private unnamed_addr constant { i32, [5 x i8] } { i32 5, [5 x i8]
c"main\00" }
@string.5 = private unnamed_addr constant { i32, [5 x i8] } { i32 5, [5 x i8]
c"~A()\00" }
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void
()*, i8* } { i32 0, void ()* @global.ctors, i8* null }]
@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void
()*, i8* } { i32 65535, void ()* @global.dtors, i8* null }] ;
<---------------------------- here I changed dtor priority
@t.a.0 = alias %type.3, %type.3* @global.95
; Function Attrs: nofree nounwind
define internal void @global.ctors() #0 {
tail call void (i8*, ...) @printf(i8* getelementptr inbounds ({ i32, [2 x i8]
}, { i32, [2 x i8] }* @string.2, i64 0, i32 1, i64 0)) #1
store i32 0, i32* getelementptr inbounds (%type.3, %type.3* @global.95, i64
0, i32 0), align 8
ret void
}
; Function Attrs: nofree nounwind
define internal void @global.dtors() #0 {
tail call void (i8*, ...) @printf(i8* getelementptr inbounds ({ i32, [5 x i8]
}, { i32, [5 x i8] }* @string.5, i64 0, i32 1, i64 0)) #1
ret void
}
; Function Attrs: nofree nounwind
declare void @printf(i8* nocapture readonly, ...) local_unnamed_addr #0
; Function Attrs: nofree nounwind
define i32 @main() local_unnamed_addr #0 {
label0:
tail call void (i8*, ...) @printf(i8* getelementptr inbounds ({ i32, [5 x i8]
}, { i32, [5 x i8] }* @string.4, i64 0, i32 1, i64 0))
ret i32 0
}
attributes #0 = { nofree nounwind }
attributes #1 = { nounwind }
;-------------------------------------------------------------------------------
then I try to compile&run it:
clang t.ll
a.exe
I tried to change priority of global_dtor to differentvalues.
When I make in 0,1,...65534 global_dtor calls BEFORE main.
When I make it 65535, program fails after main.
In Linux all values of priority of global_dtor generate correct program.
So now I have the only way to generate correct global_dtors - generate
platform-specifix quirks line "atexit" etc. But it is not good, I hove llvm
will fix this bug.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>