[llvm-dev] A problem about LLVM IR

Lei Wang via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 15 00:00:34 PST 2015


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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151215/e215f587/attachment.html>


More information about the llvm-dev mailing list