summaryrefslogtreecommitdiff
path: root/community/rubinius/llvm34.patch
blob: ca8f2d2893225e2008537fdcf6d4e39d932b1843 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
diff --git i/vm/llvm/disassembler.cpp w/vm/llvm/disassembler.cpp
index 79c74ff..b3ea424 100644
--- i/vm/llvm/disassembler.cpp
+++ w/vm/llvm/disassembler.cpp
@@ -46,20 +46,27 @@ namespace rubinius {
 #if RBX_LLVM_API_VER > 300
     llvm::TargetOptions options;
     options.NoFramePointerElim = true;
+#if RBX_LLVM_API_VER < 304
     options.NoFramePointerElimNonLeaf = true;
+#endif
     target_machine = target->createTargetMachine(host, llvm::sys::getHostCPUName(), "", options);
 #else
     target_machine = target->createTargetMachine(host, llvm::sys::getHostCPUName(), "");
 #endif
 
     sub_target = target->createMCSubtargetInfo(host, llvm::sys::getHostCPUName(), "");
-    asm_info = target->createMCAsmInfo(host);
 
 #if RBX_LLVM_API_VER > 300
     instr_info = target->createMCInstrInfo();
     reg_info = target->createMCRegInfo(host);
 #endif
 
+#if RBX_LLVM_API_VER > 303
+    asm_info = target->createMCAsmInfo(*reg_info, host);
+#else
+    asm_info = target->createMCAsmInfo(host);
+#endif
+
     if(asm_info) {
       disassembler = target->createMCDisassembler(*sub_target);
       memory_object = new JITMemoryObject((const uint8_t*)buffer, (uint64_t) size);
diff --git i/vm/llvm/jit_builder.cpp w/vm/llvm/jit_builder.cpp
index 652350f..c479aab 100644
--- i/vm/llvm/jit_builder.cpp
+++ w/vm/llvm/jit_builder.cpp
@@ -56,12 +56,21 @@ namespace jit {
         "", "rubinius", true, "", 0);
     DIFile file = debug_builder().createFile(file_str, "");
 
+#if RBX_LLVM_API_VER > 303
+    DIType dummy_return_type = debug_builder().createNullPtrType();
+    Value* dummy_signature[] = {
+      &*dummy_return_type,
+    };
+    DICompositeType dummy_subroutine_type = debug_builder().createSubroutineType(file,
+        debug_builder().getOrCreateArray(dummy_signature));
+#else
     DIType dummy_return_type = debug_builder().createNullPtrType("dummy type");
     Value* dummy_signature[] = {
       &*dummy_return_type,
     };
     DIType dummy_subroutine_type = debug_builder().createSubroutineType(file,
         debug_builder().getOrCreateArray(dummy_signature));
+#endif
 
 #if RBX_LLVM_API_VER > 300
     DISubprogram subprogram = debug_builder().createFunction(file, "", "",
diff --git i/vm/llvm/jit_context.cpp w/vm/llvm/jit_context.cpp
index e555adb..594a63a 100644
--- i/vm/llvm/jit_context.cpp
+++ w/vm/llvm/jit_context.cpp
@@ -84,7 +84,9 @@ namespace rubinius {
 #if RBX_LLVM_API_VER > 300
     llvm::TargetOptions opts;
     opts.NoFramePointerElim = true;
+#if RBX_LLVM_API_VER < 304
     opts.NoFramePointerElimNonLeaf = true;
+#endif
     opts.JITEmitDebugInfo = true;
 
     factory.setTargetOptions(opts);
diff --git i/vm/llvm/jit_memory_manager.hpp w/vm/llvm/jit_memory_manager.hpp
index 8a58a09..7205f89 100644
--- i/vm/llvm/jit_memory_manager.hpp
+++ w/vm/llvm/jit_memory_manager.hpp
@@ -202,7 +202,7 @@ namespace jit {
 
   public:
     RubiniusJITMemoryManager();
-    ~RubiniusJITMemoryManager();
+    virtual ~RubiniusJITMemoryManager();
 
     /// allocateNewSlab - Allocates a new MemoryBlock and remembers it as the
     /// last slab it allocated, so that subsequent allocations follow it.
@@ -356,8 +356,13 @@ namespace jit {
     }
 
     /// allocateCodeSection - Allocate memory for a code section.
+#if RBX_LLVM_API_VER > 303
+    virtual uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
+                                 unsigned SectionID, StringRef SectionName) {
+#else
     uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
                                  unsigned SectionID) {
+#endif
       utilities::thread::SpinLock::LockGuard guard(lock_);
       // Grow the required block size to account for the block header
       Size += sizeof(*CurBlock);
@@ -397,11 +402,21 @@ namespace jit {
     }
 
     /// allocateDataSection - Allocate memory for a data section.
-    uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
-                                 unsigned SectionID) {
+    /// TODO: currently IsReadOnly is ignored.
+#if RBX_LLVM_API_VER > 303
+    virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
+                                 unsigned SectionID, StringRef SectionName,
+                                 bool IsReadOnly) {
       utilities::thread::SpinLock::LockGuard guard(lock_);
       return (uint8_t*)DataAllocator.Allocate(Size, Alignment);
     }
+#else
+    uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
+                                 unsigned SectionID, bool IsReadOnly) {
+      utilities::thread::SpinLock::LockGuard guard(lock_);
+      return (uint8_t*)DataAllocator.Allocate(Size, Alignment);
+    }
+#endif
 
     /// startExceptionTable - Use startFunctionBody to allocate memory for the
     /// function's exception table.
@@ -495,7 +510,7 @@ namespace jit {
       , GOTBase(NULL)
     {}
 
-    ~RubiniusRequestJITMemoryManager() {
+    virtual ~RubiniusRequestJITMemoryManager() {
       if(GOTBase) delete[] GOTBase;
     }
 
@@ -504,17 +519,32 @@ namespace jit {
       return mgr_->getPointerToNamedFunction(Name, AbortOnFailure);
     }
 
+#if RBX_LLVM_API_VER >= 304
+    virtual uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
+                                 unsigned SectionID, StringRef SectionName) {
+      return mgr_->allocateCodeSection(Size, Alignment, SectionID,
+                                       SectionName);
+    }
+#else
     uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
                                  unsigned SectionID) {
       return mgr_->allocateCodeSection(Size, Alignment, SectionID);
     }
+#endif
 
     /// allocateDataSection - Allocate memory for a data section.
-#if RBX_LLVM_API_VER >= 303
+#if RBX_LLVM_API_VER >= 304
+    virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
+                                 unsigned SectionID, StringRef SectionName,
+                                 bool IsReadOnly) {
+      return mgr_->allocateDataSection(Size, Alignment, SectionID,
+                                       SectionName, IsReadOnly);
+    }
+#elif RBX_LLVM_API_VER >= 303
     uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
                                  unsigned SectionID, bool IsReadOnly) {
-      // TODO: currently IsReadOnly is ignored.
-      return mgr_->allocateDataSection(Size, Alignment, SectionID);
+      return mgr_->allocateDataSection(Size, Alignment, SectionID,
+                                       IsReadOnly);
     }
 #else
     uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
@@ -601,6 +631,12 @@ namespace jit {
     void resetGeneratedFunction() {
       GeneratedFunction = NULL;
     }
+
+#if RBX_LLVM_API_VER > 303
+    virtual bool finalizeMemory(std::string* ErrMsg = 0) {
+      return false;
+    }
+#endif
   };