diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-12 16:55:59 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-12 16:55:59 +0000 |
| commit | 3d5d464df891196b25a52bcf5b8fcd4b1dc3e4e7 (patch) | |
| tree | ddea8115e6f19568d5c952ed22b579d6a6c96867 /llvm/lib/Target | |
| parent | 7066f7bc39426fdfd8646a7469a0945fe660e654 (diff) | |
| download | bcm5719-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/Target')
4 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp index 66ce92d7b93..c7ccaee8653 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp @@ -79,7 +79,7 @@ void AArch64MCExpr::PrintImpl(raw_ostream &OS) const { bool AArch64MCExpr::EvaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout) const { - return getSubExpr()->EvaluateAsRelocatable(Res, *Layout); + return getSubExpr()->EvaluateAsRelocatable(Res, Layout); } static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) { diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp index e470fea1653..22ce41100a0 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp @@ -36,9 +36,7 @@ void MipsMCExpr::PrintImpl(raw_ostream &OS) const { bool MipsMCExpr::EvaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout) const { - if (!Layout) - return false; - return getSubExpr()->EvaluateAsRelocatable(Res, *Layout); + return getSubExpr()->EvaluateAsRelocatable(Res, Layout); } // FIXME: This basically copies MCObjectStreamer::AddValueSymbols. Perhaps diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp index 562badfd59d..c181e03fe64 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp @@ -54,7 +54,7 @@ PPCMCExpr::EvaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout) const { MCValue Value; - if (!Layout || !getSubExpr()->EvaluateAsRelocatable(Value, *Layout)) + if (!getSubExpr()->EvaluateAsRelocatable(Value, Layout)) return false; if (Value.isAbsolute()) { @@ -86,6 +86,9 @@ PPCMCExpr::EvaluateAsRelocatableImpl(MCValue &Res, } Res = MCValue::get(Result); } else { + if (!Layout) + return false; + MCContext &Context = Layout->getAssembler().getContext(); const MCSymbolRefExpr *Sym = Value.getSymA(); MCSymbolRefExpr::VariantKind Modifier = Sym->getKind(); diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp index 7f2b25e4081..e6b2acab9d0 100644 --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp @@ -160,9 +160,7 @@ Sparc::Fixups SparcMCExpr::getFixupKind(SparcMCExpr::VariantKind Kind) { bool SparcMCExpr::EvaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout) const { - if (!Layout) - return false; - return getSubExpr()->EvaluateAsRelocatable(Res, *Layout); + return getSubExpr()->EvaluateAsRelocatable(Res, Layout); } static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) { |

