diff --git a/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index 738fa2b204d..d94d33ad24f 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -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() { diff --git a/test/MC/Mips/elf_st_other.s b/test/MC/Mips/elf_st_other.s index eb685c3760c..579707b6be3 100644 --- a/test/MC/Mips/elf_st_other.s +++ b/test/MC/Mips/elf_st_other.s @@ -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