[PATCH] D103288: [SanCov] Properly set ABI parameter attributes

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 4 12:39:29 PDT 2021


rnk added a comment.

OK, right, the issue we were trying to solve is that LLVM was crashing when byval (+inalloca, etc) types mismatched somehow.

It occurs to me that, in a world of typeless pointers, it is possible that the function type used by the call may not match the prototype of the callee. Consider something like this:

  define dso_local void @pass_int() #0 {
  entry:
    call void bitcast (void (i32*)* @use_int to void (i32)*)(i32 0)
    ret void
  }
  declare dso_local void @use_int(i32* byval(i32)) #1

With opaque pointers, we lose the bitcast, so the call may appear to be direct, but the prototypes do not match. If the prototypes don't match, the attribute lists may not even correspond. In this case, the argument we are passing to a byval parameter isn't even a pointer. I don't know how the codegenerator would handle that.

We may need to teach CallBase::getCallee to do more than just dyn_cast, maybe it should check that the function prototypes match, and the call will be considered indirect otherwise. Is this a known issue, or something new?

If the prototypes do match, then I think it is OK to look at ABI attributes on the declaration of the callee. In the case of byval, LLVM would get the type from the declaration and use that. The caller would have only a typeless pointer argument anyway, which has no information about the underlying value to be passed.

The other option is that we compromise and allow codegen to look at the callee only for some kinds of ABI attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103288



More information about the llvm-commits mailing list