From ed16b27e92ff70152d25baa6d19e4754aab637fa Mon Sep 17 00:00:00 2001 From: Sean Fertile Date: Fri, 26 Jul 2019 17:25:27 +0000 Subject: [PATCH] [PowerPC][AIX]Add lowering of MCSymbol MachineOperand. Adds machine operand lowering for MCSymbolSDNodes to the PowerPC backend. This is needed to produce call instructions in assembly for AIX because the callee operand is a MCSymbolSDNode. The test is XFAIL'ed for asserts due to a (valid) assertion in PEI that the AIX ABI isn't supported yet. Differential Revision: https://reviews.llvm.org/D63738 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367133 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 3 +++ lib/Target/PowerPC/PPCMCInstLower.cpp | 3 +++ test/CodeGen/PowerPC/test_call_aix.ll | 13 +++++++++++++ 3 files changed, 19 insertions(+) diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index ba2c78c3b93..a3bf69ae4ef 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1843,6 +1843,9 @@ MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal( Kind, /* BeginSymbolName */ nullptr); } + if (Kind.isText()) + return TextSection; + report_fatal_error("XCOFF other section types not yet implemented."); } diff --git a/lib/Target/PowerPC/PPCMCInstLower.cpp b/lib/Target/PowerPC/PPCMCInstLower.cpp index 027e6bd1ba0..32b9818e70b 100644 --- a/lib/Target/PowerPC/PPCMCInstLower.cpp +++ b/lib/Target/PowerPC/PPCMCInstLower.cpp @@ -193,6 +193,9 @@ bool llvm::LowerPPCMachineOperandToMCOperand(const MachineOperand &MO, OutMO = GetSymbolRef(MO, AP.GetBlockAddressSymbol(MO.getBlockAddress()), AP, isDarwin); return true; + case MachineOperand::MO_MCSymbol: + OutMO = GetSymbolRef(MO, MO.getMCSymbol(), AP, isDarwin); + return true; case MachineOperand::MO_RegisterMask: return false; } diff --git a/test/CodeGen/PowerPC/test_call_aix.ll b/test/CodeGen/PowerPC/test_call_aix.ll index 6f98843e92b..81133a5b529 100644 --- a/test/CodeGen/PowerPC/test_call_aix.ll +++ b/test/CodeGen/PowerPC/test_call_aix.ll @@ -1,9 +1,14 @@ +; XFAIL: asserts + ; RUN: llc -mtriple powerpc-ibm-aix-xcoff -stop-after=machine-cp < %s | \ ; RUN: FileCheck --check-prefix=32BIT %s ; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -stop-after=machine-cp < %s | \ ; RUN: FileCheck --check-prefix=64BIT %s +; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s +; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s + declare void @foo(...) define void @test_call() { @@ -16,6 +21,10 @@ entry: ; 64BIT: BL8_NOP , csr_aix64, implicit-def dead $lr8, implicit $rm, implicit $x2, implicit-def $r1 ; 64BIT: ADJCALLSTACKUP 112, 0, implicit-def dead $r1, implicit $r1 +; CHECK-LABEL: test_call +; CHECK: bl .foo +; CHECK-NEXT: nop + call void bitcast (void (...)* @foo to void ()*)() ret void } @@ -35,6 +44,10 @@ entry: ; 64BIT: BL8 , csr_aix64, implicit-def dead $lr8, implicit $rm, implicit $x2, implicit-def $r1 ; 64BIT: ADJCALLSTACKUP 112, 0, implicit-def dead $r1, implicit $r1 +; CHECK-LABEL: test_local_call +; CHECK: bl .foo_local +; CHECK-NOT: nop + call void @foo_local() ret void } -- 2.40.0