Index: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp =================================================================== --- lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -465,6 +465,7 @@ void emitPad(int64_t Offset); void emitRegSave(const SmallVectorImpl &RegList, bool isVector); void emitUnwindRaw(int64_t Offset, const SmallVectorImpl &Opcodes); + void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc) override; void ChangeSection(MCSection *Section, const MCExpr *Subsection) override { LastMappingSymbols[getCurrentSection().first] = std::move(LastEMSInfo); @@ -1475,6 +1476,16 @@ UnwindOpAsm.EmitRaw(Opcodes); } +void ARMELFStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue, + SMLoc Loc) { + if (LastEMSInfo->State == EMS_None) { + EmitMappingSymbol("$d"); + LastEMSInfo->State = EMS_Data; + } else + EmitDataMappingSymbol(); + MCObjectStreamer::emitFill(NumBytes, FillValue, Loc); +} + namespace llvm { MCTargetStreamer *createARMTargetAsmStreamer(MCStreamer &S, Index: test/CodeGen/ARM/CheckDataSymbol.ll =================================================================== --- /dev/null +++ test/CodeGen/ARM/CheckDataSymbol.ll @@ -0,0 +1,47 @@ +; RUN: llc -filetype=obj -mtriple=thumbv7-arm-none-eabi -o - %s | llvm-readobj -s -t - | FileCheck %s +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "thumbv7-arm-none-eabi" + +%struct.S = type { i32 } + +@.str = private unnamed_addr constant [4 x i8] c"%p\0A\00", align 1 +@defaultS = internal constant %struct.S zeroinitializer, align 4 #0 + +define hidden void @f(i8* %p) local_unnamed_addr { +entry: + %0 = tail call i32 (i8*, ...) @__2printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* %p) + ret void +} + +define hidden void @g() local_unnamed_addr #1 { +entry: + %0 = tail call i32 (i8*, ...) @__2printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* bitcast (%struct.S* @defaultS to i8*)) + ret void +} + +define hidden i32 @main() local_unnamed_addr { +entry: + %0 = tail call i32 (i8*, ...) @__2printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* bitcast (%struct.S* @defaultS to i8*)) + ret i32 0 +} + +declare i32 @__2printf(i8*, ...) + +attributes #0 = { "rodata-section"="os_code" } +attributes #1 = { "implicit-section-name"="os_code" } + +; CHECK: Name: $d.{{[0-9]+ \([1-9][0-9]*\)}} +; CHECK-NEXT: Value: [[POSITION:0x[1-9][0-9]*]] +; CHECK-NEXT: Size: 0 +; CHECK-NEXT: Binding: Local (0x0) +; CHECK-NEXT: Type: None (0x0) +; CHECK-NEXT: Other: 0 +; CHECK-NEXT: Section: os_code (0x6) +; CHECK: Name: defaultS ({{[1-9][0-9]*}}) +; CHECK-NEXT: Value: [[POSITION]] +; CHECK-NEXT: Size: 4 +; CHECK-NEXT: Binding: Local (0x0) +; CHECK-NEXT: Type: Object (0x1) +; CHECK-NEXT: Other: 0 +; CHECK-NEXT: Section: os_code (0x6) +; CHECK-NEXT: } Index: test/CodeGen/ARM/CheckDataSymbol.s =================================================================== --- /dev/null +++ test/CodeGen/ARM/CheckDataSymbol.s @@ -0,0 +1,117 @@ +# RUN: clang -c -target arm-arm-none-eabi -mcpu=cortex-a9 -O2 -mthumb %s -o - | llvm-readobj -s -t - | FileCheck %s +# CHECK: Name: $d.{{[0-9]+ \([1-9][0-9]*\)}} +# CHECK-NEXT: Value: [[POSITION:0x[1-9][0-9]*]] +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Local (0x0) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: os_code (0x6) +# CHECK: Name: defaultS ({{[1-9][0-9]*}}) +# CHECK-NEXT: Value: [[POSITION]] +# CHECK-NEXT: Size: 4 +# CHECK-NEXT: Binding: Local (0x0) +# CHECK-NEXT: Type: Object (0x1) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: os_code (0x6) +# CHECK-NEXT: } + .text + .syntax unified + .eabi_attribute 67, "2.09" + .cpu cortex-a9 + .eabi_attribute 6, 10 + .eabi_attribute 7, 65 + .eabi_attribute 8, 1 + .eabi_attribute 9, 2 + .fpu neon-fp16 + .eabi_attribute 36, 1 + .eabi_attribute 42, 1 + .eabi_attribute 34, 0 + .eabi_attribute 68, 1 + .eabi_attribute 17, 1 + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 38, 1 + .eabi_attribute 18, 4 + .eabi_attribute 26, 2 + .eabi_attribute 14, 0 + .file "thumb-data.c" + .globl f + .p2align 1 + .type f,%function + .code 16 + .thumb_func +f: + .fnstart + mov r1, r0 + movw r0, :lower16:.L.str + movt r0, :upper16:.L.str + b printf +.Lfunc_end0: + .size f, .Lfunc_end0-f + .cantunwind + .fnend + + .section os_code,"ax",%progbits + .globl g + .p2align 1 + .type g,%function + .code 16 + .thumb_func +g: + .fnstart + movw r0, :lower16:.L.str + movw r1, :lower16:defaultS + movt r0, :upper16:.L.str + movt r1, :upper16:defaultS + b printf +.Lfunc_end1: + .size g, .Lfunc_end1-g + .cantunwind + .fnend + + .text + .globl main + .p2align 1 + .type main,%function + .code 16 + .thumb_func +main: + .fnstart + .save {r7, lr} + push {r7, lr} + .setfp r7, sp + mov r7, sp + movw r0, :lower16:.L.str + movw r1, :lower16:defaultS + movt r0, :upper16:.L.str + movt r1, :upper16:defaultS + bl printf + movs r0, #0 + pop {r7, pc} +.Lfunc_end2: + .size main, .Lfunc_end2-main + .cantunwind + .fnend + + .type .L.str,%object + .section .rodata.str1.1,"aMS",%progbits,1 +.L.str: + .asciz "%p\n" + .size .L.str, 4 + + .type defaultS,%object + .section os_code,"ax",%progbits + .p2align 2 +defaultS: + .zero 4 + .size defaultS, 4 + + + .ident "clang version 8.0.0 (trunk 340934)" + .section ".note.GNU-stack","",%progbits + .addrsig + .addrsig_sym defaultS + .eabi_attribute 30, 1