Skip to content

Commit cdab623

Browse files
committed
Fix ADR instruction encoding
1 parent 1856935 commit cdab623

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,11 @@ AArch64MCCodeEmitter::getAdrLabelOpValue(const MCInst &MI, unsigned OpIdx,
218218
const MCOperand &MO = MI.getOperand(OpIdx);
219219

220220
// If the destination is an immediate, we have nothing to do.
221-
if (MO.isImm())
222-
return MO.getImm() - (MI.getAddress() >> 12);
221+
if (MO.isImm()) {
222+
if (MI.getOpcode() == AArch64::ADR)
223+
return MO.getImm() - MI.getAddress();
224+
return MO.getImm() - (MI.getAddress() >> 12);
225+
}
223226
assert(MO.isExpr() && "Unexpected target type!");
224227
const MCExpr *Expr = MO.getExpr();
225228

0 commit comments

Comments
 (0)