From: Ahmed Bougacha Date: Fri, 10 Mar 2017 00:25:35 +0000 (+0000) Subject: [GlobalISel] Fallback when failing to translate invoke. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=60bc0e71032b4eb746e8b4585e53c7cd6b867c4d;p=llvm [GlobalISel] Fallback when failing to translate invoke. We unintentionally stopped falling back in r293670. While there, change an unusual construct. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297425 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/GlobalISel/IRTranslator.cpp b/lib/CodeGen/GlobalISel/IRTranslator.cpp index b2ab3c12bc1..1e8f6c222d7 100644 --- a/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -787,7 +787,7 @@ bool IRTranslator::translateInvoke(const User &U, const BasicBlock *ReturnBB = I.getSuccessor(0); const BasicBlock *EHPadBB = I.getSuccessor(1); - const Value *Callee(I.getCalledValue()); + const Value *Callee = I.getCalledValue(); const Function *Fn = dyn_cast(Callee); if (isa(Callee)) return false; @@ -815,8 +815,9 @@ bool IRTranslator::translateInvoke(const User &U, for (auto &Arg: I.arg_operands()) Args.push_back(getOrCreateVReg(*Arg)); - CLI->lowerCall(MIRBuilder, I, Res, Args, - [&]() { return getOrCreateVReg(*I.getCalledValue()); }); + if (!CLI->lowerCall(MIRBuilder, I, Res, Args, + [&]() { return getOrCreateVReg(*I.getCalledValue()); })) + return false; MCSymbol *EndSymbol = Context.createTempSymbol(); MIRBuilder.buildInstr(TargetOpcode::EH_LABEL).addSym(EndSymbol); diff --git a/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll b/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll index 4510f5cf054..087faa293de 100644 --- a/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll +++ b/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll @@ -118,3 +118,23 @@ define void @test_write_register_intrin() { call void @llvm.write_register.i64(metadata !{!"sp"}, i64 0) ret void } + +@_ZTIi = external global i8* +declare i32 @__gxx_personality_v0(...) + +; Check that we fallback on invoke translation failures. +; FALLBACK-WITH-REPORT-ERR: remark: :0:0: unable to translate instruction: invoke: ' invoke void %callee(i128 0) +; FALLBACK-WITH-REPORT-NEXT: to label %continue unwind label %broken' (in function: invoke_weird_type) +; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for invoke_weird_type +; FALLBACK-WITH-REPORT-OUT-LABEL: invoke_weird_type: +define void @invoke_weird_type(void(i128)* %callee) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { + invoke void %callee(i128 0) + to label %continue unwind label %broken + +broken: + landingpad { i8*, i32 } catch i8* bitcast(i8** @_ZTIi to i8*) + ret void + +continue: + ret void +}