Use the vanilla func_end symbol for .size.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 4 Mar 2015 01:35:23 +0000 (01:35 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 4 Mar 2015 01:35:23 +0000 (01:35 +0000)
No need to create yet another temp symbol.

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

lib/CodeGen/AsmPrinter/AsmPrinter.cpp
test/CodeGen/PowerPC/empty-functions.ll
test/CodeGen/PowerPC/ppc64-linux-func-size.ll
test/CodeGen/SPARC/empty-functions.ll
test/CodeGen/X86/empty-functions.ll
test/CodeGen/X86/statepoint-call-lowering.ll
test/DebugInfo/X86/debug-loc-asan.ll
test/DebugInfo/X86/pr19307.ll

index da66bc91ec01241aa35f1f2df6c820d887a0fb14..3721458d6995b759e09e2182112f63d3abf84dc2 100644 (file)
@@ -882,7 +882,7 @@ void AsmPrinter::EmitFunctionBody() {
   // Emit target-specific gunk after the function body.
   EmitFunctionBodyEnd();
 
-  if (!MMI->getLandingPads().empty()) {
+  if (!MMI->getLandingPads().empty() || MAI->hasDotTypeDotSizeDirective()) {
     // Create a symbol for the end of function.
     CurrentFnEnd = createTempSymbol("func_end", getFunctionNumber());
     OutStreamer.EmitLabel(CurrentFnEnd);
@@ -891,13 +891,10 @@ void AsmPrinter::EmitFunctionBody() {
   // If the target wants a .size directive for the size of the function, emit
   // it.
   if (MAI->hasDotTypeDotSizeDirective()) {
-    // Create a symbol for the end of function, so we can get the size as
-    // difference between the function label and the temp label.
-    MCSymbol *FnEndLabel = OutContext.CreateTempSymbol();
-    OutStreamer.EmitLabel(FnEndLabel);
-
+    // We can get the size as difference between the function label and the
+    // temp label.
     const MCExpr *SizeExp =
-      MCBinaryExpr::CreateSub(MCSymbolRefExpr::Create(FnEndLabel, OutContext),
+      MCBinaryExpr::CreateSub(MCSymbolRefExpr::Create(CurrentFnEnd, OutContext),
                               MCSymbolRefExpr::Create(CurrentFnSymForSize,
                                                       OutContext),
                               OutContext);
index e32a8472b8356154bfd84bc9e3f1d3984c9431f6..41fe5094daf586c69a4e3d6a11e0c5b84ad81656 100644 (file)
@@ -39,5 +39,5 @@ entry:
 ; LINUX-FP-NEXT:{{^}}.L{{.*}}:{{$}}
 ; LINUX-FP-NEXT: .cfi_def_cfa_register r31
 ; LINUX-FP-NEXT:{{^}}.L{{.*}}:{{$}}
-; LINUX-FP-NEXT: .size   func, .Ltmp3-func
+; LINUX-FP-NEXT: .size   func, .Lfunc_end0-func
 ; LINUX-FP-NEXT: .cfi_endproc
index e1d50bac51a2ca6f4a9c8f6266f8f388609eb46c..21d5bddeb4cd4c527e8db68aa7f31e343705a63f 100644 (file)
@@ -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, .Ltmp0-.L.test1
+; CHECK: .size test1, .Lfunc_end0-.L.test1
index 38d288903d4a68b0f1d0014ab433a35b056c0561..1f8c5e3a312d0fe6659eb0d06df47a0a85da6a68 100644 (file)
@@ -28,5 +28,5 @@ entry:
 ; LINUX-FP-NEXT: {{^}}.L{{.*}}:{{$}}
 ; LINUX-FP-NEXT: .cfi_register 15, 31
 ; LINUX-FP-NEXT: {{^}}.L{{.*}}:{{$}}
-; LINUX-FP-NEXT: .size   func, .Ltmp3-func
+; LINUX-FP-NEXT: .size   func, .Lfunc_end0-func
 ; LINUX-FP-NEXT: .cfi_endproc
index 42349688a710747e46a77e24a57d034716122691..735df2a4196d585fb077028d20357e2c7d2e337b 100644 (file)
@@ -50,5 +50,5 @@ entry:
 ; LINUX-FP-NEXT:{{^}}.L{{.*}}:{{$}}
 ; LINUX-FP-NEXT: .cfi_def_cfa_register %rbp
 ; LINUX-FP-NEXT:{{^}}.L{{.*}}:{{$}}
-; LINUX-FP-NEXT: .size   func, .Ltmp3-func
+; LINUX-FP-NEXT: .size   func, .Lfunc_end0-func
 ; LINUX-FP-NEXT: .cfi_endproc
index e1a1369534ff257bbc5dad434a1a722701506df3..22049cfa385b1c8e39415e32dd8b1022c3fe62b0 100644 (file)
@@ -66,7 +66,7 @@ define i1 @test_relocate(i32 addrspace(1)* %a) gc "statepoint-example" {
 ; Check that an ununsed relocate has no code-generation impact
 ; CHECK: pushq %rax
 ; CHECK: callq return_i1
-; CHECK-NEXT: .Ltmp13:
+; CHECK-NEXT: .Ltmp9:
 ; CHECK-NEXT: popq %rdx
 ; CHECK-NEXT: retq
 entry:
index b15668a7547c592d114b97010b024e7b4ce7e480..4a087f342f3d38b566651a6951d6d09c3b5ce69f 100644 (file)
@@ -28,7 +28,7 @@
 
 ; Then it's addressed via %rsp:
 ; CHECK:      .quad [[START_LABEL]]-.Lfunc_begin0
-; CHECK-NEXT: .Lfunc_end0-.Lfunc_begin0
+; CHECK-NEXT: .Lfunc_end06-.Lfunc_begin0
 ; CHECK: DW_OP_breg7
 ; CHECK-NEXT: [[OFFSET]]
 ; CHECK: DW_OP_deref
index e673f1d7cf3e7922d72a118761ff30e8a0754f78..13023ac8b8f68d4fdb34bed672bb0b7cee557741 100644 (file)
@@ -21,7 +21,7 @@
 ; CHECK: .Ldebug_loc{{[0-9]+}}:
 ; CHECK: DW_OP_breg1
 ; CHECK:      .quad [[START_LABEL]]-.Lfunc_begin0
-; CHECK-NEXT: .quad .Lfunc_end0-.Lfunc_begin0
+; CHECK-NEXT: .quad .Lfunc_end09-.Lfunc_begin0
 ; CHECK: DW_OP_breg6
 ; CHECK: DW_OP_deref