summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Writer
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2019-05-29 19:12:48 +0000
committerTim Northover <tnorthover@apple.com>2019-05-29 19:12:48 +0000
commit6e07f16fae605c42014aa4f1f2babf3e7767c95c (patch)
tree0fc6d7bdebcdd3d743976cbbee35393af81f9a62 /llvm/lib/Bitcode/Writer
parentee37e28fd1c670ecabea64a15b9cc8698ca62b86 (diff)
downloadbcm5719-llvm-6e07f16fae605c42014aa4f1f2babf3e7767c95c.tar.gz
bcm5719-llvm-6e07f16fae605c42014aa4f1f2babf3e7767c95c.zip
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. 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: 362012
Diffstat (limited to 'llvm/lib/Bitcode/Writer')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp15
-rw-r--r--llvm/lib/Bitcode/Writer/ValueEnumerator.cpp6
2 files changed, 15 insertions, 6 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 8e1e06226bb..d243815667f 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,
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
index 72d7000fad9..143570fb20a 100644
--- a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -949,9 +949,11 @@ void ValueEnumerator::incorporateFunction(const Function &F) {
incorporateFunctionMetadata(F);
// Adding function arguments to the value table.
- for (const auto &I : F.args())
+ for (const auto &I : F.args()) {
EnumerateValue(&I);
-
+ if (I.hasAttribute(Attribute::ByVal) && I.getParamByValType())
+ EnumerateType(I.getParamByValType());
+ }
FirstFuncConstantID = Values.size();
// Add all function-level constants to the value table.
OpenPOWER on IntegriCloud