diff options
author | Tim Northover <tnorthover@apple.com> | 2019-05-30 18:48:23 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2019-05-30 18:48:23 +0000 |
commit | b7141207a483d39b99c2b4da4eb3bb591eca9e1a (patch) | |
tree | 17be3c9e9f0ba7f9493e2279d5df0e029533d910 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | 7fecdf36cc5b41dc5ad85d58c6e3b97b4fce6d00 (diff) | |
download | llvm-b7141207a483d39b99c2b4da4eb3bb591eca9e1a.zip llvm-b7141207a483d39b99c2b4da4eb3bb591eca9e1a.tar.gz llvm-b7141207a483d39b99c2b4da4eb3bb591eca9e1a.tar.bz2 |
Reapply: IR: add optional type to 'byval' function parameters
When we switch to opaque pointer types we will need some way to describe
how many bytes a 'byval' parameter should occupy on the stack. This adds
a (for now) optional extra type parameter.
If present, the type must match the pointee type of the argument.
The original commit did not remap byval types when linking modules, which broke
LTO. This version fixes that.
Note to front-end maintainers: if this causes test failures, it's probably
because the "byval" attribute is printed after attributes without any parameter
after this change.
llvm-svn: 362128
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 8e1e062..d243815 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -747,7 +747,7 @@ void ModuleBitcodeWriter::writeAttributeGroupTable() { Record.push_back(1); Record.push_back(getAttrKindEncoding(Attr.getKindAsEnum())); Record.push_back(Attr.getValueAsInt()); - } else { + } else if (Attr.isStringAttribute()) { StringRef Kind = Attr.getKindAsString(); StringRef Val = Attr.getValueAsString(); @@ -758,6 +758,13 @@ void ModuleBitcodeWriter::writeAttributeGroupTable() { Record.append(Val.begin(), Val.end()); Record.push_back(0); } + } else { + assert(Attr.isTypeAttribute()); + Type *Ty = Attr.getValueAsType(); + Record.push_back(Ty ? 6 : 5); + Record.push_back(getAttrKindEncoding(Attr.getKindAsEnum())); + if (Ty) + Record.push_back(VE.getTypeID(Attr.getValueAsType())); } } @@ -4126,15 +4133,15 @@ void ModuleBitcodeWriter::write() { // Emit blockinfo, which defines the standard abbreviations etc. writeBlockInfo(); + // Emit information describing all of the types in the module. + writeTypeTable(); + // Emit information about attribute groups. writeAttributeGroupTable(); // Emit information about parameter attributes. writeAttributeTable(); - // Emit information describing all of the types in the module. - writeTypeTable(); - writeComdats(); // Emit top-level description of module, including target triple, inline asm, |