[PATCH] D42127: [ARM] Don't merge global externals for windows
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 16 12:51:26 PST 2018
mstorsjo created this revision.
mstorsjo added reviewers: compnerd, john.brawn.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.
A global external on windows can have a dllexport attribute, which is lost when globals are merged.
Repository:
rL LLVM
https://reviews.llvm.org/D42127
Files:
lib/Target/ARM/ARMTargetMachine.cpp
test/CodeGen/ARM/global-merge-external.ll
Index: test/CodeGen/ARM/global-merge-external.ll
===================================================================
--- test/CodeGen/ARM/global-merge-external.ll
+++ test/CodeGen/ARM/global-merge-external.ll
@@ -3,6 +3,7 @@
; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge -global-merge-on-external=false | FileCheck %s --check-prefixes=CHECK,CHECK-NO-MERGE
; RUN: llc < %s -mtriple=arm-macho -arm-global-merge | FileCheck %s --check-prefixes=CHECK,CHECK-NO-MERGE
; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge -relocation-model=pic | FileCheck %s --check-prefixes=CHECK,CHECK-NO-MERGE
+; RUN llc < %s -mtriple=thumbv7-win32 -arm-global-merge | FileCheck %s --check-prefix=CHECK-WIN32-NO-MERGE
@x = global i32 0, align 4
@y = global i32 0, align 4
@@ -14,6 +15,9 @@
;CHECK: [[LABEL1]]:
;CHECK-MERGE: .long .L_MergedGlobals
;CHECK-NO-MERGE: .long {{_?x}}
+;CHECK-WIN32-NO-MERGE: f1:
+;CHECK-WIN32-NO-MERGE: movw: [[REG1:r[0-9]+]], :lower16:x
+;CHECK-WIN32-NO-MERGE: movt: [[REG1]], :upper16:x
store i32 %a1, i32* @x, align 4
store i32 %a2, i32* @y, align 4
ret void
@@ -25,6 +29,9 @@
;CHECK: [[LABEL2]]:
;CHECK-MERGE: .long .L_MergedGlobals
;CHECK-NO-MERGE: .long {{_?y}}
+;CHECK-WIN32-NO-MERGE: g1:
+;CHECK-WIN32-NO-MERGE: movw: [[REG2:r[0-9]+]], :lower16:y
+;CHECK-WIN32-NO-MERGE: movt: [[REG2]], :upper16:y
store i32 %a1, i32* @y, align 4
store i32 %a2, i32* @z, align 4
ret void
Index: lib/Target/ARM/ARMTargetMachine.cpp
===================================================================
--- lib/Target/ARM/ARMTargetMachine.cpp
+++ lib/Target/ARM/ARMTargetMachine.cpp
@@ -412,7 +412,10 @@
// expect it to be generally either beneficial or harmless. On Mach-O it
// is disabled as we emit the .subsections_via_symbols directive which
// means that merging extern globals is not safe.
- bool MergeExternalByDefault = !TM->getTargetTriple().isOSBinFormatMachO();
+ // Disable merging of extern globals for windows, since it would drop
+ // related dllexport attributes.
+ bool MergeExternalByDefault = !TM->getTargetTriple().isOSBinFormatMachO() &&
+ !TM->getTargetTriple().isOSWindows();
addPass(createGlobalMergePass(TM, 127, OnlyOptimizeForSize,
MergeExternalByDefault));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42127.130016.patch
Type: text/x-patch
Size: 2418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180116/3aa27f22/attachment-0001.bin>
More information about the llvm-commits
mailing list