llvm.org GIT mirror llvm / 50fb516
Merging r322900 and r323307: ------------------------------------------------------------------------ r322900 | mstorsjo | 2018-01-18 22:21:48 +0100 (Thu, 18 Jan 2018) | 6 lines [test] Actually check the common parts in CodeGen/ARM/global-merge-external.ll. NFC. Previously, these parts weren't ever checked. The label patterns need to be extended to match successfully on macho. Differential Revision: https://reviews.llvm.org/D42126 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r323307 | mstorsjo | 2018-01-24 07:40:04 +0100 (Wed, 24 Jan 2018) | 6 lines [GlobalMerge] Don't merge dllexport globals Merging such globals loses the dllexport attribute. Add a test to check that normal globals still are merged. Differential Revision: https://reviews.llvm.org/D42127 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@323337 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 1 year, 11 months ago
3 changed file(s) with 39 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
576576 for (auto &GV : M.globals()) {
577577 // Merge is safe for "normal" internal or external globals only
578578 if (GV.isDeclaration() || GV.isThreadLocal() ||
579 GV.hasSection() || GV.hasImplicitSection())
579 GV.hasSection() || GV.hasImplicitSection() ||
580 GV.hasDLLExportStorageClass())
580581 continue;
581582
582583 // It's not safe to merge globals that may be preempted
0 ; RUN: llc < %s -mtriple=thumbv7-win32 -arm-global-merge | FileCheck %s
1
2 @x = global i32 0, align 4
3 @y = dllexport global i32 0, align 4
4
5 define void @f1(i32 %a1, i32 %a2) {
6 ; CHECK: f1:
7 ; CHECK: movw [[REG1:r[0-9]+]], :lower16:x
8 ; CHECK: movt [[REG1]], :upper16:x
9 store i32 %a1, i32* @x, align 4
10 store i32 %a2, i32* @y, align 4
11 ret void
12 }
13
14 ; CHECK-NOT: .L_MergedGlobals
None ; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge | FileCheck %s --check-prefix=CHECK-MERGE
1 ; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge -global-merge-on-external=true | FileCheck %s --check-prefix=CHECK-MERGE
2 ; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge -global-merge-on-external=false | FileCheck %s --check-prefix=CHECK-NO-MERGE
3 ; RUN: llc < %s -mtriple=arm-macho -arm-global-merge | FileCheck %s --check-prefix=CHECK-NO-MERGE
4 ; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge -relocation-model=pic | FileCheck %s --check-prefix=CHECK-NO-MERGE
0 ; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge | FileCheck %s --check-prefixes=CHECK,CHECK-MERGE
1 ; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge -global-merge-on-external=true | FileCheck %s --check-prefixes=CHECK,CHECK-MERGE
2 ; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge -global-merge-on-external=false | FileCheck %s --check-prefixes=CHECK,CHECK-NO-MERGE
3 ; RUN: llc < %s -mtriple=arm-macho -arm-global-merge | FileCheck %s --check-prefixes=CHECK,CHECK-NO-MERGE
4 ; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge -relocation-model=pic | FileCheck %s --check-prefixes=CHECK,CHECK-NO-MERGE
5 ; RUN: llc < %s -mtriple=thumbv7-win32 -arm-global-merge | FileCheck %s --check-prefixes=CHECK-WIN32
56
67 @x = global i32 0, align 4
78 @y = global i32 0, align 4
910
1011 define void @f1(i32 %a1, i32 %a2) {
1112 ;CHECK: f1:
12 ;CHECK: ldr {{r[0-9]+}}, [[LABEL1:\.LCPI[0-9]+_[0-9]]]
13 ;CHECK: ldr {{r[0-9]+}}, [[LABEL1:\.?LCPI[0-9]+_[0-9]]]
1314 ;CHECK: [[LABEL1]]:
1415 ;CHECK-MERGE: .long .L_MergedGlobals
1516 ;CHECK-NO-MERGE: .long {{_?x}}
17 ;CHECK-WIN32: f1:
18 ;CHECK-WIN32: movw [[REG1:r[0-9]+]], :lower16:.L_MergedGlobals
19 ;CHECK-WIN32: movt [[REG1]], :upper16:.L_MergedGlobals
1620 store i32 %a1, i32* @x, align 4
1721 store i32 %a2, i32* @y, align 4
1822 ret void
2024
2125 define void @g1(i32 %a1, i32 %a2) {
2226 ;CHECK: g1:
23 ;CHECK: ldr {{r[0-9]+}}, [[LABEL2:\.LCPI[0-9]+_[0-9]]]
27 ;CHECK: ldr {{r[0-9]+}}, [[LABEL2:\.?LCPI[0-9]+_[0-9]]]
2428 ;CHECK: [[LABEL2]]:
2529 ;CHECK-MERGE: .long .L_MergedGlobals
2630 ;CHECK-NO-MERGE: .long {{_?y}}
31 ;CHECK-WIN32: g1:
32 ;CHECK-WIN32: movw [[REG2:r[0-9]+]], :lower16:.L_MergedGlobals
33 ;CHECK-WIN32: movt [[REG2]], :upper16:.L_MergedGlobals
2734 store i32 %a1, i32* @y, align 4
2835 store i32 %a2, i32* @z, align 4
2936 ret void
3441 ;CHECK-MERGE: .type .L_MergedGlobals,%object
3542 ;CHECK-MERGE: .local .L_MergedGlobals
3643 ;CHECK-MERGE: .comm .L_MergedGlobals,12,4
44 ;CHECK-WIN32: .lcomm .L_MergedGlobals,12,4
3745
3846 ;CHECK-MERGE: .globl x
3947 ;CHECK-MERGE: x = .L_MergedGlobals
4452 ;CHECK-MERGE: .globl z
4553 ;CHECK-MERGE: z = .L_MergedGlobals+8
4654 ;CHECK-MERGE: .size z, 4
55
56 ;CHECK-WIN32: .globl x
57 ;CHECK-WIN32: x = .L_MergedGlobals
58 ;CHECK-WIN32: .globl y
59 ;CHECK-WIN32: y = .L_MergedGlobals+4
60 ;CHECK-WIN32: .globl z
61 ;CHECK-WIN32: z = .L_MergedGlobals+8