我在(人类可读的) LLVM bitcode文件Input.ll中定义了以下Input.ll函数:
; Function Attrs: alwaysinline noredzone nounwind
define i64 @SyS_sendto(
i64 %fd, i64 %buff, i64 %len, i64 %flags, i64 %addr, i64 %addr_len) #0 {在该文件的末尾,属性#0 包含单词alwaysinline
attributes #0 = { alwaysinline noredzone nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }在Input.ll的某个地方,有一个对SyS_sendto的调用,即应该在opt pass中内联--总是内联的。
; Function Attrs: noredzone nounwind
define i64 @GO(i64 %fd, i64 %buff, i64 %len, i64 %flags) #0 {
%1 = trunc i64 %fd to i32
%2 = inttoptr i64 %buff to i8*
%3 = trunc i64 %flags to i32
%4 = tail call i64 bitcast
(i64 (i64, i64, i64, i64, i64, i64)*
@SyS_sendto to i64
(i32, i8*, i64, i32, %struct.sockaddr*, i32)*)
(i32 %1,
i8* %2,
i64 %len,
i32 %3,
%struct.sockaddr* null,
i32 0) #0
ret i64 %4
}我跑:
llvm-as -o=Input.bc Input.ll
opt -always-inline Input.bc -o InlinedInput.bc
llvm-dis -o=InlinedInput.ll InlinedInput.bc但是GO已经改变了而不是,我也看到了对InputInlined.ll的SyS_sendto的调用.这是而不是的内联:
; Function Attrs: noredzone nounwind
define i64 @GO(i64 %fd, i64 %buff, i64 %len, i64 %flags) #0 {
%1 = trunc i64 %fd to i32
%2 = inttoptr i64 %buff to i8*
%3 = trunc i64 %flags to i32
%4 = tail call i64 bitcast
(i64 (i64, i64, i64, i64, i64, i64)*
@SyS_sendto to i64
(i32, i8*, i64, i32, %struct.sockaddr*, i32)*)
(i32 %1,
i8* %2,
i64 %len,
i32 %3,
%struct.sockaddr* null,
i32 0) #0
ret i64 %4
}任何帮助都是非常感谢的!谢谢!
发布于 2017-05-14 16:35:52
在您的示例中,对@SyS_sendto的调用是一个间接调用的实例(由于bitcast表达式),LLVM当前对这些调用进行了不支持内联。
您可以跟踪关于邮件列表的讨论 (2015年),也可以登录源代码。
https://stackoverflow.com/questions/43961282
复制相似问题