[llvm] r292514 - Fix aliases to thumbfunc-based exprs to be thumbfunc.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 12:04:11 PST 2017


Author: eugenis
Date: Thu Jan 19 14:04:11 2017
New Revision: 292514

URL: http://llvm.org/viewvc/llvm-project?rev=292514&view=rev
Log:
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

Modified:
    llvm/trunk/lib/MC/MCAssembler.cpp
    llvm/trunk/test/MC/ARM/elf-thumbfunc.s

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=292514&r1=292513&r2=292514&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Thu Jan 19 14:04:11 2017
@@ -114,10 +114,16 @@ bool MCAssembler::isThumbFunc(const MCSy
   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;
 

Modified: llvm/trunk/test/MC/ARM/elf-thumbfunc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/elf-thumbfunc.s?rev=292514&r1=292513&r2=292514&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/elf-thumbfunc.s (original)
+++ llvm/trunk/test/MC/ARM/elf-thumbfunc.s Thu Jan 19 14:04:11 2017
@@ -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
@@ -21,6 +24,13 @@ bar = foo
 @CHECK-NEXT:     Size: 0
 @CHECK-NEXT:     Binding: Global
 @CHECK-NEXT:     Type: Function
+
+ at CHECK:        Symbol {
+ at CHECK:          Name: baz
+ at CHECK-NEXT:     Value: 0x3
+ at CHECK-NEXT:     Size: 0
+ at CHECK-NEXT:     Binding: Global
+ at CHECK-NEXT:     Type: Function
 
 @CHECK:        Symbol {
 @CHECK:          Name: foo




More information about the llvm-commits mailing list