[PATCH] D28878: Fix aliases to thumbfunc-based exprs to be thumbfunc

Evgeniy Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 12:15:16 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL292514: Fix aliases to thumbfunc-based exprs to be thumbfunc. (authored by eugenis).

Changed prior to commit:
  https://reviews.llvm.org/D28878?vs=84901&id=85005#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28878

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


Index: llvm/trunk/test/MC/ARM/elf-thumbfunc.s
===================================================================
--- llvm/trunk/test/MC/ARM/elf-thumbfunc.s
+++ llvm/trunk/test/MC/ARM/elf-thumbfunc.s
@@ -14,6 +14,9 @@
 	.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 @@
 @CHECK-NEXT:     Type: Function
 
 @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
+
+ at CHECK:        Symbol {
 @CHECK:          Name: foo
 @CHECK-NEXT:     Value: 0x1
 @CHECK-NEXT:     Size: 0
Index: llvm/trunk/lib/MC/MCAssembler.cpp
===================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp
+++ llvm/trunk/lib/MC/MCAssembler.cpp
@@ -114,10 +114,16 @@
   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;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28878.85005.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170119/fe6ffb5a/attachment.bin>


More information about the llvm-commits mailing list