Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/include/llvm/CodeGen/TargetLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -4249,7 +4249,8 @@ class TargetLowering : public TargetLoweringBase {
IsInReg = Call.hasRetAttr(Attribute::InReg);
DoesNotReturn =
Call.doesNotReturn() ||
(!isa<InvokeInst>(Call) && isa<UnreachableInst>(Call.getNextNode()));
(!isa<InvokeInst>(Call) && !isa<CallBrInst>(Call) &&
isa<UnreachableInst>(Call.getNextNode()));
IsVarArg = FTy->isVarArg();
IsReturnValueUsed = !Call.use_empty();
RetSExt = Call.hasRetAttr(Attribute::SExt);
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/IR/DiagnosticInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -1096,7 +1097,7 @@ class DiagnosticInfoSrcMgr : public DiagnosticInfo {
}
};

void diagnoseDontCall(const CallInst &CI);
void diagnoseDontCall(const CallBase &CI);

class DiagnosticInfoDontCall : public DiagnosticInfo {
StringRef CalleeName;
Expand Down
9 changes: 7 additions & 2 deletions llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CallBrInst>(U);

if (I.isInlineAsm()) {
return translateInlineAsm(I, MIRBuilder);
} else {
return translateCallBase(I, MIRBuilder);
}
}

bool IRTranslator::translateLandingPad(const User &U,
Expand Down
27 changes: 14 additions & 13 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<ConstantSDNode>(getValue(Size));
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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())
Expand All @@ -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())
Expand All @@ -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);
Expand All @@ -8392,7 +8392,8 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
IID = II->getIntrinsicID(F);

if (IID) {
visitIntrinsicCall(I, IID);
assert(isa<CallInst>(I) && "Don't know how to handle intrinsic callbr");
visitIntrinsicCall(cast<CallInst>(I), IID);
return;
}
}
Expand Down
20 changes: 10 additions & 10 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/DiagnosticInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Function>(CI.getCalledOperand()->stripPointerCasts());

Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<InlineAsm>(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<InlineAsm>(CBI.getCalledOperand());
// Check(!IA->canThrow(), "Unwinding from Callbr is not allowed");

verifyInlineAsmCall(CBI);
if (CBI.isInlineAsm()) verifyInlineAsmCall(CBI);
visitTerminator(CBI);
}

Expand Down