xref: /llvm-project/llvm/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll (revision b1acb7a315e903ee340a33dbc9b2b61b0450bb67)
1; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
2; RUN:   -mattr=-altivec -filetype=obj -xcoff-traceback-table=false -o %t.o < %s
3
4; RUN: llvm-readobj --syms %t.o | FileCheck -D#NFA=2 --check-prefix=32-SYM %s
5
6; RUN: llvm-readobj --relocs --expand-relocs %t.o | FileCheck -D#NFA=2 \
7; RUN:   --check-prefix=32-REL %s
8
9; RUN: llvm-objdump -D %t.o | FileCheck -D#NFA=2 --check-prefix=32-DIS %s
10
11; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff \
12; RUN:   -mcpu=pwr4 -mattr=-altivec < %s | FileCheck %s
13
14;; FIXME: currently only fileHeader and sectionHeaders are supported in XCOFF64.
15
16; Test verifies:
17; If there exists a user-defined function whose name is the same as the
18; "memcpy" ExternalSymbol's, we pick up the user-defined version, even if this
19; may lead to some undefined behavior.
20
21define dso_local signext i32 @memcpy(ptr %destination, i32 signext %num) {
22entry:
23  ret i32 3
24}
25
26define void @call_memcpy(ptr %p, ptr %q, i32 %n) {
27entry:
28  call void @llvm.memcpy.p0.p0.i32(ptr %p, ptr %q, i32 %n, i1 false)
29  ret void
30}
31
32declare void @llvm.memcpy.p0.p0.i32(ptr nocapture writeonly, ptr nocapture readonly, i32, i1)
33
34; This test check
35; 1. The symbol table for .o file to verify .memcpy is a defined external label.
36; 2. There is no relocation associated with the call, since callee is defined.
37; 3. Branch instruction in raw data is branching back to the right callee location.
38
39; CHECK-NOT: .extern .memcpy
40
41; 32-SYM:      Symbol {{[{][[:space:]] *}}Index: [[#Index:]]{{[[:space:]] *}}Name: .___memmove
42; 32-SYM-NEXT:    Value (RelocatableAddress): 0x0
43; 32-SYM-NEXT:    Section: N_UNDEF
44; 32-SYM-NEXT:    Type: 0x0
45; 32-SYM-NEXT:    StorageClass: C_EXT (0x2)
46; 32-SYM-NEXT:    NumberOfAuxEntries: 1
47; 32-SYM-NEXT:    CSECT Auxiliary Entry {
48; 32-SYM-NEXT:      Index: [[#NFA+2]]
49; 32-SYM-NEXT:      SectionLen: 0
50; 32-SYM-NEXT:      ParameterHashIndex: 0x0
51; 32-SYM-NEXT:      TypeChkSectNum: 0x0
52; 32-SYM-NEXT:      SymbolAlignmentLog2: 0
53; 32-SYM-NEXT:      SymbolType: XTY_ER (0x0)
54; 32-SYM-NEXT:      StorageMappingClass: XMC_PR (0x0)
55; 32-SYM-NEXT:      StabInfoIndex: 0x0
56; 32-SYM-NEXT:      StabSectNum: 0x0
57; 32-SYM-NEXT:    }
58; 32-SYM-NEXT:  }
59
60; 32-SYM:      Symbol {{[{][[:space:]] *}}Index: [[#Index:]]{{[[:space:]] *}}Name: .memcpy
61; 32-SYM-NEXT:    Value (RelocatableAddress): 0x0
62; 32-SYM-NEXT:    Section: .text
63; 32-SYM-NEXT:    Type: 0x0
64; 32-SYM-NEXT:    StorageClass: C_EXT (0x2)
65; 32-SYM-NEXT:    NumberOfAuxEntries: 1
66; 32-SYM-NEXT:    CSECT Auxiliary Entry {
67; 32-SYM-NEXT:      Index: [[#NFA+6]]
68; 32-SYM-NEXT:      ContainingCsectSymbolIndex: [[#NFA+3]]
69; 32-SYM-NEXT:      ParameterHashIndex: 0x0
70; 32-SYM-NEXT:      TypeChkSectNum: 0x0
71; 32-SYM-NEXT:      SymbolAlignmentLog2: 0
72; 32-SYM-NEXT:      SymbolType: XTY_LD (0x2)
73; 32-SYM-NEXT:      StorageMappingClass: XMC_PR (0x0)
74; 32-SYM-NEXT:      StabInfoIndex: 0x0
75; 32-SYM-NEXT:      StabSectNum: 0x0
76; 32-SYM-NEXT:    }
77; 32-SYM-NEXT:  }
78
79; 32-SYM-NOT: .memcpy
80
81; 32-REL:      Relocations [
82; 32-REL-NEXT:  Section (index: 1) .text {
83; 32-REL-NEXT:  Relocation {
84; 32-REL-NEXT:    Virtual Address: 0x1C
85; 32-REL-NEXT:    Symbol: .___memmove ([[#NFA+1]])
86; 32-REL-NEXT:    IsSigned: Yes
87; 32-REL-NEXT:    FixupBitValue: 0
88; 32-REL-NEXT:    Length: 26
89; 32-REL-NEXT:    Type: R_RBR (0x1A)
90; 32-REL-NEXT:  }
91; 32-REL-NEXT:}
92; 32-REL-NEXT:  Section (index: 2) .data {
93; 32-REL-NEXT:  Relocation {
94; 32-REL-NEXT:    Virtual Address: 0x34
95; 32-REL-NEXT:    Symbol: .memcpy ([[#NFA+5]])
96; 32-REL-NEXT:    IsSigned: No
97; 32-REL-NEXT:    FixupBitValue: 0
98; 32-REL-NEXT:    Length: 32
99; 32-REL-NEXT:    Type: R_POS (0x0)
100; 32-REL-NEXT:  }
101; 32-REL-NEXT:  Relocation {
102; 32-REL-NEXT:    Virtual Address: 0x38
103; 32-REL-NEXT:    Symbol: TOC ([[#NFA+13]])
104; 32-REL-NEXT:    IsSigned: No
105; 32-REL-NEXT:    FixupBitValue: 0
106; 32-REL-NEXT:    Length: 32
107; 32-REL-NEXT:    Type: R_POS (0x0)
108; 32-REL-NEXT:  }
109; 32-REL-NEXT:  Relocation {
110; 32-REL-NEXT:    Virtual Address: 0x40
111; 32-REL-NEXT:    Symbol: .call_memcpy ([[#NFA+7]])
112; 32-REL-NEXT:    IsSigned: No
113; 32-REL-NEXT:    FixupBitValue: 0
114; 32-REL-NEXT:    Length: 32
115; 32-REL-NEXT:    Type: R_POS (0x0)
116; 32-REL-NEXT:  }
117; 32-REL-NEXT:  Relocation {
118; 32-REL-NEXT:    Virtual Address: 0x44
119; 32-REL-NEXT:    Symbol: TOC ([[#NFA+13]])
120; 32-REL-NEXT:    IsSigned: No
121; 32-REL-NEXT:    FixupBitValue: 0
122; 32-REL-NEXT:    Length: 32
123; 32-REL-NEXT:    Type: R_POS (0x0)
124; 32-REL-NEXT:  }
125; 32-REL-NEXT:  }
126; 32-REL-NEXT: ]
127
128; 32-REL-NOT:  Type: R_RBR (0x1A)
129
130; 32-DIS:      Disassembly of section .text:
131; 32-DIS:      00000000 <.memcpy>:
132; 32-DIS-NEXT:        0: 38 60 00 03                   li 3, 3
133; 32-DIS-NEXT:        4: 4e 80 00 20                   blr
134; 32-DIS-NEXT:        8: 60 00 00 00                   nop
135; 32-DIS-NEXT:        c: 60 00 00 00                   nop
136; 32-DIS:      00000010 <.call_memcpy>:
137; 32-DIS-NEXT:       10: 7c 08 02 a6                   mflr 0
138; 32-DIS-NEXT:       14: 94 21 ff c0                   stwu 1, -64(1)
139; 32-DIS-NEXT:       18: 90 01 00 48                   stw 0, 72(1)
140; 32-DIS-NEXT:       1c: 4b ff ff e5                   bl 0x0
141; 32-DIS-NEXT:       20: 60 00 00 00                   nop
142; 32-DIS-NEXT:       24: 38 21 00 40                   addi 1, 1, 64
143; 32-DIS-NEXT:       28: 80 01 00 08                   lwz 0, 8(1)
144; 32-DIS-NEXT:       2c: 7c 08 03 a6                   mtlr 0
145; 32-DIS-NEXT:       30: 4e 80 00 20                   blr
146