/// hasCustomConstantPool - Allows a target to specify that constant
/// pool address resolution is handled by the target.
virtual bool hasCustomConstantPool() const { return false; }
+
+ /// allocateSeparateGVMemory - If true, globals should be placed in
+ /// separately allocated heap memory rather than in the same
+ /// code memory allocated by MachineCodeEmitter.
+ virtual bool allocateSeparateGVMemory() const { return false; }
protected:
bool useGOT;
};
if (GV->isThreadLocal()) {
MutexGuard locked(lock);
Ptr = TJI.allocateThreadLocalMemory(S);
+ } else if (TJI.allocateSeparateGVMemory()) {
+ if (A <= 8) {
+ Ptr = malloc(S);
+ } else {
+ // Allocate S+A bytes of memory, then use an aligned pointer within that
+ // space.
+ Ptr = malloc(S+A);
+ unsigned MisAligned = ((intptr_t)Ptr & (A-1));
+ Ptr = (char*)Ptr + (MisAligned ? (A-MisAligned) : 0);
+ }
} else {
Ptr = MCE->allocateSpace(S, A);
}
/// pool address resolution is handled by the target.
virtual bool hasCustomConstantPool() const { return true; }
+ /// allocateSeparateGVMemory - If true, globals should be placed in
+ /// separately allocated heap memory rather than in the same
+ /// code memory allocated by MachineCodeEmitter.
+ virtual bool allocateSeparateGVMemory() const {
+#ifdef __APPLE__
+ return true;
+#else
+ return false;
+#endif
+ }
+
/// Initialize - Initialize internal stage. Get the list of constant pool
/// Resize constant pool ids to CONSTPOOL_ENTRY addresses map.
void Initialize(const std::vector<MachineConstantPoolEntry> *mcpes) {