-
Notifications
You must be signed in to change notification settings - Fork 10
/
fix-llvm36.patch
59 lines (53 loc) · 2.24 KB
/
fix-llvm36.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index f2d53f5..aad382d 100644
--- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -130,9 +130,12 @@ void MCJIT::setObjectCache(ObjectCache* NewCache) {
ObjCache = NewCache;
}
+
+
std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) {
MutexGuard locked(lock);
+
// This must be a module which has already been added but not loaded to this
// MCJIT instance, since these conditions are tested by our caller,
// generateCodeForModule.
@@ -156,6 +159,21 @@ std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) {
// Flush the output buffer to get the generated code into memory
ObjStream.flush();
+
+ // Christian Schafmeister added hack suggested by Logan Chien to dump ObjBufferSV to a file
+#if 1
+ static int JITFileNameIndex = 0;
+ char* jitdump = getenv("JIT_DUMP");
+ if ( jitdump != NULL ) {
+ char fileName[1024];
+ sprintf(fileName,jitdump,JITFileNameIndex);
+ ++JITFileNameIndex;
+ FILE* fout = fopen(fileName,"wb");
+ fwrite(ObjBufferSV.data(),ObjBufferSV.size_in_bytes(),1,fout);
+ fclose(fout);
+ }
+#endif
+
std::unique_ptr<MemoryBuffer> CompiledObjBuffer(
new ObjectMemoryBuffer(std::move(ObjBufferSV)));
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
index 2851e48..98449f1 100644
--- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
+++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
@@ -176,6 +176,7 @@ bool RuntimeDyldMachO::isCompatibleFile(const object::ObjectFile &Obj) const {
return Obj.isMachO();
}
+
template <typename Impl>
void RuntimeDyldMachOCRTPBase<Impl>::finalizeLoad(const ObjectFile &Obj,
ObjSectionToIDMap &SectionMap) {
@@ -206,6 +207,7 @@ void RuntimeDyldMachOCRTPBase<Impl>::finalizeLoad(const ObjectFile &Obj,
EHFrameRelatedSections(EHFrameSID, TextSID, ExceptTabSID));
}
+
template <typename Impl>
unsigned char *RuntimeDyldMachOCRTPBase<Impl>::processFDE(unsigned char *P,
int64_t DeltaForText,