Only mark functions as micromips.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 15 Jan 2014 03:07:12 +0000 (03:07 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 15 Jan 2014 03:07:12 +0000 (03:07 +0000)
The GNU as behavior is a bit different and very strange. It will mark any
label that contains an instruction. We can implement that, but using the
type looks more natural since gas will not mark a function if a .word is
used to output the instructions!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199287 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
test/MC/Mips/elf_st_other.s

index 738fa2b204da521c5cf8ad717124559edcd33df8..d94d33ad24fcef0c79baf04cc5e71a52ccc86c4c 100644 (file)
@@ -68,12 +68,17 @@ void MipsTargetAsmStreamer::emitDirectiveOptionPic0() {
 MipsTargetELFStreamer::MipsTargetELFStreamer() {}
 
 void MipsTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
+  if (!isMicroMipsEnabled())
+    return;
   MCSymbolData &Data = getStreamer().getOrCreateSymbolData(Symbol);
+  uint8_t Type = MCELF::GetType(Data);
+  if (Type != ELF::STT_FUNC)
+    return;
+
   // The "other" values are stored in the last 6 bits of the second byte
   // The traditional defines for STO values assume the full byte and thus
   // the shift to pack it.
-  if (isMicroMipsEnabled())
-    MCELF::setOther(Data, ELF::STO_MIPS_MICROMIPS >> 2);
+  MCELF::setOther(Data, ELF::STO_MIPS_MICROMIPS >> 2);
 }
 
 MCELFStreamer &MipsTargetELFStreamer::getStreamer() {
index eb685c3760cf49d61ba00264cc371f24e48776da..579707b6be38535d225915509b89c2268598bb95 100644 (file)
@@ -2,15 +2,24 @@
 
 
 .globl f1
+.type f1, @function
 .set micromips
 f1:
        nop
 
+.globl d1
+.type d1, @object
+d1:
+.word 42
+
 .globl f2
+.type f2, @function
 .set nomicromips
 f2:
        nop
 
+// CHECK-LABEL: Name: d1
+// CHECK:       Other: 0
 // CHECK-LABEL: Name: f1
 // CHECK:       Other: 128
 // CHECK-LABEL: Name: f2