forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AIX][XCOFF]emit extern linkage for the llvm intrinsic symbol
SUMMARY: when we call memset, memcopy,memmove etc(this are llvm intrinsic function) in the c source code. the llvm will generate IR like call call void @llvm.memset.p0i8.i32(i8* align 4 bitcast (%struct.S* @s to i8*), i8 %1, i32 %2, i1 false) for c source code bash> cat test_memset.call struct S{ int a; int b; }; extern struct S s; void bar() { memset(&s, s.b, s.b); } like %struct.S = type { i32, i32 } @s = external global %struct.S, align 4 ; Function Attrs: noinline nounwind optnone define void @bar() #0 { entry: %0 = load i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i32 0, i32 1), align 4 %1 = trunc i32 %0 to i8 %2 = load i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i32 0, i32 1), align 4 call void @llvm.memset.p0i8.i32(i8* align 4 bitcast (%struct.S* @s to i8*), i8 %1, i32 %2, i1 false) ret void } declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1 immarg) #1 If we want to let the aix as assembly compile pass without -u it need to has following assembly code. .extern .memset (we do not output extern linkage for llvm instrinsic function. even if we output the extern linkage for llvm intrinsic function, we should not out .extern llvm.memset.p0i8.i32, instead of we should emit .extern memset) for other llvm buildin function floatdidf . even if we do not call these function floatdidf in the c source code(the generated IR also do not the call __floatdidf . the function call was generated in the LLVM optimized. the function is not in the functions list of Module, but we still need to emit extern .__floatdidf The solution for it as : We record all the lllvm intrinsic extern symbol when transformCallee(), and emit all these symbol in the AsmPrinter::doFinalization(Module &M) Reviewers: jasonliu, Sean Fertile, hubert.reinterpretcast, Differential Revision: https://reviews.llvm.org/D78929
- Loading branch information
diggerlin
committed
Jul 21, 2020
1 parent
73bc23f
commit 1154689
Showing
7 changed files
with
168 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 -mattr=-altivec < %s | \ | ||
; RUN: FileCheck %s | ||
|
||
; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 -mattr=-altivec < %s | \ | ||
; RUN: FileCheck %s | ||
|
||
; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ | ||
; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s | ||
; RUN: llvm-readobj --symbols %t.o | FileCheck --check-prefix=CHECKSYM %s | ||
; RUN: llvm-objdump -r -d --symbol-description %t.o | FileCheck --check-prefix=CHECKRELOC %s | ||
|
||
; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff \ | ||
; RUN: -mattr=-altivec -filetype=obj -o %t.o 2>&1 < %s | \ | ||
; RUN: FileCheck --check-prefix=XCOFF64 %s | ||
; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. | ||
|
||
%struct.S = type { i32, i32 } | ||
|
||
@s = external global %struct.S, align 4 | ||
|
||
define void @bar() { | ||
entry: | ||
%0 = load i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i32 0, i32 1), align 4 | ||
%1 = trunc i32 %0 to i8 | ||
%2 = load i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i32 0, i32 1), align 4 | ||
call void @llvm.memset.p0i8.i32(i8* align 4 bitcast (%struct.S* @s to i8*), i8 %1, i32 %2, i1 false) | ||
ret void | ||
} | ||
|
||
declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1 immarg) | ||
|
||
; CHECK-LABEL: .bar: | ||
; CHECK-NEXT: # %bb.0: # %entry | ||
; CHECK-NEXT: mflr 0 | ||
|
||
; CHECK: bl .memset | ||
|
||
; CHECK: .extern .memset | ||
|
||
; CHECKSYM: Symbol { | ||
; CHECKSYM-NEXT: Index: 0 | ||
; CHECKSYM-NEXT: Name: .memset | ||
; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 | ||
; CHECKSYM-NEXT: Section: N_UNDEF | ||
; CHECKSYM-NEXT: Type: 0x0 | ||
; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) | ||
; CHECKSYM-NEXT: NumberOfAuxEntries: 1 | ||
; CHECKSYM-NEXT: CSECT Auxiliary Entry { | ||
; CHECKSYM-NEXT: Index: 1 | ||
; CHECKSYM-NEXT: SectionLen: 0 | ||
; CHECKSYM-NEXT: ParameterHashIndex: 0x0 | ||
; CHECKSYM-NEXT: TypeChkSectNum: 0x0 | ||
; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 | ||
; CHECKSYM-NEXT: SymbolType: XTY_ER (0x0) | ||
; CHECKSYM-NEXT: StorageMappingClass: XMC_PR (0x0) | ||
; CHECKSYM-NEXT: StabInfoIndex: 0x0 | ||
; CHECKSYM-NEXT: StabSectNum: 0x0 | ||
; CHECKSYM-NEXT: } | ||
; CHECKSYM-NEXT: } | ||
|
||
; CHECKRELOC: 00000000 (idx: 6) .bar: | ||
; CHECKRELOC-NEXT: 0: 7c 08 02 a6 mflr 0 | ||
; CHECKRELOC-NEXT: 4: 90 01 00 08 stw 0, 8(1) | ||
; CHECKRELOC-NEXT: 8: 94 21 ff c0 stwu 1, -64(1) | ||
; CHECKRELOC-NEXT: c: 80 62 00 00 lwz 3, 0(2) | ||
; CHECKRELOC-NEXT: 0000000e: R_TOC (idx: 12) s[TC] | ||
; CHECKRELOC-NEXT: 10: 80 83 00 04 lwz 4, 4(3) | ||
; CHECKRELOC-NEXT: 14: 7c 85 23 78 mr 5, 4 | ||
; CHECKRELOC-NEXT: 18: 4b ff ff e9 bl 0x0 | ||
; CHECKRELOC-NEXT: 00000018: R_RBR (idx: 0) .memset[PR] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters