IR: make getParamByValType Just Work. NFC.

Most parts of LLVM don't care whether the byval type is derived from an
explicit Attribute or from the parameter's pointee type, so it makes
sense for the main access function to just return the right value.

The very few users who do care (only BitcodeReader so far) can find out
how it's specified by accessing the Attribute directly.

llvm-svn: 362642
This commit is contained in:
Tim Northover
2019-06-05 20:37:47 +00:00
parent 4fb580c314
commit 607c8a9d14
8 changed files with 24 additions and 9 deletions

View File

@@ -3049,7 +3049,8 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
// pointee type. There should be no opaque pointers where the byval type is
// implicit.
for (auto &Arg : Func->args()) {
if (Arg.hasByValAttr() && !Arg.getParamByValType()) {
if (Arg.hasByValAttr() &&
!Arg.getAttribute(Attribute::ByVal).getValueAsType()) {
Arg.removeAttr(Attribute::ByVal);
Arg.addAttr(Attribute::getWithByValType(
Context, Arg.getType()->getPointerElementType()));