summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2019-05-12 22:26:33 +0000
committerLang Hames <lhames@gmail.com>2019-05-12 22:26:33 +0000
commit23085ec36d0821d4e3d69f4acf75d47ed0789837 (patch)
tree0e41d4e6eb344061df212db7ed029ae9d799e295 /llvm/include
parent27415e7a92fa7e7676e486e7f95dbd922d8b22ed (diff)
downloadbcm5719-llvm-23085ec36d0821d4e3d69f4acf75d47ed0789837.tar.gz
bcm5719-llvm-23085ec36d0821d4e3d69f4acf75d47ed0789837.zip
[JITLink] Add a test for zero-filled content.
Also updates RuntimeDyldChecker and llvm-rtdyld to support zero-fill tests by returning a content address of zero (but no error) for zero-fill atoms, and treating loads from zero as returning zero. llvm-svn: 360547
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h60
1 files changed, 57 insertions, 3 deletions
diff --git a/llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h b/llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h
index 2897c8ebca8..93ea09107bd 100644
--- a/llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h
+++ b/llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h
@@ -73,9 +73,63 @@ class raw_ostream;
///
class RuntimeDyldChecker {
public:
- struct MemoryRegionInfo {
- StringRef Content;
- JITTargetAddress TargetAddress;
+ class MemoryRegionInfo {
+ public:
+ MemoryRegionInfo() = default;
+
+ /// Constructor for symbols/sections with content.
+ MemoryRegionInfo(StringRef Content, JITTargetAddress TargetAddress)
+ : ContentPtr(Content.data()), Size(Content.size()),
+ TargetAddress(TargetAddress) {}
+
+ /// Constructor for zero-fill symbols/sections.
+ MemoryRegionInfo(uint64_t Size, JITTargetAddress TargetAddress)
+ : Size(Size), TargetAddress(TargetAddress) {}
+
+ /// Returns true if this is a zero-fill symbol/section.
+ bool isZeroFill() const {
+ assert(Size && "setContent/setZeroFill must be called first");
+ return !ContentPtr;
+ }
+
+ /// Set the content for this memory region.
+ void setContent(StringRef Content) {
+ assert(!ContentPtr && !Size && "Content/zero-fill already set");
+ ContentPtr = Content.data();
+ Size = Content.size();
+ }
+
+ /// Set a zero-fill length for this memory region.
+ void setZeroFill(uint64_t Size) {
+ assert(!ContentPtr && !this->Size && "Content/zero-fill already set");
+ this->Size = Size;
+ }
+
+ /// Returns the content for this section if there is any.
+ StringRef getContent() const {
+ assert(!isZeroFill() && "Can't get content for a zero-fill section");
+ return StringRef(ContentPtr, static_cast<size_t>(Size));
+ }
+
+ /// Returns the zero-fill length for this section.
+ uint64_t getZeroFillLength() const {
+ assert(isZeroFill() && "Can't get zero-fill length for content section");
+ return Size;
+ }
+
+ /// Set the target address for this region.
+ void setTargetAddress(JITTargetAddress TargetAddress) {
+ assert(!this->TargetAddress && "TargetAddress already set");
+ this->TargetAddress = TargetAddress;
+ }
+
+ /// Return the target address for this region.
+ JITTargetAddress getTargetAddress() const { return TargetAddress; }
+
+ private:
+ const char *ContentPtr = 0;
+ uint64_t Size = 0;
+ JITTargetAddress TargetAddress = 0;
};
using IsSymbolValidFunction = std::function<bool(StringRef Symbol)>;
OpenPOWER on IntegriCloud