<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">I think this question should be moved
      to llvm-dev.  David's point is completely reasonable, but I think
      we generally assume personality functions are functions today. 
      I'd be tempted to modify the verifier as Pete suggests, but we
      should get broader input before actually doing so.  Given how
      vague the LangRef is today, restricting personality functions to
      be direct calls could be construed as a LangRef change.<br>
      <br>
      Philip<br>
      <br>
      On 08/29/2015 08:56 AM, David Blaikie wrote:<br>
    </div>
    <blockquote
cite="mid:CAENS6EuLprP_eFQ9tisNAQ+b3Pag+_CUhZ-DMky5KKQ6n-LcpA@mail.gmail.com"
      type="cite">
      <div dir="ltr">Knowing nothing about any of this stuff, I do find
        this a bit surprising - usually values are opaque to their
        consumers: they're just a value.<br>
        <br>
        (especially with pointer bitcasts (which will go away,
        eventually) - if I have a global variable I've put some
        executable bytes in and I cast a pointer to that global variable
        to a pointer to a function, I would expect that should be
        interchangeable...)</div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, Aug 28, 2015 at 5:33 PM, Pete
          Cooper via llvm-commits <span dir="ltr"><<a
              moz-do-not-send="true"
              href="mailto:llvm-commits@lists.llvm.org" target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a></a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div style="word-wrap:break-word">Hi Philip
              <div><br>
              </div>
              <div>While reducing a test case with personality
                functions, I crashed selection DAG.  The reason being
                that my personality function was no longer a function. 
                The relevant code is</div>
              <div><br>
              </div>
              <div>  MF->getMMI().addPersonality(MBB, cast<Function>(LPadInst->getParent()<br>
                                                                   
                  ->getParent()<br>
                                                                   
                  ->getPersonalityFn()<br>
                                                                   
                  ->stripPointerCasts()));</div>
              <div><br>
              </div>
              <div>We get different behavior in this code, which is able
                to handle non-function personality functions.</div>
              <div><br>
              </div>
              <div>
                <div
                  style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span
                    style="color:#4f8187">EHPersonality</span> <span
                    style="color:#703daa">llvm</span>::classifyEHPersonality(<span
                    style="color:#bb2ca2">const</span> <span
                    style="color:#4f8187">Value</span> *Pers) {</div>
                <div
style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(49,89,93)"><span
                    style="color:#000000">  </span><span
                    style="color:#bb2ca2">const</span><span
                    style="color:#000000"> </span><span
                    style="color:#4f8187">Function</span><span
                    style="color:#000000"> *F = </span>dyn_cast<span
                    style="color:#000000"><</span><span
                    style="color:#4f8187">Function</span><span
                    style="color:#000000">>(Pers-></span>stripPointerCasts<span
                    style="color:#000000">());</span></div>
                <div
                  style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> 
                  <span style="color:#bb2ca2">if</span> (!F)</div>
                <div
style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)"><span
                    style="color:#000000">    </span><span
                    style="color:#bb2ca2">return</span><span
                    style="color:#000000"> </span>EHPersonality<span
                    style="color:#000000">::</span><span
                    style="color:#31595d">Unknown</span><span
                    style="color:#000000">;</span></div>
              </div>
              <div><br>
              </div>
              <div>And finally, LangRef itself implies that its a
                function as it says that we should 'specify what
                function to use for exception handling’.</div>
              <div><br>
              </div>
              <div>So i’m not sure exactly what behavior we want.</div>
              <div><br>
              </div>
              <div>However, assuming we do want personality functions to
                always actually be functions (which was what i
                originally thought we wanted), here’s a patch which
                teaches the verifier this.</div>
              <div><br>
              </div>
              <div>Comments welcome, including the possibility that this
                is completely wrong and that we do want to support other
                values as personalities.</div>
              <div><br>
              </div>
              <div>Cheers</div>
              <span class="HOEnZb"><font color="#888888">
                  <div>Pete</div>
                  <div><br>
                  </div>
                </font></span></div>
            <br>
            <br>
            _______________________________________________<br>
            llvm-commits mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
            <a moz-do-not-send="true"
              href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits"
              rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>