<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Most LLVM IR instructions have a result field, according to the
    Language Reference.<br>
    <br>
    I want to know, for all LLVM Instructions, is there an easy and
    consistent way to know if the current Inst has a result field?<br>
    And if yes, what is the best way to obtain it?<br>
    <br>
    E.g.:<br>
    <br>
    <span class="Apple-style-span" style="border-collapse: separate;
      color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style:
      normal; font-variant: normal; font-weight: normal; letter-spacing:
      normal; line-height: normal; orphans: 2; text-indent: 0px;
      text-transform: none; white-space: normal; widows: 2;
      word-spacing: 0px; font-size: medium;"><span
        class="Apple-style-span" style="text-align: left;">
        <pre>  <result> = add <ty> <op1>, <op2>          <i>; yields {ty}:result

</i></pre>
      </span></span>All ADD instruction will have a result field,
    regardless of whether its result is used.<br>
    <br>
    I checked the source code for Instruction.h/.cpp, getOperand(int) is
    for obtaining the operands only. There is no dedicated method to
    obtain the result.<br>
    {I was expecting something like Instruction->getResult().}<br>
    <br>
    <br>
    Instruction * Inst;<br>
    ...<br>
    Value * Res = Inst;<br>
    <br>
    Is the above the right way to do the work?<br>
    <br>
    For an other example:<br>
    <br>
    <span class="Apple-style-span" style="border-collapse: separate;
      color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style:
      normal; font-variant: normal; font-weight: normal; letter-spacing:
      normal; line-height: normal; orphans: 2; text-indent: 0px;
      text-transform: none; white-space: normal; widows: 2;
      word-spacing: 0px; font-size: medium;"><span
        class="Apple-style-span" style="text-align: left;">
        <pre> <result> = [tail] call [<a href="http://llvm.org/docs/LangRef.html#callingconv">cconv</a>] [<a href="http://llvm.org/docs/LangRef.html#paramattrs">ret attrs</a>] <ty> [<fnty>*] <fnptrval>(<function args>) [<a href="http://llvm.org/docs/LangRef.html#fnattrs">fn attrs</a>]</pre>
      </span></span><br>
    According to the LLVM Language reference, CallInst should always
    have a result.<br>
    But for void bar(int) types, there will be no return. So the
    generated IR will be similar to:<br>
    <pre wrap="">  call void @bar(i32 %2) nounwind

instead of
</pre>
    <pre wrap="">  %3 = call void @bar(i32 %2) nounwind
</pre>
    How can I handle this or similar case?<br>
    <br>
    Are there special handling for certain Instructions? (E.g. LoadInst,
    StoreInst, etc.)<br>
    <br>
    Thank you very much<br>
    <br>
    Chuck<br>
    <br>
    <br>
    <br>
    <br>
  </body>
</html>