From bee70bfff0f41a1cea5010276cf4a6229c2c3b93 Mon Sep 17 00:00:00 2001 From: jasonliu Date: Mon, 24 Feb 2020 15:46:11 +0000 Subject: [PATCH] [XCOFF][AIX] Fix incorrect alignment for function descriptor csect Summary: Function descriptor csect on AIX should be 4 byte align instead of 1 byte align. Reviewer: daltenty Differential Revision: https://reviews.llvm.org/D74974 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 3 ++- llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll | 2 +- llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index 00ffc120ce00..885c625557d5 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1547,9 +1547,10 @@ void PPCLinuxAsmPrinter::emitFunctionBodyEnd() { void PPCAIXAsmPrinter::SetupMachineFunction(MachineFunction &MF) { // Get the function descriptor symbol. CurrentFnDescSym = getSymbol(&MF.getFunction()); - // Set the containing csect. + // Set the alignment and the containing csect. MCSectionXCOFF *FnDescSec = cast( getObjFileLowering().getSectionForFunctionDescriptor(CurrentFnDescSym)); + FnDescSec->setAlignment(Align(Subtarget->isPPC64() ? 8 : 4)); cast(CurrentFnDescSym)->setContainingCsect(FnDescSec); return AsmPrinter::SetupMachineFunction(MF); diff --git a/llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll b/llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll index 29b2d4c454c4..d983c8de54a9 100644 --- a/llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll +++ b/llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll @@ -63,7 +63,7 @@ entry: ; CHECK-NEXT: SectionLen: 12 ; CHECK-NEXT: ParameterHashIndex: 0x0 ; CHECK-NEXT: TypeChkSectNum: 0x0 -; CHECK-NEXT: SymbolAlignmentLog2: 0 +; CHECK-NEXT: SymbolAlignmentLog2: 2 ; CHECK-NEXT: SymbolType: XTY_SD (0x1) ; CHECK-NEXT: StorageMappingClass: XMC_DS (0xA) ; CHECK-NEXT: StabInfoIndex: 0x0 diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll index 0b8f43f9c791..1cb4c1f3e32b 100644 --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll @@ -318,7 +318,7 @@ declare i32 @bar(i32) ; SYM-NEXT: SectionLen: 12 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 -; SYM-NEXT: SymbolAlignmentLog2: 0 +; SYM-NEXT: SymbolAlignmentLog2: 2 ; SYM-NEXT: SymbolType: XTY_SD (0x1) ; SYM-NEXT: StorageMappingClass: XMC_DS (0xA) ; SYM-NEXT: StabInfoIndex: 0x0 -- 2.34.1