[llvm-dev] Zero-extending function parameters on x86_64
Alexander Potapenko via llvm-dev
llvm-dev at lists.llvm.org
Tue Jul 11 06:02:09 PDT 2017
Yesterday we've noticed (https://bugs.llvm.org/show_bug.cgi?id=33732)
that on x86_64 a function declaration created by getOrInsertFunction()
must set the zeroext attribute for each parameter that is smaller than
Failing to do so may result in LLVM passing garbage in the upper bits
of the registers instead of zeroing them out in the caller. In some
cases the garbage may be passed on from the called function.
I've started going through sanitizer instrumentation passes and
noticed some of them also declare functions with e.g. i32 parameters
lacking the zeroext attribute. There also are other LLVM passes that
don't set the zeroext attribute for function parameters.
I find this a little counterintuitive that every user of
getOrInsertFunction() should think about whatever possible ABI
conventions and opt-in into the zeroext attribute.
Is it feasible to make getOrInsertFunction() take care of this
automatically depending on the target?
Google Germany GmbH
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
More information about the llvm-dev