[PATCH] D119967: [InstCombineCalls] Optimize call of bitcast even w/ parameter attributes

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 19 00:35:31 PDT 2022


efriedma added a comment.

In general, the reason we don't just treat calling a bitcast as instant UB is that we want to avoid breaking cases where different signatures represent equivalent calls, but the IR types aren't compatible.  We don't have any standard rule for lowering C calls to IR, so different language frontends might do slightly different things.

Along those lines, some attributes hide significant differences in how the call is actually lowered; for example, byval means that a "pointer" isn't really a pointer at all.  Some attributes are obviously irrelevant, like noundef.

Going through the LangRef list, zeroext/signext/inreg/sret/nest/swiftself/swiftasync/swifterror are the parameter attributes which this code currently doesn't explicitly check for, but are ABI significant.  But... given the motivation, they're unlikely to be relevant, I guess?  If there's a mismatch, and the call otherwise passes the checks, the untransformed call is probably UB anyway.

That said, I don't really want to try to write up a coherent justification for each of those, or worry about attributes that will be implemented in the future.  An explicit list of attributes which are obviously safe to drop would be much simpler to reason about.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119967



More information about the llvm-commits mailing list