Skip to content

Commit f60e693

Browse files
authored
[llvm] Emit canonical linkage correct function symbol (llvm#166487)
In the call graph section, we were emitting the temporary label pointing to the start of the function instead of the canonical linkage correct function symbol. This patch fixes it and updates the corresponding tests.
1 parent 9564b26 commit f60e693

File tree

6 files changed

+6
-11
lines changed

6 files changed

+6
-11
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,6 @@ void AsmPrinter::emitCallGraphSection(const MachineFunction &MF,
17081708
OutStreamer->pushSection();
17091709
OutStreamer->switchSection(FuncCGSection);
17101710

1711-
const MCSymbol *FunctionSymbol = getFunctionBegin();
17121711
const Function &F = MF.getFunction();
17131712
// If this function has external linkage or has its address taken and
17141713
// it is not a callback, then anything could call it.
@@ -1747,7 +1746,7 @@ void AsmPrinter::emitCallGraphSection(const MachineFunction &MF,
17471746
// 8) Each unique indirect target type id.
17481747
OutStreamer->emitInt8(CallGraphSectionFormatVersion::V_0);
17491748
OutStreamer->emitInt8(static_cast<uint8_t>(CGFlags));
1750-
OutStreamer->emitSymbolValue(FunctionSymbol, TM.getProgramPointerSize());
1749+
OutStreamer->emitSymbolValue(getSymbol(&F), TM.getProgramPointerSize());
17511750
const auto *TypeId = extractNumericCGTypeId(F);
17521751
if (IsIndirectTarget && TypeId)
17531752
OutStreamer->emitInt64(TypeId->getZExtValue());

llvm/test/CodeGen/ARM/call-graph-section-addrtaken.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ entry:
1414
}
1515

1616
; CHECK: _ZL10myCallbacki:
17-
; CHECK-NEXT: [[LABEL_FUNC:\.Lfunc_begin[0-9]+]]:
1817
define internal void @_ZL10myCallbacki(i32 %value) !type !2 {
1918
entry:
2019
%sink = alloca i32, align 4
@@ -33,7 +32,7 @@ entry:
3332
;; Flags -- Potential indirect target so LSB is set to 1. Other bits are 0.
3433
; CHECK-NEXT: .byte 1
3534
;; Function Entry PC
36-
; CHECK-NEXT: .long [[LABEL_FUNC]]
35+
; CHECK-NEXT: .long _ZL10myCallbacki
3736
;; Function type ID -5212364466660467813
3837
; CHECK-NEXT: .long 1154849691
3938
; CHECK-NEXT: .long 3081369122

llvm/test/CodeGen/ARM/call-graph-section-assembly.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ declare !type !1 i32 @direct_bar(i8)
1111
declare !type !2 ptr @direct_baz(ptr)
1212

1313
; CHECK: ball:
14-
; CHECK-NEXT: [[LABEL_FUNC:\.Lfunc_begin[0-9]+]]:
1514
define ptr @ball() {
1615
entry:
1716
call void @direct_foo()
@@ -42,7 +41,7 @@ entry:
4241
;; Flags
4342
; CHECK-NEXT: .byte 7
4443
;; Function Entry PC
45-
; CHECK-NEXT: .long [[LABEL_FUNC]]
44+
; CHECK-NEXT: .long ball
4645
;; Function type ID -- set to 0 as no type metadata attached to function.
4746
; CHECK-NEXT: .long 0
4847
; CHECK-NEXT: .long 0

llvm/test/CodeGen/ARM/call-graph-section-tailcall.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ declare !type !2 i32 @bar(i8 signext)
2929

3030
; CHECK: Hex dump of section '.llvm.callgraph':
3131
; CHECK-NEXT: 0x00000000 00050000 00008e19 0b7f3326 e3000154
32-
; CHECK-NEXT: 0x00000010 86bc5981 4b8e3000 05100000 00a150b8
32+
; CHECK-NEXT: 0x00000010 86bc5981 4b8e3000 05000000 00a150b8
3333
;; Verify that the type id 0x308e4b8159bc8654 is in section.
3434
; CHECK-NEXT: 0x00000020 3e0cfe3c b2015486 bc59814b 8e30

llvm/test/CodeGen/X86/call-graph-section-addrtaken.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ entry:
1414
}
1515

1616
; CHECK: _ZL10myCallbacki:
17-
; CHECK-NEXT: [[LABEL_FUNC:\.Lfunc_begin[0-9]+]]:
1817
define internal void @_ZL10myCallbacki(i32 %value) !type !2 {
1918
entry:
2019
%sink = alloca i32, align 4
@@ -33,6 +32,6 @@ entry:
3332
;; Flags -- Potential indirect target so LSB is set to 1. Other bits are 0.
3433
; CHECK-NEXT: .byte 1
3534
;; Function Entry PC
36-
; CHECK-NEXT: .quad [[LABEL_FUNC]]
35+
; CHECK-NEXT: .quad _ZL10myCallbacki
3736
;; Function type ID
3837
; CHECK-NEXT: .quad -5212364466660467813

llvm/test/CodeGen/X86/call-graph-section-assembly.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ declare !type !1 i32 @direct_bar(i8)
1111
declare !type !2 ptr @direct_baz(ptr)
1212

1313
; CHECK: ball:
14-
; CHECK-NEXT: [[LABEL_FUNC:\.Lfunc_begin[0-9]+]]:
1514
define ptr @ball() {
1615
entry:
1716
call void @direct_foo()
@@ -42,7 +41,7 @@ entry:
4241
;; Flags
4342
; CHECK-NEXT: .byte 7
4443
;; Function Entry PC
45-
; CHECK-NEXT: .quad [[LABEL_FUNC]]
44+
; CHECK-NEXT: .quad ball
4645
;; Function type ID -- set to 0 as no type metadata attached to function.
4746
; CHECK-NEXT: .quad 0
4847
;; Number of unique direct callees.

0 commit comments

Comments
 (0)