From 2e2dbc35dafda95c2cfff335d3d02556742c848d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 5 Mar 2015 18:55:50 +0000 Subject: [PATCH] Use the generic Lfunc_begin label on ppc. This removes yet another custom label to mark the start of a function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231390 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 4 ++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 6 +- lib/MC/MCAsmInfo.cpp | 1 + .../PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp | 4 ++ lib/Target/PowerPC/PPCAsmPrinter.cpp | 5 -- test/CodeGen/PowerPC/empty-functions.ll | 10 ++-- test/CodeGen/PowerPC/ppc64-anyregcc.ll | 41 +++++++++++--- test/CodeGen/PowerPC/ppc64-linux-func-size.ll | 4 +- test/CodeGen/PowerPC/ppc64-stackmap.ll | 56 +++++++++++++++---- test/CodeGen/PowerPC/ppc64le-localentry.ll | 3 + 10 files changed, 103 insertions(+), 31 deletions(-) diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index ee245e94ac9..1e9817ea48d 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -118,6 +118,9 @@ protected: // Print the EH begin symbol with an assignment. Defaults to false. bool UseAssignmentForEHBegin; + // Do we need to create a local symbol for .size? + bool NeedsLocalForSize; + /// This prefix is used for globals like constant pool entries that are /// completely private to the .s file and should not have names in the .o /// file. Defaults to "L" @@ -427,6 +430,7 @@ public: const char *getLabelSuffix() const { return LabelSuffix; } bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; } + bool needsLocalForSize() const { return NeedsLocalForSize; } const char *getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; } const char *getPrivateLabelPrefix() const { return PrivateLabelPrefix; } bool hasLinkerPrivateGlobalPrefix() const { diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 0f9edf1d0e9..2a132e56132 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -556,8 +556,12 @@ void AsmPrinter::EmitFunctionHeader() { OutStreamer.EmitLabel(DeadBlockSyms[i]); } - if (!MMI->getLandingPads().empty() || MMI->hasDebugInfo()) { + bool NeedsLocalForSize = MAI->needsLocalForSize(); + if (!MMI->getLandingPads().empty() || MMI->hasDebugInfo() || + NeedsLocalForSize) { CurrentFnBegin = createTempSymbol("func_begin", getFunctionNumber()); + if (NeedsLocalForSize) + CurrentFnSymForSize = CurrentFnBegin; if (MAI->useAssignmentForEHBegin()) { MCSymbol *CurPos = OutContext.CreateTempSymbol(); diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp index 04b804209a7..8a7ee94a593 100644 --- a/lib/MC/MCAsmInfo.cpp +++ b/lib/MC/MCAsmInfo.cpp @@ -39,6 +39,7 @@ MCAsmInfo::MCAsmInfo() { CommentString = "#"; LabelSuffix = ":"; UseAssignmentForEHBegin = false; + NeedsLocalForSize = false; PrivateGlobalPrefix = "L"; PrivateLabelPrefix = PrivateGlobalPrefix; LinkerPrivateGlobalPrefix = ""; diff --git a/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp b/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp index 2b4f2d81db8..d8fab5b7c01 100644 --- a/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp +++ b/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp @@ -45,6 +45,10 @@ PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit, const Triple& T) { void PPCELFMCAsmInfo::anchor() { } PPCELFMCAsmInfo::PPCELFMCAsmInfo(bool is64Bit, const Triple& T) { + // FIXME: This is not always needed. For example, it is not needed in the + // v2 abi. + NeedsLocalForSize = true; + if (is64Bit) { PointerSize = CalleeSaveStackSlotSize = 8; } diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index 13272908b12..93bf99898d0 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1082,11 +1082,6 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() { // Emit a null environment pointer. OutStreamer.EmitIntValue(0, 8 /* size */); OutStreamer.SwitchSection(Current.first, Current.second); - - MCSymbol *RealFnSym = OutContext.GetOrCreateSymbol( - ".L." + Twine(CurrentFnSym->getName())); - OutStreamer.EmitLabel(RealFnSym); - CurrentFnSymForSize = RealFnSym; } diff --git a/test/CodeGen/PowerPC/empty-functions.ll b/test/CodeGen/PowerPC/empty-functions.ll index 41fe5094daf..aa760d82b1c 100644 --- a/test/CodeGen/PowerPC/empty-functions.ll +++ b/test/CodeGen/PowerPC/empty-functions.ll @@ -17,16 +17,18 @@ entry: ; An empty function is perfectly fine on ELF. ; LINUX-NO-FP: func: +; LINUX-NO-FP-NEXT: {{^}}.L[[BEGIN:.*]]:{{$}} ; LINUX-NO-FP-NEXT: .cfi_startproc ; LINUX-NO-FP-NEXT: {{^}}# -; LINUX-NO-FP-NEXT: {{^}}.L{{.*}}:{{$}} -; LINUX-NO-FP-NEXT: .size func, .L{{.*}}-func +; LINUX-NO-FP-NEXT: {{^}}.L[[END:.*]]:{{$}} +; LINUX-NO-FP-NEXT: .size func, .L[[END]]-.L[[BEGIN]] ; LINUX-NO-FP-NEXT: .cfi_endproc ; A cfi directive can point to the end of a function. It (and in fact the ; entire body) could be optimized out because of the unreachable, but we ; don't do it right now. ; LINUX-FP: func: +; LINUX-FP-NEXT: {{^}}.L[[BEGIN:.*]]:{{$}} ; LINUX-FP-NEXT: .cfi_startproc ; LINUX-FP-NEXT: {{^}}# ; LINUX-FP-NEXT: stw 31, -4(1) @@ -38,6 +40,6 @@ entry: ; LINUX-FP-NEXT: mr 31, 1 ; LINUX-FP-NEXT:{{^}}.L{{.*}}:{{$}} ; LINUX-FP-NEXT: .cfi_def_cfa_register r31 -; LINUX-FP-NEXT:{{^}}.L{{.*}}:{{$}} -; LINUX-FP-NEXT: .size func, .Lfunc_end0-func +; LINUX-FP-NEXT: {{^}}.L[[END:.*]]:{{$}} +; LINUX-FP-NEXT: .size func, .L[[END]]-.L[[BEGIN]] ; LINUX-FP-NEXT: .cfi_endproc diff --git a/test/CodeGen/PowerPC/ppc64-anyregcc.ll b/test/CodeGen/PowerPC/ppc64-anyregcc.ll index 8b4cec5dabd..ab2feb64981 100644 --- a/test/CodeGen/PowerPC/ppc64-anyregcc.ll +++ b/test/CodeGen/PowerPC/ppc64-anyregcc.ll @@ -2,6 +2,31 @@ target datalayout = "E-m:e-i64:64-n32:64" target triple = "powerpc64-unknown-linux-gnu" +; CHECK-LABEL: test: +; CHECK: {{^}}.L[[test_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: property_access1: +; CHECK: {{^}}.L[[property_access1_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: property_access2: +; CHECK: {{^}}.L[[property_access2_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: property_access3: +; CHECK: {{^}}.L[[property_access3_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: anyreg_test1: +; CHECK: {{^}}.L[[anyreg_test1_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: anyreg_test2: +; CHECK: {{^}}.L[[anyreg_test2_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: patchpoint_spilldef: +; CHECK: {{^}}.L[[patchpoint_spilldef_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: patchpoint_spillargs: +; CHECK: {{^}}.L[[patchpoint_spillargs_BEGIN:.*]]:{{$}} + + ; Stackmap Header: no constants - 6 callsites ; CHECK-LABEL: .section .llvm_stackmaps ; CHECK-NEXT: __LLVM_StackMaps: @@ -36,7 +61,7 @@ target triple = "powerpc64-unknown-linux-gnu" ; test -; CHECK-LABEL: .long .L{{.*}}-.L.test +; CHECK: .long .L{{.*}}-.L[[test_BEGIN]] ; CHECK-NEXT: .short 0 ; 3 locations ; CHECK-NEXT: .short 3 @@ -62,7 +87,7 @@ entry: } ; property access 1 - %obj is an anyreg call argument and should therefore be in a register -; CHECK-LABEL: .long .L{{.*}}-.L.property_access1 +; CHECK: .long .L{{.*}}-.L[[property_access1_BEGIN]] ; CHECK-NEXT: .short 0 ; 2 locations ; CHECK-NEXT: .short 2 @@ -84,7 +109,7 @@ entry: } ; property access 2 - %obj is an anyreg call argument and should therefore be in a register -; CHECK-LABEL: .long .L{{.*}}-.L.property_access2 +; CHECK: .long .L{{.*}}-.L[[property_access2_BEGIN]] ; CHECK-NEXT: .short 0 ; 2 locations ; CHECK-NEXT: .short 2 @@ -107,7 +132,7 @@ entry: } ; property access 3 - %obj is a frame index -; CHECK-LABEL: .long .L{{.*}}-.L.property_access3 +; CHECK: .long .L{{.*}}-.L[[property_access3_BEGIN]] ; CHECK-NEXT: .short 0 ; 2 locations ; CHECK-NEXT: .short 2 @@ -130,7 +155,7 @@ entry: } ; anyreg_test1 -; CHECK-LABEL: .long .L{{.*}}-.L.anyreg_test1 +; CHECK: .long .L{{.*}}-.L[[anyreg_test1_BEGIN]] ; CHECK-NEXT: .short 0 ; 14 locations ; CHECK-NEXT: .short 14 @@ -212,7 +237,7 @@ entry: } ; anyreg_test2 -; CHECK-LABEL: .long .L{{.*}}-.L.anyreg_test2 +; CHECK: .long .L{{.*}}-.L[[anyreg_test2_BEGIN]] ; CHECK-NEXT: .short 0 ; 14 locations ; CHECK-NEXT: .short 14 @@ -297,7 +322,7 @@ entry: ; ; [JS] Assertion: "Folded a def to a non-store!" ; -; CHECK-LABEL: .long .L{{.*}}-.L.patchpoint_spilldef +; CHECK: .long .L{{.*}}-.L[[patchpoint_spilldef_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 3 ; Loc 0: Register (some register that will be spilled to the stack) @@ -327,7 +352,7 @@ entry: ; ; [JS] AnyRegCC argument ends up being spilled ; -; CHECK-LABEL: .long .L{{.*}}-.L.patchpoint_spillargs +; CHECK: .long .L{{.*}}-.L[[patchpoint_spillargs_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 5 ; Loc 0: Return a register diff --git a/test/CodeGen/PowerPC/ppc64-linux-func-size.ll b/test/CodeGen/PowerPC/ppc64-linux-func-size.ll index 21d5bddeb4c..04e0dfcd05c 100644 --- a/test/CodeGen/PowerPC/ppc64-linux-func-size.ll +++ b/test/CodeGen/PowerPC/ppc64-linux-func-size.ll @@ -7,7 +7,7 @@ ; CHECK-NEXT: .quad .TOC.@tocbase ; CHECK-NEXT: .quad 0 ; CHECK-NEXT: .text -; CHECK-NEXT: .L.test1: +; CHECK-NEXT: .L[[BEGIN:.*]]: define i32 @test1(i32 %a) nounwind { entry: @@ -19,4 +19,4 @@ entry: ; however, using this directive with recent binutils will result in the error: ; .size expression for XXX does not evaluate to a constant ; so we must use the label which actually tags the start of the function. -; CHECK: .size test1, .Lfunc_end0-.L.test1 +; CHECK: .size test1, .Lfunc_end0-.L[[BEGIN]] diff --git a/test/CodeGen/PowerPC/ppc64-stackmap.ll b/test/CodeGen/PowerPC/ppc64-stackmap.ll index 714d363388f..bc974a08d01 100644 --- a/test/CodeGen/PowerPC/ppc64-stackmap.ll +++ b/test/CodeGen/PowerPC/ppc64-stackmap.ll @@ -7,6 +7,40 @@ target datalayout = "E-m:e-i64:64-n32:64" target triple = "powerpc64-unknown-linux-gnu" +; CHECK-LABEL: constantargs: +; CHECK: {{^}}.L[[constantargs_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: osrinline: +; CHECK: {{^}}.L[[osrinline_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: osrcold: +; CHECK: {{^}}.L[[osrcold_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: propertyRead: +; CHECK: {{^}}.L[[propertyRead_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: propertyWrite: +; CHECK: {{^}}.L[[propertyWrite_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: jsVoidCall: +; CHECK: {{^}}.L[[jsVoidCall_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: jsIntCall: +; CHECK: {{^}}.L[[jsIntCall_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: spilledValue: +; CHECK: {{^}}.L[[spilledValue_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: spilledStackMapValue: +; CHECK: {{^}}.L[[spilledStackMapValue_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: liveConstant: +; CHECK: {{^}}.L[[liveConstant_BEGIN:.*]]:{{$}} + +; CHECK-LABEL: clobberLR: +; CHECK: {{^}}.L[[clobberLR_BEGIN:.*]]:{{$}} + + ; CHECK-LABEL: .section .llvm_stackmaps ; CHECK-NEXT: __LLVM_StackMaps: ; Header @@ -51,7 +85,7 @@ target triple = "powerpc64-unknown-linux-gnu" ; Constant arguments ; ; CHECK-NEXT: .quad 1 -; CHECK-NEXT: .long .L{{.*}}-.L.constantargs +; CHECK-NEXT: .long .L{{.*}}-.L[[constantargs_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 4 ; SmallConstant @@ -84,7 +118,7 @@ entry: ; Inline OSR Exit ; -; CHECK-LABEL: .long .L{{.*}}-.L.osrinline +; CHECK: .long .L{{.*}}-.L[[osrinline_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 2 ; CHECK-NEXT: .byte 1 @@ -108,7 +142,7 @@ entry: ; ; 2 live variables in register. ; -; CHECK-LABEL: .long .L{{.*}}-.L.osrcold +; CHECK: .long .L{{.*}}-.L[[osrcold_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 2 ; CHECK-NEXT: .byte 1 @@ -133,7 +167,7 @@ ret: } ; Property Read -; CHECK-LABEL: .long .L{{.*}}-.L.propertyRead +; CHECK: .long .L{{.*}}-.L[[propertyRead_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 0 ; @@ -148,7 +182,7 @@ entry: } ; Property Write -; CHECK-LABEL: .long .L{{.*}}-.L.propertyWrite +; CHECK: .long .L{{.*}}-.L[[propertyWrite_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 2 ; CHECK-NEXT: .byte 1 @@ -170,7 +204,7 @@ entry: ; ; 2 live variables in registers. ; -; CHECK-LABEL: .long .L{{.*}}-.L.jsVoidCall +; CHECK: .long .L{{.*}}-.L[[jsVoidCall_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 2 ; CHECK-NEXT: .byte 1 @@ -192,7 +226,7 @@ entry: ; ; 2 live variables in registers. ; -; CHECK-LABEL: .long .L{{.*}}-.L.jsIntCall +; CHECK: .long .L{{.*}}-.L[[jsIntCall_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 2 ; CHECK-NEXT: .byte 1 @@ -215,7 +249,7 @@ entry: ; ; Verify 28 stack map entries. ; -; CHECK-LABEL: .long .L{{.*}}-.L.spilledValue +; CHECK: .long .L{{.*}}-.L[[spilledValue_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 28 ; @@ -234,7 +268,7 @@ entry: ; ; Verify 30 stack map entries. ; -; CHECK-LABEL: .long .L{{.*}}-.L.spilledStackMapValue +; CHECK: .long .L{{.*}}-.L[[spilledStackMapValue_BEGIN]] ; CHECK-NEXT: .short 0 ; CHECK-NEXT: .short 30 ; @@ -252,7 +286,7 @@ entry: ; Map a constant value. ; -; CHECK-LABEL: .long .L{{.*}}-.L.liveConstant +; CHECK: .long .L{{.*}}-.L[[liveConstant_BEGIN]] ; CHECK-NEXT: .short 0 ; 1 location ; CHECK-NEXT: .short 1 @@ -269,7 +303,7 @@ define void @liveConstant() { ; Map a value when LR is the only free register. ; -; CHECK-LABEL: .long .L{{.*}}-.L.clobberLR +; CHECK: .long .L{{.*}}-.L[[clobberLR_BEGIN]] ; CHECK-NEXT: .short 0 ; 1 location ; CHECK-NEXT: .short 1 diff --git a/test/CodeGen/PowerPC/ppc64le-localentry.ll b/test/CodeGen/PowerPC/ppc64le-localentry.ll index 73697b24ace..be64f115176 100644 --- a/test/CodeGen/PowerPC/ppc64le-localentry.ll +++ b/test/CodeGen/PowerPC/ppc64le-localentry.ll @@ -16,6 +16,7 @@ target triple = "powerpc64le-unknown-linux-gnu" define i64 @use_toc(i64 %a) nounwind { entry: ; CHECK-LABEL: @use_toc +; CHECK-NEXT: .L{{.*}}: ; CHECK-NEXT: .Ltmp[[TMP1:[0-9]+]]: ; CHECK-NEXT: addis 2, 12, .TOC.-.Ltmp[[TMP1]]@ha ; CHECK-NEXT: addi 2, 2, .TOC.-.Ltmp[[TMP1]]@l @@ -32,6 +33,7 @@ declare void @callee() define void @use_toc_implicit() nounwind { entry: ; CHECK-LABEL: @use_toc_implicit +; CHECK-NEXT: .L{{.*}}: ; CHECK-NEXT: .Ltmp[[TMP1:[0-9]+]]: ; CHECK-NEXT: addis 2, 12, .TOC.-.Ltmp[[TMP1]]@ha ; CHECK-NEXT: addi 2, 2, .TOC.-.Ltmp[[TMP1]]@l @@ -45,6 +47,7 @@ entry: define i64 @no_toc(i64 %a) nounwind { entry: ; CHECK-LABEL: @no_toc +; CHECK-NEXT: .L{{.*}}: ; CHECK-NEXT: %entry ret i64 %a } -- 2.34.1