[PATCH] D101725: [Verifier] Check that calls' arguments match the callee's byval/inalloca/preallocated

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 3 13:15:24 PDT 2021


rnk added a comment.

I need more time to read into this, but my first thought is, we can't do this. People can write code that does stuff like:

  struct Byval { int x; } bv;
  void takeByval(Byval);
  void foo(bool isByRef, void (*fp)()) {
    if (isByRef) {  ((void(*)(ByVal*))fp)(&bv); }
    else { ((void(*)(ByVal))fp)(bv); }
  }
  void bar() {
    foo(false, &takeByval);
  }

Inlining foo into bar and simplifying would lead to a verifier failure, no?

This is for example why the verifier doesn't check that calling conventions match:
https://llvm.org/docs/FAQ.html#why-does-instcombine-simplifycfg-turn-a-call-to-a-function-with-a-mismatched-calling-convention-into-unreachable-why-not-make-the-verifier-reject-it


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101725/new/

https://reviews.llvm.org/D101725



More information about the llvm-commits mailing list