[llvm-dev] (no subject)
Alberto Barbaro via llvm-dev
llvm-dev at lists.llvm.org
Sun Jan 20 01:48:57 PST 2019
Hi all,
I have the following C code:
#include<stdio.h>
int main(int argc, char *argv[]) {
printf("%s\n", argv[0]);
return argc;
}
that generates the following IR for the main function:
; Function Attrs: noinline nounwind optnone uwtable
define i32 @main(i32, i8**) #0 {
%3 = alloca i32, align 4
%4 = alloca i32, align 4
%5 = alloca i8**, align 8
store i32 0, i32* %3, align 4
store i32 %0, i32* %4, align 4
store i8** %1, i8*** %5, align 8
%6 = load i8**, i8*** %5, align 8
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7, align 8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4
x i8]* @.str, i32 0, i32 0), i8* %8)
%10 = load i32, i32* %4, align 4
ret i32 %10
}
I think %8 will contain the address of argv[0], so %7 was storing a pointer
to pointer to argv? I'm not sure of that.
Considering that I can access the GenericValue set by
visitGetElementPtrInst. How can I obtain the value of argv[0] at runtime
using the Interpreter class?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190120/949253e7/attachment.html>
More information about the llvm-dev
mailing list