[IR] Allow attributes with global variables
This patch extends llvm-ir to allow attributes to be set on global variables. An RFC was sent out earlier by my colleague James Molloy: http://lists.llvm.org/pipermail/cfe-dev/2017-March/053100.html A key part of that proposal was to extend LLVM-IR to carry attributes on global variables. This generic feature could be useful for multiple purposes. In our present context, it would be useful to carry user specified sections for bss/rodata/data. Reviewed by: Jonathan Roelofs, Reid Kleckner Differential Revision: https://reviews.llvm.org/D32009 llvm-svn: 302794
This commit is contained in:
@@ -2750,7 +2750,7 @@ Error BitcodeReader::parseComdatRecord(ArrayRef<uint64_t> Record) {
|
||||
Error BitcodeReader::parseGlobalVarRecord(ArrayRef<uint64_t> Record) {
|
||||
// v1: [pointer type, isconst, initid, linkage, alignment, section,
|
||||
// visibility, threadlocal, unnamed_addr, externally_initialized,
|
||||
// dllstorageclass, comdat] (name in VST)
|
||||
// dllstorageclass, comdat, attributes] (name in VST)
|
||||
// v2: [strtab_offset, strtab_size, v1]
|
||||
StringRef Name;
|
||||
std::tie(Name, Record) = readNameFromStrtab(Record);
|
||||
@@ -2830,6 +2830,11 @@ Error BitcodeReader::parseGlobalVarRecord(ArrayRef<uint64_t> Record) {
|
||||
} else if (hasImplicitComdat(RawLinkage)) {
|
||||
NewGV->setComdat(reinterpret_cast<Comdat *>(1));
|
||||
}
|
||||
|
||||
if (Record.size() > 12) {
|
||||
auto AS = getAttributes(Record[12]).getFnAttributes();
|
||||
NewGV->setAttributes(AS);
|
||||
}
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user