From 530fa5fcc973c0e1ac5801563a42f69ffffa0c6c Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Mon, 3 Oct 2016 04:06:44 +0000 Subject: [PowerPC] Account for the ELFv2 function prologue during branch selection The PPC branch-selection pass, which performs branch relaxation, needs to account for the padding that might be introduced to satisfy block alignment requirements. We were assuming that the first block was at offset zero (i.e. had the alignment of the function itself), but under the ELFv2 ABI, a global entry function prologue is added to the first block, and it is a two-instruction sequence (i.e. eight-bytes long). If the function has 16-byte alignment, the fact that the first block is eight bytes offset from the start of the function is relevant to calculating where padding will be added in between later blocks. Unfortunately, I don't have a small test case. llvm-svn: 283086 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp') diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index e5c93950604..5e742cf4e6f 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1199,6 +1199,9 @@ void PPCLinuxAsmPrinter::EmitFunctionBodyStart() { if (Subtarget->isELFv2ABI() // Only do all that if the function uses r2 in the first place. && !MF->getRegInfo().use_empty(PPC::X2)) { + // Note: The logic here must be synchronized with the code in the + // branch-selection pass which sets the offset of the first block in the + // function. This matters because it affects the alignment. const PPCFunctionInfo *PPCFI = MF->getInfo(); MCSymbol *GlobalEntryLabel = PPCFI->getGlobalEPSymbol(); -- cgit v1.2.3