[PATCH] Verify that personality functions are actually functions

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 11:06:00 PDT 2015


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.

Philip

On 08/29/2015 08:56 AM, David Blaikie wrote:
> 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.
>
> (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...)
>
> On Fri, Aug 28, 2015 at 5:33 PM, Pete Cooper via llvm-commits 
> <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
>
>     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) {
>     constFunction*F = dyn_cast<Function>(Pers->stripPointerCasts());
>     if (!F)
>     returnEHPersonality::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
>
>
>
>     _______________________________________________
>     llvm-commits mailing list
>     llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
>     http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150831/2e82fd32/attachment.html>


More information about the llvm-commits mailing list