[PATCH] D84761: [XCOFF][AIX] Put each jump table in an independent section if -ffunction-sections is specified
Jason Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 07:31:57 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe5062a6caf75: [XCOFF][AIX] Put each jump table in an independent section if -ffunction… (authored by jasonliu).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84761/new/
https://reviews.llvm.org/D84761
Files:
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
Index: llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
+++ llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
@@ -26,6 +26,12 @@
; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -code-model=large < %s | FileCheck \
; RUN: --check-prefixes=64LARGE-ASM,CHECK %s
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff -function-sections < %s | FileCheck \
+; RUN: --check-prefixes=FUNC-ASM,CHECK %s
+
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -function-sections < %s | FileCheck \
+; RUN: --check-prefixes=FUNC-ASM,CHECK %s
+
define i32 @jump_table(i32 %a) {
entry:
switch i32 %a, label %sw.epilog [
@@ -184,5 +190,21 @@
; 64LARGE-ASM: .vbyte 4, L..BB0_4-L..JTI0_0
; 64LARGE-ASM: .vbyte 4, L..BB0_5-L..JTI0_0
+; FUNC-ASM: .csect .jump_table[PR],2
+; FUNC-ASM: L..BB0_2:
+; FUNC-ASM: L..BB0_3:
+; FUNC-ASM: L..BB0_4:
+; FUNC-ASM: L..BB0_5:
+; FUNC-ASM: L..BB0_6:
+; FUNC-ASM: li 3, 0
+; FUNC-ASM: blr
+; FUNC-ASM: .csect .rodata.jmp..jump_table[RO],2
+; FUNC-ASM: .align 2
+; FUNC-ASM: L..JTI0_0:
+; FUNC-ASM: .vbyte 4, L..BB0_2-L..JTI0_0
+; FUNC-ASM: .vbyte 4, L..BB0_3-L..JTI0_0
+; FUNC-ASM: .vbyte 4, L..BB0_4-L..JTI0_0
+; FUNC-ASM: .vbyte 4, L..BB0_5-L..JTI0_0
+
; CHECK: .toc
; CHECK: .tc L..JTI0_0[TC],L..JTI0_0
Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -2085,11 +2085,18 @@
MCSection *TargetLoweringObjectFileXCOFF::getSectionForJumpTable(
const Function &F, const TargetMachine &TM) const {
- assert (!TM.getFunctionSections() && "Unique sections not supported on XCOFF"
- " yet.");
assert (!F.getComdat() && "Comdat not supported on XCOFF.");
- //TODO: Enable emiting jump table to unique sections when we support it.
- return ReadOnlySection;
+
+ if (!TM.getFunctionSections())
+ return ReadOnlySection;
+
+ // If the function can be removed, produce a unique section so that
+ // the table doesn't prevent the removal.
+ SmallString<128> NameStr(".rodata.jmp..");
+ getNameWithPrefix(NameStr, &F, TM);
+ return getContext().getXCOFFSection(NameStr, XCOFF::XMC_RO, XCOFF::XTY_SD,
+ XCOFF::C_HIDEXT,
+ SectionKind::getReadOnly());
}
bool TargetLoweringObjectFileXCOFF::shouldPutJumpTableInFunctionSection(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84761.283603.patch
Type: text/x-patch
Size: 2632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200806/b66fc764/attachment.bin>
More information about the llvm-commits
mailing list