I use Clang as a library to create some LLVM IR modules.
Here is the source code of the module:
inline int getSevenInline() {
return 7;
}
int getSeven() {
return getSevenInline();
}
I would expect the LLVM IR module to contain one function getSeventhat returns 7.
Here is the LLVM IR that my program generates:
; ModuleID = './test.cpp'
source_filename = "./test.cpp"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.12.0"
; Function Attrs: noinline ssp uwtable
define i32 @_Z8getSevenv()
entry:
%call = call i32 @_Z14getSevenInlinev()
ret i32 %call
}
declare i32 @_Z14getSevenInlinev()
attributes
attributes
When I try to execute a module, it cannot resolve the character to getSevenInline.
IR seems wrong in two ways:
- A function
getSevenInlinemust not exist because it must be inlined - Despite the fact that it is not built-in, it
getSevenInlinedoes not have an implementation
What should I configure on mine clang::CompilerInstanceso that it compiles functions correctly inline?
inline; -inline .
, , IR, , - Clang.