From: Amara Emerson Date: Thu, 26 Jul 2018 01:25:58 +0000 (+0000) Subject: [GlobalISel] Fall back to SDISel for swifterror/swiftself attributes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a145774c76ef75206356f92dd4c1b2c0d8dea896;p=llvm [GlobalISel] Fall back to SDISel for swifterror/swiftself attributes. We don't currently support these, fall back until we do. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337994 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/GlobalISel/CallLowering.cpp b/lib/CodeGen/GlobalISel/CallLowering.cpp index 114c068749e..07de31bec66 100644 --- a/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -38,6 +38,9 @@ bool CallLowering::lowerCall( ArgInfo OrigArg{ArgRegs[i], Arg->getType(), ISD::ArgFlagsTy{}, i < NumFixedArgs}; setArgFlags(OrigArg, i + AttributeList::FirstArgIndex, DL, CS); + // We don't currently support swifterror or swiftself args. + if (OrigArg.Flags.isSwiftError() || OrigArg.Flags.isSwiftSelf()) + return false; OrigArgs.push_back(OrigArg); ++i; } diff --git a/lib/CodeGen/GlobalISel/IRTranslator.cpp b/lib/CodeGen/GlobalISel/IRTranslator.cpp index d4812202498..bafb7a05536 100644 --- a/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -1157,6 +1157,9 @@ bool IRTranslator::translateAlloca(const User &U, MachineIRBuilder &MIRBuilder) { auto &AI = cast(U); + if (AI.isSwiftError()) + return false; + if (AI.isStaticAlloca()) { unsigned Res = getOrCreateVReg(AI); int FI = getOrCreateFrameIndex(AI); @@ -1574,6 +1577,18 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) { MRI->createGenericVirtualRegister(getLLTForType(*Arg.getType(), *DL))); } + // We don't currently support translating swifterror or swiftself functions. + for (auto &Arg : F.args()) { + if (Arg.hasSwiftErrorAttr() || Arg.hasSwiftSelfAttr()) { + OptimizationRemarkMissed R("gisel-irtranslator", "GISelFailure", + F.getSubprogram(), &F.getEntryBlock()); + R << "unable to lower arguments due to swifterror/swiftself: " + << ore::NV("Prototype", F.getType()); + reportTranslationError(*MF, *TPC, *ORE, R); + return false; + } + } + if (!CLI->lowerFormalArguments(EntryBuilder, F, VRegArgs)) { OptimizationRemarkMissed R("gisel-irtranslator", "GISelFailure", F.getSubprogram(), &F.getEntryBlock()); diff --git a/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll b/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll index e0c88609fed..9c9d22d8ff6 100644 --- a/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll +++ b/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll @@ -235,3 +235,26 @@ define void @nonpow2_vector_add_fewerelements() { store i64 %ex, i64* undef ret void } + +%swift_error = type {i64, i8} + +; FALLBACK-WITH-REPORT-ERR: remark: :0:0: unable to lower arguments due to swifterror/swiftself: void (%swift_error**)* (in function: swifterror_param) +; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for swifterror_param +define void @swifterror_param(%swift_error** swifterror %error_ptr_ref) { + ret void +} + +; FALLBACK-WITH-REPORT-ERR: remark: :0:0: unable to translate instruction: alloca: ' %error_ptr_ref = alloca swifterror %swift_error*' (in function: swifterror_alloca) +; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for swifterror_alloca +; We can't currently test the call parameters being swifterror because the value +; must come from a swifterror alloca or parameter, at which point we already +; fallback. As long as those cases work however we should be fine. +define void @swifterror_alloca(i8* %error_ref) { +entry: + %error_ptr_ref = alloca swifterror %swift_error* + store %swift_error* null, %swift_error** %error_ptr_ref + call void @swifterror_param(%swift_error** swifterror %error_ptr_ref) + ret void +} + +