2017-05-14 32 views
1

我有(人類可讀的)LLVM位碼文件Input.ll內部SyS_sendto的以下函數定義:LLVM選擇-always內聯通不內聯

; 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一個呼叫應在選擇傳球被內聯 -always內聯

; 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 
} 

任何幫助非常感謝!謝謝!

回答