diff options
| author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2017-01-19 20:04:11 +0000 |
|---|---|---|
| committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2017-01-19 20:04:11 +0000 |
| commit | f2d9a46b5ff059f002602c7d6199bda1993435dd (patch) | |
| tree | ebf0206cc76bcd039651904c3a53f5dc172f2969 /llvm | |
| parent | 2c87688c70c211cb3b1f1331d69879e272a733f7 (diff) | |
| download | bcm5719-llvm-f2d9a46b5ff059f002602c7d6199bda1993435dd.tar.gz bcm5719-llvm-f2d9a46b5ff059f002602c7d6199bda1993435dd.zip | |
Fix aliases to thumbfunc-based exprs to be thumbfunc.
If F is a Thumb function symbol, and G = F + const, and G is a
function symbol, then G is Thumb. Because what else could it be?
Differential Revision: https://reviews.llvm.org/D28878
llvm-svn: 292514
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 12 | ||||
| -rw-r--r-- | llvm/test/MC/ARM/elf-thumbfunc.s | 10 |
2 files changed, 19 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 83fcec92e2b..17a0edcc954 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -114,10 +114,16 @@ bool MCAssembler::isThumbFunc(const MCSymbol *Symbol) const { if (!Symbol->isVariable()) return false; - // FIXME: It looks like gas supports some cases of the form "foo + 2". It - // is not clear if that is a bug or a feature. const MCExpr *Expr = Symbol->getVariableValue(); - const MCSymbolRefExpr *Ref = dyn_cast<MCSymbolRefExpr>(Expr); + + MCValue V; + if (!Expr->evaluateAsRelocatable(V, nullptr, nullptr)) + return false; + + if (V.getSymB() || V.getRefKind() != MCSymbolRefExpr::VK_None) + return false; + + const MCSymbolRefExpr *Ref = V.getSymA(); if (!Ref) return false; diff --git a/llvm/test/MC/ARM/elf-thumbfunc.s b/llvm/test/MC/ARM/elf-thumbfunc.s index af061b50bc3..b6b0b03059c 100644 --- a/llvm/test/MC/ARM/elf-thumbfunc.s +++ b/llvm/test/MC/ARM/elf-thumbfunc.s @@ -14,6 +14,9 @@ foo: .global bar bar = foo + .global baz +baz = foo + 2 + @@ make sure foo and bar are thumb function: bit 0 = 1 (st_value) @CHECK: Symbol { @CHECK: Name: bar @@ -23,6 +26,13 @@ bar = foo @CHECK-NEXT: Type: Function @CHECK: Symbol { +@CHECK: Name: baz +@CHECK-NEXT: Value: 0x3 +@CHECK-NEXT: Size: 0 +@CHECK-NEXT: Binding: Global +@CHECK-NEXT: Type: Function + +@CHECK: Symbol { @CHECK: Name: foo @CHECK-NEXT: Value: 0x1 @CHECK-NEXT: Size: 0 |

