mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[SVE][CodeGen] Fix bug when falling back to DAG ISel
In an earlier commit 584d0d5c1749c13625a5d322178ccb4121eea610 I added functionality to allow AArch64 CodeGen support for falling back to DAG ISel when Global ISel encounters scalable vector types. However, it seems that we were not falling back early enough as llvm::getLLTForType was still being invoked for scalable vector types. I've added a new fallback function to the call lowering class in order to catch this problem early enough, rather than wait for lowerFormalArguments to reject scalable vector types. Differential Revision: https://reviews.llvm.org/D82524
This commit is contained in:
parent
204220c193
commit
654ddede3d
@ -290,6 +290,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool fallBackToDAGISel(const Function &F) const { return false; }
|
||||
|
||||
/// This hook must be implemented to lower the incoming (formal)
|
||||
/// arguments, described by \p VRegs, for GlobalISel. Each argument
|
||||
/// must end up in the related virtual registers described by \p VRegs.
|
||||
|
@ -2384,6 +2384,14 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {
|
||||
// Make our arguments/constants entry block fallthrough to the IR entry block.
|
||||
EntryBB->addSuccessor(&getMBB(F.front()));
|
||||
|
||||
if (CLI->fallBackToDAGISel(F)) {
|
||||
OptimizationRemarkMissed R("gisel-irtranslator", "GISelFailure",
|
||||
F.getSubprogram(), &F.getEntryBlock());
|
||||
R << "unable to lower function: " << ore::NV("Prototype", F.getType());
|
||||
reportTranslationError(*MF, *TPC, *ORE, R);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Lower the actual args into this basic block.
|
||||
SmallVector<ArrayRef<Register>, 8> VRegArgs;
|
||||
for (const Argument &Arg: F.args()) {
|
||||
|
@ -427,6 +427,14 @@ static void handleMustTailForwardedRegisters(MachineIRBuilder &MIRBuilder,
|
||||
}
|
||||
}
|
||||
|
||||
bool AArch64CallLowering::fallBackToDAGISel(const Function &F) const {
|
||||
if (isa<ScalableVectorType>(F.getReturnType()))
|
||||
return true;
|
||||
return llvm::any_of(F.args(), [](const Argument &A) {
|
||||
return isa<ScalableVectorType>(A.getType());
|
||||
});
|
||||
}
|
||||
|
||||
bool AArch64CallLowering::lowerFormalArguments(
|
||||
MachineIRBuilder &MIRBuilder, const Function &F,
|
||||
ArrayRef<ArrayRef<Register>> VRegs) const {
|
||||
@ -438,9 +446,6 @@ bool AArch64CallLowering::lowerFormalArguments(
|
||||
SmallVector<ArgInfo, 8> SplitArgs;
|
||||
unsigned i = 0;
|
||||
for (auto &Arg : F.args()) {
|
||||
if (isa<ScalableVectorType>(Arg.getType()))
|
||||
return false;
|
||||
|
||||
if (DL.getTypeStoreSize(Arg.getType()).isZero())
|
||||
continue;
|
||||
|
||||
|
@ -37,6 +37,8 @@ public:
|
||||
ArrayRef<Register> VRegs,
|
||||
Register SwiftErrorVReg) const override;
|
||||
|
||||
bool fallBackToDAGISel(const Function &F) const override;
|
||||
|
||||
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F,
|
||||
ArrayRef<ArrayRef<Register>> VRegs) const override;
|
||||
|
||||
|
@ -220,21 +220,30 @@ entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to lower arguments{{.*}}scalable_arg
|
||||
; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to lower function{{.*}}scalable_arg
|
||||
; FALLBACK-WITH-REPORT-OUT-LABEL: scalable_arg
|
||||
define <vscale x 16 x i8> @scalable_arg(<vscale x 16 x i1> %pred, i8* %addr) #1 {
|
||||
%res = call <vscale x 16 x i8> @llvm.aarch64.sve.ld1.nxv16i8(<vscale x 16 x i1> %pred, i8* %addr)
|
||||
ret <vscale x 16 x i8> %res
|
||||
}
|
||||
|
||||
; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to translate instruction{{.*}}scalable_call
|
||||
; FALLBACK-WITH-REPORT-OUT-LABEL: scalable_call
|
||||
define <vscale x 16 x i8> @scalable_call(i8* %addr) #1 {
|
||||
; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to lower function{{.*}}scalable_ret
|
||||
; FALLBACK-WITH-REPORT-OUT-LABEL: scalable_ret
|
||||
define <vscale x 16 x i8> @scalable_ret(i8* %addr) #1 {
|
||||
%pred = call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 0)
|
||||
%res = call <vscale x 16 x i8> @llvm.aarch64.sve.ld1.nxv16i8(<vscale x 16 x i1> %pred, i8* %addr)
|
||||
ret <vscale x 16 x i8> %res
|
||||
}
|
||||
|
||||
; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to translate instruction{{.*}}scalable_call
|
||||
; FALLBACK-WITH-REPORT-OUT-LABEL: scalable_call
|
||||
define i8 @scalable_call(i8* %addr) #1 {
|
||||
%pred = call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 0)
|
||||
%vec = call <vscale x 16 x i8> @llvm.aarch64.sve.ld1.nxv16i8(<vscale x 16 x i1> %pred, i8* %addr)
|
||||
%res = extractelement <vscale x 16 x i8> %vec, i32 0
|
||||
ret i8 %res
|
||||
}
|
||||
|
||||
attributes #1 = { "target-features"="+sve" }
|
||||
|
||||
declare <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 %pattern)
|
||||
|
Loading…
Reference in New Issue
Block a user