@@ -60,6 +60,7 @@ namespace {
60
60
ARMJITInfo *JTI;
61
61
const ARMInstrInfo *II;
62
62
const TargetData *TD;
63
+ const ARMSubtarget *Subtarget;
63
64
TargetMachine &TM;
64
65
CodeEmitter &MCE;
65
66
const std::vector<MachineConstantPoolEntry> *MCPEs;
@@ -163,7 +164,7 @@ namespace {
163
164
// / Routines that handle operands which add machine relocations which are
164
165
// / fixed up by the relocation stage.
165
166
void emitGlobalAddress (GlobalValue *GV, unsigned Reloc,
166
- bool NeedStub, intptr_t ACPV = 0 );
167
+ bool NeedStub, bool Indirect, intptr_t ACPV = 0 );
167
168
void emitExternalSymbolAddress (const char *ES, unsigned Reloc);
168
169
void emitConstPoolAddress (unsigned CPI, unsigned Reloc);
169
170
void emitJumpTableAddress (unsigned JTIndex, unsigned Reloc);
@@ -195,9 +196,10 @@ bool Emitter<CodeEmitter>::runOnMachineFunction(MachineFunction &MF) {
195
196
assert ((MF.getTarget ().getRelocationModel () != Reloc::Default ||
196
197
MF.getTarget ().getRelocationModel () != Reloc::Static) &&
197
198
" JIT relocation model must be set to static or default!" );
199
+ JTI = ((ARMTargetMachine&)MF.getTarget ()).getJITInfo ();
198
200
II = ((ARMTargetMachine&)MF.getTarget ()).getInstrInfo ();
199
201
TD = ((ARMTargetMachine&)MF.getTarget ()).getTargetData ();
200
- JTI = ((ARMTargetMachine&)MF. getTarget ()). getJITInfo ();
202
+ Subtarget = &TM. getSubtarget <ARMSubtarget> ();
201
203
MCPEs = &MF.getConstantPool ()->getConstants ();
202
204
MJTEs = &MF.getJumpTableInfo ()->getJumpTables ();
203
205
IsPIC = TM.getRelocationModel () == Reloc::PIC_;
@@ -244,7 +246,7 @@ unsigned Emitter<CodeEmitter>::getMachineOpValue(const MachineInstr &MI,
244
246
else if (MO.isImm ())
245
247
return static_cast <unsigned >(MO.getImm ());
246
248
else if (MO.isGlobal ())
247
- emitGlobalAddress (MO.getGlobal (), ARM::reloc_arm_branch, true );
249
+ emitGlobalAddress (MO.getGlobal (), ARM::reloc_arm_branch, true , false );
248
250
else if (MO.isSymbol ())
249
251
emitExternalSymbolAddress (MO.getSymbolName (), ARM::reloc_arm_branch);
250
252
else if (MO.isCPI ()) {
@@ -270,9 +272,14 @@ unsigned Emitter<CodeEmitter>::getMachineOpValue(const MachineInstr &MI,
270
272
// /
271
273
template <class CodeEmitter >
272
274
void Emitter<CodeEmitter>::emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
273
- bool NeedStub, intptr_t ACPV) {
274
- MCE.addRelocation (MachineRelocation::getGV (MCE.getCurrentPCOffset (), Reloc,
275
- GV, ACPV, NeedStub));
275
+ bool NeedStub, bool Indirect,
276
+ intptr_t ACPV) {
277
+ MachineRelocation MR = Indirect
278
+ ? MachineRelocation::getIndirectSymbol (MCE.getCurrentPCOffset (), Reloc,
279
+ GV, ACPV, NeedStub)
280
+ : MachineRelocation::getGV (MCE.getCurrentPCOffset (), Reloc,
281
+ GV, ACPV, NeedStub);
282
+ MCE.addRelocation (MR);
276
283
}
277
284
278
285
// / emitExternalSymbolAddress - Arrange for the address of an external symbol to
@@ -423,8 +430,11 @@ void Emitter<CodeEmitter>::emitConstPoolInstruction(const MachineInstr &MI) {
423
430
424
431
GlobalValue *GV = ACPV->getGV ();
425
432
if (GV) {
433
+ Reloc::Model RelocM = TM.getRelocationModel ();
426
434
emitGlobalAddress (GV, ARM::reloc_arm_machine_cp_entry,
427
- isa<Function>(GV), (intptr_t )ACPV);
435
+ isa<Function>(GV),
436
+ Subtarget->GVIsIndirectSymbol (GV, RelocM),
437
+ (intptr_t )ACPV);
428
438
} else {
429
439
emitExternalSymbolAddress (ACPV->getSymbol (), ARM::reloc_arm_absolute);
430
440
}
@@ -443,7 +453,7 @@ void Emitter<CodeEmitter>::emitConstPoolInstruction(const MachineInstr &MI) {
443
453
});
444
454
445
455
if (GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
446
- emitGlobalAddress (GV, ARM::reloc_arm_absolute, isa<Function>(GV));
456
+ emitGlobalAddress (GV, ARM::reloc_arm_absolute, isa<Function>(GV), false );
447
457
emitWordLE (0 );
448
458
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
449
459
uint32_t Val = *(uint32_t *)CI->getValue ().getRawData ();
0 commit comments