'llvm IR use functions in libc
How does llvm IR use functions in libc, such as open socket, etc. is there a specific example,How does llvm IR use functions in libc, such as open socket, etc. is there a specific example,How does llvm IR use functions in libc, such as open socket, etc. is there a specific example,How does llvm IR use functions in libc, such as open socket, etc. is there a specific example
Solution 1:[1]
LLVM IR allows calls to functions by name. Just like in C the function must be declared. In LLVM IR, the syntax looks like:
;; Sample declaration of a function in libc.
declare i32 @strlen(i8*)
;; Test code using it.
define i32 @test(i8* %a, i8* %b) {
%A = call i32 @strlen(i8* %a)
%B = call i32 @strlen(i8* %b)
%c = add i32 %A, %B
ret i32 %c
}
You can always take a look at the textual LLVM IR generated by clang for any given C code. clang -S -emit-llvm client.c -o client.ll -O1 to produce client.ll with light optimization.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nick Lewycky |
