summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp4
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.cpp2
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h20
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp8
4 files changed, 26 insertions, 8 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index 9660e1acad1..df9d2ceba32 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -443,7 +443,7 @@ Error RuntimeDyldImpl::computeTotalAllocSize(const ObjectFile &Obj,
SI != SE; ++SI) {
const SectionRef &Section = *SI;
- bool IsRequired = isRequiredForExecution(Section);
+ bool IsRequired = isRequiredForExecution(Section) || ProcessAllSections;
// Consider only the sections that are required to be loaded for execution
if (IsRequired) {
@@ -703,7 +703,7 @@ RuntimeDyldImpl::emitSection(const ObjectFile &Obj,
unsigned Alignment = (unsigned)Alignment64 & 0xffffffffL;
unsigned PaddingSize = 0;
unsigned StubBufSize = 0;
- bool IsRequired = isRequiredForExecution(Section);
+ bool IsRequired = isRequiredForExecution(Section) || ProcessAllSections;
bool IsVirtual = Section.isVirtual();
bool IsZeroInit = isZeroInit(Section);
bool IsReadOnly = isReadOnlyData(Section);
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.cpp b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.cpp
index 17d1e9c9276..ccd2fc0fb18 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.cpp
@@ -15,7 +15,7 @@
using namespace llvm;
-bool OrcExecutionTest::NativeTargetInitialized = false;
+bool OrcNativeTarget::NativeTargetInitialized = false;
ModuleBuilder::ModuleBuilder(LLVMContext &Context, StringRef Triple,
StringRef Name)
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
index f3972a3084e..d08962fa7cf 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
@@ -28,17 +28,29 @@
namespace llvm {
-// Base class for Orc tests that will execute code.
-class OrcExecutionTest {
+class OrcNativeTarget {
public:
-
- OrcExecutionTest() {
+ static void initialize() {
if (!NativeTargetInitialized) {
InitializeNativeTarget();
InitializeNativeTargetAsmParser();
InitializeNativeTargetAsmPrinter();
NativeTargetInitialized = true;
}
+ }
+
+private:
+ static bool NativeTargetInitialized;
+};
+
+// Base class for Orc tests that will execute code.
+class OrcExecutionTest {
+public:
+
+ OrcExecutionTest() {
+
+ // Initialize the native target if it hasn't been done already.
+ OrcNativeTarget::initialize();
// Try to select a TargetMachine for the host.
TM.reset(EngineBuilder().selectTarget());
diff --git a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
index f4cec0cc930..de99c022fb9 100644
--- a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
@@ -60,7 +60,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
IsReadOnly);
}
private:
- bool DebugSeen;
+ bool &DebugSeen;
};
RTDyldObjectLinkingLayer<> ObjLayer;
@@ -75,6 +75,10 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
GV->setSection(".debug_str");
+
+ // Initialize the native target in case this is the first unit test
+ // to try to build a TM.
+ OrcNativeTarget::initialize();
std::unique_ptr<TargetMachine> TM(
EngineBuilder().selectTarget(Triple(M->getTargetTriple()), "", "",
SmallVector<std::string, 1>()));
@@ -99,6 +103,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
{
// Test with ProcessAllSections = false (the default).
auto H = ObjLayer.addObjectSet(Objs, &SMMW, &*Resolver);
+ ObjLayer.emitAndFinalize(H);
EXPECT_EQ(DebugSectionSeen, false)
<< "Unexpected debug info section";
ObjLayer.removeObjectSet(H);
@@ -108,6 +113,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
// Test with ProcessAllSections = true.
ObjLayer.setProcessAllSections(true);
auto H = ObjLayer.addObjectSet(Objs, &SMMW, &*Resolver);
+ ObjLayer.emitAndFinalize(H);
EXPECT_EQ(DebugSectionSeen, true)
<< "Expected debug info section not seen";
ObjLayer.removeObjectSet(H);
OpenPOWER on IntegriCloud