summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-03-12 16:55:59 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-03-12 16:55:59 +0000
commit3d5d464df891196b25a52bcf5b8fcd4b1dc3e4e7 (patch)
treeddea8115e6f19568d5c952ed22b579d6a6c96867 /llvm/lib/MC
parent7066f7bc39426fdfd8646a7469a0945fe660e654 (diff)
downloadbcm5719-llvm-3d5d464df891196b25a52bcf5b8fcd4b1dc3e4e7.tar.gz
bcm5719-llvm-3d5d464df891196b25a52bcf5b8fcd4b1dc3e4e7.zip
Try harder to evaluate expressions when printing assembly.
When printing assembly we don't have a Layout object, but we can still try to fold some constants. Testcase by Ulrich Weigand. llvm-svn: 203677
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/MCAssembler.cpp4
-rw-r--r--llvm/lib/MC/MCExpr.cpp6
-rw-r--r--llvm/lib/MC/MachObjectWriter.cpp4
3 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index b8a4b438f6c..89d7d190167 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -122,7 +122,7 @@ uint64_t MCAsmLayout::getSymbolOffset(const MCSymbolData *SD) const {
// If this is a variable, then recursively evaluate now.
if (S.isVariable()) {
MCValue Target;
- if (!S.getVariableValue()->EvaluateAsRelocatable(Target, *this))
+ if (!S.getVariableValue()->EvaluateAsRelocatable(Target, this))
report_fatal_error("unable to evaluate offset for variable '" +
S.getName() + "'");
@@ -357,7 +357,7 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
MCValue &Target, uint64_t &Value) const {
++stats::evaluateFixup;
- if (!Fixup.getValue()->EvaluateAsRelocatable(Target, Layout))
+ if (!Fixup.getValue()->EvaluateAsRelocatable(Target, &Layout))
getContext().FatalError(Fixup.getLoc(), "expected relocatable expression");
bool IsPCRel = Backend.getFixupKindInfo(
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index 75bde8ed36b..9a4c41699e1 100644
--- a/llvm/lib/MC/MCExpr.cpp
+++ b/llvm/lib/MC/MCExpr.cpp
@@ -607,9 +607,9 @@ static bool EvaluateSymbolicAdd(const MCAssembler *Asm,
}
bool MCExpr::EvaluateAsRelocatable(MCValue &Res,
- const MCAsmLayout &Layout) const {
- return EvaluateAsRelocatableImpl(Res, &Layout.getAssembler(), &Layout,
- 0, false);
+ const MCAsmLayout *Layout) const {
+ MCAssembler *Assembler = Layout ? &Layout->getAssembler() : 0;
+ return EvaluateAsRelocatableImpl(Res, Assembler, Layout, 0, false);
}
bool MCExpr::EvaluateAsRelocatableImpl(MCValue &Res,
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index edbd2b98b28..b3b593d3154 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -82,7 +82,7 @@ uint64_t MachObjectWriter::getSymbolAddress(const MCSymbolData* SD,
MCValue Target;
- if (!S.getVariableValue()->EvaluateAsRelocatable(Target, Layout))
+ if (!S.getVariableValue()->EvaluateAsRelocatable(Target, &Layout))
report_fatal_error("unable to evaluate offset for variable '" +
S.getName() + "'");
@@ -631,7 +631,7 @@ void MachObjectWriter::markAbsoluteVariableSymbols(MCAssembler &Asm,
// and neither symbol is external, mark the variable as absolute.
const MCExpr *Expr = SD.getSymbol().getVariableValue();
MCValue Value;
- if (Expr->EvaluateAsRelocatable(Value, Layout)) {
+ if (Expr->EvaluateAsRelocatable(Value, &Layout)) {
if (Value.getSymA() && Value.getSymB())
const_cast<MCSymbol*>(&SD.getSymbol())->setAbsolute();
}
OpenPOWER on IntegriCloud