Skip to content

Commit f02386d

Browse files
committed
Sparc: Don't build SparcMCExpr with a zero specifier
1 parent 1d95548 commit f02386d

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

llvm/lib/Target/Sparc/MCTargetDesc/SparcMCCodeEmitter.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,24 +171,15 @@ unsigned SparcMCCodeEmitter::
171171
getCallTargetOpValue(const MCInst &MI, unsigned OpNo,
172172
SmallVectorImpl<MCFixup> &Fixups,
173173
const MCSubtargetInfo &STI) const {
174-
const MCOperand &MO = MI.getOperand(OpNo);
175-
const MCExpr *Expr = MO.getExpr();
176-
const SparcMCExpr *SExpr = dyn_cast<SparcMCExpr>(Expr);
177-
178174
if (MI.getOpcode() == SP::TLS_CALL) {
179175
// No fixups for __tls_get_addr. Will emit for fixups for tls_symbol in
180176
// encodeInstruction.
181-
#ifndef NDEBUG
182-
// Verify that the callee is actually __tls_get_addr.
183-
assert(SExpr && SExpr->getSubExpr()->getKind() == MCExpr::SymbolRef &&
184-
"Unexpected expression in TLS_CALL");
185-
const MCSymbolRefExpr *SymExpr = cast<MCSymbolRefExpr>(SExpr->getSubExpr());
186-
assert(SymExpr->getSymbol().getName() == "__tls_get_addr" &&
187-
"Unexpected function for TLS_CALL");
188-
#endif
189177
return 0;
190178
}
191179

180+
const MCOperand &MO = MI.getOperand(OpNo);
181+
const MCExpr *Expr = MO.getExpr();
182+
auto *SExpr = cast<SparcMCExpr>(Expr);
192183
Fixups.push_back(MCFixup::create(0, Expr, SExpr->getFixupKind()));
193184
return 0;
194185
}

llvm/lib/Target/Sparc/SparcMCInstLower.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ static MCOperand LowerSymbolOperand(const MachineInstr *MI,
5656
break;
5757
}
5858

59-
const MCSymbolRefExpr *MCSym = MCSymbolRefExpr::create(Symbol,
60-
AP.OutContext);
61-
const SparcMCExpr *expr = SparcMCExpr::create(Kind, MCSym,
62-
AP.OutContext);
59+
const MCExpr *expr = MCSymbolRefExpr::create(Symbol, AP.OutContext);
60+
if (Kind)
61+
expr = SparcMCExpr::create(Kind, expr, AP.OutContext);
6362
return MCOperand::createExpr(expr);
6463
}
6564

0 commit comments

Comments
 (0)