[PATCH] D66373: Fixed placement of llvm.global_dtors on Windows.
Vyacheslav Zakharin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 14:10:30 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369299: Fixed placement of llvm.global_dtors on Windows. (authored by vzakhari, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D66373?vs=215720&id=215981#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66373/new/
https://reviews.llvm.org/D66373
Files:
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/trunk/test/CodeGen/X86/dtor-priority-coff.ll
Index: llvm/trunk/test/CodeGen/X86/dtor-priority-coff.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/dtor-priority-coff.ll
+++ llvm/trunk/test/CodeGen/X86/dtor-priority-coff.ll
@@ -0,0 +1,70 @@
+; RUN: llc < %s | FileCheck %s
+
+; Check that we come up with appropriate section names that link.exe sorts
+; well.
+
+; CHECK: .section .CRT$XTA00042,"dr"
+; CHECK: .p2align 3
+; CHECK: .quad f
+; CHECK: .section .CRT$XTT12345,"dr"
+; CHECK: .p2align 3
+; CHECK: .quad g
+; CHECK: .section .CRT$XTT23456,"dr",associative,h
+; CHECK: .p2align 3
+; CHECK: .quad init_h
+; CHECK: .section .CRT$XTX,"dr"
+; CHECK: .p2align 3
+; CHECK: .quad str3_dtor
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.14.26433"
+
+$h = comdat any
+
+ at h = linkonce_odr global i8 55, comdat, align 1
+
+ at str0 = private dso_local unnamed_addr constant [6 x i8] c"later\00", align 1
+ at str1 = private dso_local unnamed_addr constant [6 x i8] c"first\00", align 1
+ at str2 = private dso_local unnamed_addr constant [5 x i8] c"main\00", align 1
+ at str3 = private dso_local unnamed_addr constant [8 x i8] c"default\00", align 1
+
+ at llvm.global_dtors = appending global [4 x { i32, void ()*, i8* }] [
+ { i32, void ()*, i8* } { i32 12345, void ()* @g, i8* null },
+ { i32, void ()*, i8* } { i32 42, void ()* @f, i8* null },
+ { i32, void ()*, i8* } { i32 23456, void ()* @init_h, i8* @h },
+ { i32, void ()*, i8* } { i32 65535, void ()* @str3_dtor, i8* null }
+]
+
+declare dso_local i32 @puts(i8* nocapture readonly) local_unnamed_addr
+
+define dso_local void @g() {
+entry:
+ %call = tail call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str0, i64 0, i64 0))
+ ret void
+}
+
+define dso_local void @f() {
+entry:
+ %call = tail call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str1, i64 0, i64 0))
+ ret void
+}
+
+define dso_local void @str3_dtor() {
+entry:
+ %call = tail call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str3, i64 0, i64 0))
+ ret void
+}
+
+define dso_local void @init_h() {
+entry:
+ store i8 42, i8* @h
+ ret void
+}
+
+
+; Function Attrs: nounwind uwtable
+define dso_local i32 @main() local_unnamed_addr {
+entry:
+ %call = tail call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str2, i64 0, i64 0))
+ ret i32 0
+}
Index: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1520,7 +1520,8 @@
// internally, so we use ".CRT$XCA00001" for them.
SmallString<24> Name;
raw_svector_ostream OS(Name);
- OS << ".CRT$XC" << (Priority < 200 ? 'A' : 'T') << format("%05u", Priority);
+ OS << ".CRT$X" << (IsCtor ? "C" : "T") <<
+ (Priority < 200 ? 'A' : 'T') << format("%05u", Priority);
MCSectionCOFF *Sec = Ctx.getCOFFSection(
Name, COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
SectionKind::getReadOnly());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66373.215981.patch
Type: text/x-patch
Size: 3208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190819/f3be83fb/attachment.bin>
More information about the llvm-commits
mailing list