diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index 639d48e342ef3..f523324854445 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -4249,7 +4249,8 @@ class TargetLowering : public TargetLoweringBase { IsInReg = Call.hasRetAttr(Attribute::InReg); DoesNotReturn = Call.doesNotReturn() || - (!isa(Call) && isa(Call.getNextNode())); + (!isa(Call) && !isa(Call) && + isa(Call.getNextNode())); IsVarArg = FTy->isVarArg(); IsReturnValueUsed = !Call.use_empty(); RetSExt = Call.hasRetAttr(Attribute::SExt); diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h index 628445fe9fb2c..f5a932ba9944b 100644 --- a/llvm/include/llvm/IR/DiagnosticInfo.h +++ b/llvm/include/llvm/IR/DiagnosticInfo.h @@ -20,6 +20,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/IR/DebugLoc.h" +#include "llvm/IR/Instructions.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/SourceMgr.h" @@ -1096,7 +1097,7 @@ class DiagnosticInfoSrcMgr : public DiagnosticInfo { } }; -void diagnoseDontCall(const CallInst &CI); +void diagnoseDontCall(const CallBase &CI); class DiagnosticInfoDontCall : public DiagnosticInfo { StringRef CalleeName; diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 7d811dc0ad8f5..c4e4c463c2fc1 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2640,8 +2640,13 @@ bool IRTranslator::translateInvoke(const User &U, bool IRTranslator::translateCallBr(const User &U, MachineIRBuilder &MIRBuilder) { - // FIXME: Implement this. - return false; + const CallBrInst &I = cast(U); + + if (I.isInlineAsm()) { + return translateInlineAsm(I, MIRBuilder); + } else { + return translateCallBase(I, MIRBuilder); + } } bool IRTranslator::translateLandingPad(const User &U, diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 4c7cb8589c453..330fac54bc6e6 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -3044,8 +3044,8 @@ void SelectionDAGBuilder::visitCallBr(const CallBrInst &I) { {LLVMContext::OB_deopt, LLVMContext::OB_funclet}) && "Cannot lower callbrs with arbitrary operand bundles yet!"); - assert(I.isInlineAsm() && "Only know how to handle inlineasm callbr"); - visitInlineAsm(I); + // assert(I.isInlineAsm() && "Only know how to handle inlineasm callbr"); + visitCall(I); CopyToExportRegsIfNeeded(&I); // Retrieve successors. @@ -8092,7 +8092,7 @@ void SelectionDAGBuilder::processIntegerCallValue(const Instruction &I, /// normal call. /// The caller already checked that \p I calls the appropriate LibFunc with a /// correct prototype. -bool SelectionDAGBuilder::visitMemCmpBCmpCall(const CallInst &I) { +bool SelectionDAGBuilder::visitMemCmpBCmpCall(const CallBase &I) { const Value *LHS = I.getArgOperand(0), *RHS = I.getArgOperand(1); const Value *Size = I.getArgOperand(2); const ConstantSDNode *CSize = dyn_cast(getValue(Size)); @@ -8184,7 +8184,7 @@ bool SelectionDAGBuilder::visitMemCmpBCmpCall(const CallInst &I) { /// normal call. /// The caller already checked that \p I calls the appropriate LibFunc with a /// correct prototype. -bool SelectionDAGBuilder::visitMemChrCall(const CallInst &I) { +bool SelectionDAGBuilder::visitMemChrCall(const CallBase &I) { const Value *Src = I.getArgOperand(0); const Value *Char = I.getArgOperand(1); const Value *Length = I.getArgOperand(2); @@ -8208,7 +8208,7 @@ bool SelectionDAGBuilder::visitMemChrCall(const CallInst &I) { /// normal call. /// The caller already checked that \p I calls the appropriate LibFunc with a /// correct prototype. -bool SelectionDAGBuilder::visitMemPCpyCall(const CallInst &I) { +bool SelectionDAGBuilder::visitMemPCpyCall(const CallBase &I) { SDValue Dst = getValue(I.getArgOperand(0)); SDValue Src = getValue(I.getArgOperand(1)); SDValue Size = getValue(I.getArgOperand(2)); @@ -8249,7 +8249,7 @@ bool SelectionDAGBuilder::visitMemPCpyCall(const CallInst &I) { /// normal call. /// The caller already checked that \p I calls the appropriate LibFunc with a /// correct prototype. -bool SelectionDAGBuilder::visitStrCpyCall(const CallInst &I, bool isStpcpy) { +bool SelectionDAGBuilder::visitStrCpyCall(const CallBase &I, bool isStpcpy) { const Value *Arg0 = I.getArgOperand(0), *Arg1 = I.getArgOperand(1); const SelectionDAGTargetInfo &TSI = DAG.getSelectionDAGInfo(); @@ -8272,7 +8272,7 @@ bool SelectionDAGBuilder::visitStrCpyCall(const CallInst &I, bool isStpcpy) { /// normal call. /// The caller already checked that \p I calls the appropriate LibFunc with a /// correct prototype. -bool SelectionDAGBuilder::visitStrCmpCall(const CallInst &I) { +bool SelectionDAGBuilder::visitStrCmpCall(const CallBase &I) { const Value *Arg0 = I.getArgOperand(0), *Arg1 = I.getArgOperand(1); const SelectionDAGTargetInfo &TSI = DAG.getSelectionDAGInfo(); @@ -8295,7 +8295,7 @@ bool SelectionDAGBuilder::visitStrCmpCall(const CallInst &I) { /// normal call. /// The caller already checked that \p I calls the appropriate LibFunc with a /// correct prototype. -bool SelectionDAGBuilder::visitStrLenCall(const CallInst &I) { +bool SelectionDAGBuilder::visitStrLenCall(const CallBase &I) { const Value *Arg0 = I.getArgOperand(0); const SelectionDAGTargetInfo &TSI = DAG.getSelectionDAGInfo(); @@ -8316,7 +8316,7 @@ bool SelectionDAGBuilder::visitStrLenCall(const CallInst &I) { /// normal call. /// The caller already checked that \p I calls the appropriate LibFunc with a /// correct prototype. -bool SelectionDAGBuilder::visitStrNLenCall(const CallInst &I) { +bool SelectionDAGBuilder::visitStrNLenCall(const CallBase &I) { const Value *Arg0 = I.getArgOperand(0), *Arg1 = I.getArgOperand(1); const SelectionDAGTargetInfo &TSI = DAG.getSelectionDAGInfo(); @@ -8338,7 +8338,7 @@ bool SelectionDAGBuilder::visitStrNLenCall(const CallInst &I) { /// false and it will be lowered like a normal call. /// The caller already checked that \p I calls the appropriate LibFunc with a /// correct prototype. -bool SelectionDAGBuilder::visitUnaryFloatCall(const CallInst &I, +bool SelectionDAGBuilder::visitUnaryFloatCall(const CallBase &I, unsigned Opcode) { // We already checked this call's prototype; verify it doesn't modify errno. if (!I.onlyReadsMemory()) @@ -8358,7 +8358,7 @@ bool SelectionDAGBuilder::visitUnaryFloatCall(const CallInst &I, /// false, and it will be lowered like a normal call. /// The caller already checked that \p I calls the appropriate LibFunc with a /// correct prototype. -bool SelectionDAGBuilder::visitBinaryFloatCall(const CallInst &I, +bool SelectionDAGBuilder::visitBinaryFloatCall(const CallBase &I, unsigned Opcode) { // We already checked this call's prototype; verify it doesn't modify errno. if (!I.onlyReadsMemory()) @@ -8374,7 +8374,7 @@ bool SelectionDAGBuilder::visitBinaryFloatCall(const CallInst &I, return true; } -void SelectionDAGBuilder::visitCall(const CallInst &I) { +void SelectionDAGBuilder::visitCall(const CallBase &I) { // Handle inline assembly differently. if (I.isInlineAsm()) { visitInlineAsm(I); @@ -8392,7 +8392,8 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { IID = II->getIntrinsicID(F); if (IID) { - visitIntrinsicCall(I, IID); + assert(isa(I) && "Don't know how to handle intrinsic callbr"); + visitIntrinsicCall(cast(I), IID); return; } } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index bf21110134611..68979309afcc7 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -598,16 +598,16 @@ class SelectionDAGBuilder { void visitAtomicRMW(const AtomicRMWInst &I); void visitFence(const FenceInst &I); void visitPHI(const PHINode &I); - void visitCall(const CallInst &I); - bool visitMemCmpBCmpCall(const CallInst &I); - bool visitMemPCpyCall(const CallInst &I); - bool visitMemChrCall(const CallInst &I); - bool visitStrCpyCall(const CallInst &I, bool isStpcpy); - bool visitStrCmpCall(const CallInst &I); - bool visitStrLenCall(const CallInst &I); - bool visitStrNLenCall(const CallInst &I); - bool visitUnaryFloatCall(const CallInst &I, unsigned Opcode); - bool visitBinaryFloatCall(const CallInst &I, unsigned Opcode); + void visitCall(const CallBase &I); + bool visitMemCmpBCmpCall(const CallBase &I); + bool visitMemPCpyCall(const CallBase &I); + bool visitMemChrCall(const CallBase &I); + bool visitStrCpyCall(const CallBase &I, bool isStpcpy); + bool visitStrCmpCall(const CallBase &I); + bool visitStrLenCall(const CallBase &I); + bool visitStrNLenCall(const CallBase &I); + bool visitUnaryFloatCall(const CallBase &I, unsigned Opcode); + bool visitBinaryFloatCall(const CallBase &I, unsigned Opcode); void visitAtomicLoad(const LoadInst &I); void visitAtomicStore(const StoreInst &I); void visitLoadFromSwiftError(const LoadInst &I); diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp index fb238e2aac59c..ad0e304b18e62 100644 --- a/llvm/lib/IR/DiagnosticInfo.cpp +++ b/llvm/lib/IR/DiagnosticInfo.cpp @@ -415,7 +415,7 @@ void DiagnosticInfoMisExpect::print(DiagnosticPrinter &DP) const { void OptimizationRemarkAnalysisFPCommute::anchor() {} void OptimizationRemarkAnalysisAliasing::anchor() {} -void llvm::diagnoseDontCall(const CallInst &CI) { +void llvm::diagnoseDontCall(const CallBase &CI) { const auto *F = dyn_cast(CI.getCalledOperand()->stripPointerCasts()); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5426fb20e09ce..72d9313b19a94 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -2907,11 +2907,11 @@ void Verifier::visitIndirectBrInst(IndirectBrInst &BI) { } void Verifier::visitCallBrInst(CallBrInst &CBI) { - Check(CBI.isInlineAsm(), "Callbr is currently only used for asm-goto!", &CBI); - const InlineAsm *IA = cast(CBI.getCalledOperand()); - Check(!IA->canThrow(), "Unwinding from Callbr is not allowed"); + // Check(CBI.isInlineAsm(), "Callbr is currently only used for asm-goto!", &CBI); + // const InlineAsm *IA = cast(CBI.getCalledOperand()); + // Check(!IA->canThrow(), "Unwinding from Callbr is not allowed"); - verifyInlineAsmCall(CBI); + if (CBI.isInlineAsm()) verifyInlineAsmCall(CBI); visitTerminator(CBI); }