[llvm-dev] A problem about LLVM IR
James Molloy via llvm-dev
llvm-dev at lists.llvm.org
Tue Dec 15 00:37:25 PST 2015
Hi Lei,
You want It->isDeclaration(). It will return true for "declare" and false
for "define".
Cheers,
James
On Tue, 15 Dec 2015 at 08:01 Lei Wang via llvm-dev <llvm-dev at lists.llvm.org>
wrote:
> Hello,
> When I process a LLBM IR(hello.bc), how can I distinguish the "define"
> function from "declare" function in the IR likes blow:
>
> define i32 @main() ssp {
> entry:
> %retval = alloca i32
> %0 = alloca i32
> %"alloca point" = bitcast i32 0 to i32
> %1 = call i32 @puts(i8* getelementptr inbounds ([13 x i8]* @.str, i64 0, i64 0))
> store i32 0, i32* %0, align 4
> %2 = load i32* %0, align 4
> store i32 %2, i32* %retval, align 4
> br label %return
> return:
> %retval1 = load i32* %retval
> ret i32 %retval1
> }
>
> declare i32 @puts(i8*)
>
> when i write a pass as blow, it print both "main" and "puts", now I only
> want to get the "define" function(main) but not "declare" function(puts),
> what can I do to complish my work?
>
> Module::iterator It = _Module->begin(), Ite = _Module->end();
> for(; It != Ite; ++It)
> {
> errs()<<It->getName()<<"\n";
> }
>
>
> Thx.
>
> --WangLei (BUPT)
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151215/f359cd08/attachment.html>
More information about the llvm-dev
mailing list