aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorMitch Phillips <31459023+hctim@users.noreply.github.com>2022-06-10 12:24:36 -0700
committerMitch Phillips <31459023+hctim@users.noreply.github.com>2022-06-10 12:28:18 -0700
commit8db981d463ee266919907f2554194d05f96f7191 (patch)
tree6459225d9ce90dcad0e74fa605ee240d53ec6f4f /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent0bb317b7bff3d4f70bddd03a1f337c3f2a118943 (diff)
downloadllvm-8db981d463ee266919907f2554194d05f96f7191.zip
llvm-8db981d463ee266919907f2554194d05f96f7191.tar.gz
llvm-8db981d463ee266919907f2554194d05f96f7191.tar.bz2
Add sanitizer-specific GlobalValue attributes.
Plan is the migrate the global variable metadata for sanitizers, that's currently carried around generally in the 'llvm.asan.globals' section, onto the global variable itself. This patch adds the attribute and plumbs it through the LLVM IR and bitcode formats, but is a no-op other than that so far. Reviewed By: vitalybuka, kstoimenov Differential Revision: https://reviews.llvm.org/D126100
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 9dd2b128..cd253c1 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3441,6 +3441,19 @@ static void inferDSOLocal(GlobalValue *GV) {
GV->setDSOLocal(true);
}
+GlobalValue::SanitizerMetadata deserializeSanitizerMetadata(unsigned V) {
+ GlobalValue::SanitizerMetadata Meta;
+ if (V & (1 << 0))
+ Meta.NoAddress = true;
+ if (V & (1 << 1))
+ Meta.NoHWAddress = true;
+ if (V & (1 << 2))
+ Meta.NoMemtag = true;
+ if (V & (1 << 3))
+ Meta.IsDynInit = true;
+ return Meta;
+}
+
Error BitcodeReader::parseGlobalVarRecord(ArrayRef<uint64_t> Record) {
// v1: [pointer type, isconst, initid, linkage, alignment, section,
// visibility, threadlocal, unnamed_addr, externally_initialized,
@@ -3544,6 +3557,12 @@ Error BitcodeReader::parseGlobalVarRecord(ArrayRef<uint64_t> Record) {
if (Record.size() > 15)
NewGV->setPartition(StringRef(Strtab.data() + Record[14], Record[15]));
+ if (Record.size() > 16 && Record[16] != UINT_MAX) {
+ llvm::GlobalValue::SanitizerMetadata Meta =
+ deserializeSanitizerMetadata(Record[16]);
+ NewGV->setSanitizerMetadata(Meta);
+ }
+
return Error::success();
}