[all-commits] [llvm/llvm-project] 115468: [AIX][XCOFF]emit extern linkage for the llvm intri...
diggerlin via All-commits
all-commits at lists.llvm.org
Tue Jul 21 13:04:03 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 11546898e2ffc761acedad887ff00991a9affb62
https://github.com/llvm/llvm-project/commit/11546898e2ffc761acedad887ff00991a9affb62
Author: diggerlin <digger.llvm at gmail.com>
Date: 2020-07-21 (Tue, 21 Jul 2020)
Changed paths:
M llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
M llvm/lib/Target/PowerPC/PPCISelLowering.cpp
M llvm/lib/Target/PowerPC/PPCInstrInfo.td
M llvm/test/CodeGen/PowerPC/aix-cc-byval-mem.ll
M llvm/test/CodeGen/PowerPC/aix-external-sym-sdnode-lowering.ll
A llvm/test/CodeGen/PowerPC/aix-llvm-intrinsic.ll
M llvm/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll
Log Message:
-----------
[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
More information about the All-commits
mailing list