summaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/X86/mingw-comdats.ll
blob: 2e9ebd8c9fc4c4bab3a5e0dc92bfe877eb1bffca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
; RUN: llc -mtriple=x86_64-windows-itanium < %s | FileCheck %s
; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU
; RUN: llc -mtriple=i686-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU32
; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - -headers | FileCheck %s --check-prefix=GNUOBJ

; GCC and MSVC handle comdats completely differently. Make sure we do the right
; thing for each.

; Generated with this C++ source:
; int bar(int);
; __declspec(selectany) int gv = 42;
; inline int foo(int x) { return bar(x) + gv; }
; int main() { return foo(1); }

$_Z3fooi = comdat any

$gv = comdat any

@gv = weak_odr dso_local global i32 42, comdat, align 4

; Function Attrs: norecurse uwtable
define dso_local i32 @main() #0 {
entry:
  %call = tail call i32 @_Z3fooi(i32 1)
  ret i32 %call
}

; CHECK: main:
; GNU: main:

; Function Attrs: inlinehint uwtable
define linkonce_odr dso_local i32 @_Z3fooi(i32 %x) #1 comdat {
entry:
  %call = tail call i32 @_Z3bari(i32 %x)
  %0 = load i32, i32* @gv, align 4
  %add = add nsw i32 %0, %call
  ret i32 %add
}

; CHECK: .section        .text,"xr",discard,_Z3fooi
; CHECK: _Z3fooi:
; CHECK: .section        .data,"dw",discard,gv
; CHECK: gv:
; CHECK: .long 42

; GNU: .section        .text$_Z3fooi,"xr",discard,_Z3fooi
; GNU: _Z3fooi:
; GNU: .section        .data$gv,"dw",discard,gv
; GNU: gv:
; GNU: .long 42

; GNU32: .section        .text$__Z3fooi,"xr",discard,__Z3fooi
; GNU32: __Z3fooi:
; GNU32: .section        .data$_gv,"dw",discard,_gv
; GNU32: _gv:
; GNU32: .long 42


; Make sure the assembler puts the .xdata and .pdata in sections with the right
; names.
; GNUOBJ: .text$_Z3fooi
; GNUOBJ: .xdata$_Z3fooi
; GNUOBJ: .data$gv
; GNUOBJ: .pdata$_Z3fooi

declare dso_local i32 @_Z3bari(i32)

attributes #0 = { norecurse uwtable }
attributes #1 = { inlinehint uwtable }