diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-18 20:40:38 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-18 20:40:38 +0000 |
commit | 574bfa12fa80744c64b0b6eac0ba70f97f666781 (patch) | |
tree | 06c2d95390cf4c54ceb69b70a220a247abce7f59 /llvm/lib/MC/MCSymbol.cpp | |
parent | c0bd5f8256b02a499bf8f4ebf259b472ae375707 (diff) | |
download | bcm5719-llvm-574bfa12fa80744c64b0b6eac0ba70f97f666781.tar.gz bcm5719-llvm-574bfa12fa80744c64b0b6eac0ba70f97f666781.zip |
Add back r203962, r204028 and r204059.
This reverts commit r204137.
This includes a fix for handling aliases of aliases.
llvm-svn: 204178
Diffstat (limited to 'llvm/lib/MC/MCSymbol.cpp')
-rw-r--r-- | llvm/lib/MC/MCSymbol.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCSymbol.cpp b/llvm/lib/MC/MCSymbol.cpp index 24165254e56..6876cb165dc 100644 --- a/llvm/lib/MC/MCSymbol.cpp +++ b/llvm/lib/MC/MCSymbol.cpp @@ -9,6 +9,7 @@ #include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCValue.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -51,6 +52,27 @@ const MCSymbol &MCSymbol::AliasedSymbol() const { return *S; } +const MCSymbol *MCSymbol::getBaseSymbol(const MCAsmLayout &Layout) const { + // FIXME: shouldn't EvaluateAsRelocatable be responsible for following as many + // variables as possible? + + const MCSymbol *S = this; + while (S->isVariable()) { + const MCExpr *Expr = S->getVariableValue(); + MCValue Value; + if (!Expr->EvaluateAsRelocatable(Value, &Layout)) + return nullptr; + + if (Value.getSymB()) + return nullptr; + const MCSymbolRefExpr *A = Value.getSymA(); + if (!A) + return nullptr; + S = &A->getSymbol(); + } + return S; +} + void MCSymbol::setVariableValue(const MCExpr *Value) { assert(!IsUsed && "Cannot set a variable that has already been used."); assert(Value && "Invalid variable value!"); |