[PATCH] Verify that personality functions are actually functions

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 17:33:14 PDT 2015


Hi Philip

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

  MF->getMMI().addPersonality(MBB, cast<Function>(LPadInst->getParent()
                                                      ->getParent()
                                                      ->getPersonalityFn()
                                                      ->stripPointerCasts()));

We get different behavior in this code, which is able to handle non-function personality functions.

EHPersonality llvm::classifyEHPersonality(const Value *Pers) {
  const Function *F = dyn_cast<Function>(Pers->stripPointerCasts());
  if (!F)
    return EHPersonality::Unknown;

And finally, LangRef itself implies that its a function as it says that we should 'specify what function to use for exception handling’.

So i’m not sure exactly what behavior we want.

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.

Comments welcome, including the possibility that this is completely wrong and that we do want to support other values as personalities.

Cheers
Pete

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150828/50c69959/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: personality.patch
Type: application/octet-stream
Size: 11081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150828/50c69959/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150828/50c69959/attachment-0001.html>


More information about the llvm-commits mailing list