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-Tag: llvmorg-7.0.0-rc1~554 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fdd089aa14d90fcf220d54fb3fbfd2170f89de78;p=platform%2Fupstream%2Fllvm.git [GlobalISel] Fall back to SDISel for swifterror/swiftself attributes. We don't currently support these, fall back until we do. llvm-svn: 337994 --- diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 114c068..07de31b 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/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/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index d481220..bafb7a0 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/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/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll index e0c8860..9c9d22d 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll +++ b/llvm/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 +} + +