changeset 190:b1364f705114

relax tail call error on goto from normal function. args.c worked.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 06 Jun 2020 13:15:35 +0900
parents 390e42bfd95a
children d6e74ee136ee
files llvm/include/llvm/IR/Instructions.h llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/lib/IR/Instructions.cpp
diffstat 3 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/llvm/include/llvm/IR/Instructions.h	Sat Jun 06 00:15:13 2020 +0900
+++ b/llvm/include/llvm/IR/Instructions.h	Sat Jun 06 13:15:35 2020 +0900
@@ -1366,6 +1366,7 @@
 /// hold the calling convention of the call.
 ///
 class CallInst : public CallBase {
+  int count;
   CallInst(const CallInst &CI);
 
   /// Construct a CallInst given a range of arguments.
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp	Sat Jun 06 00:15:13 2020 +0900
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp	Sat Jun 06 13:15:35 2020 +0900
@@ -7163,8 +7163,11 @@
 #ifndef noCbC
   // if code segment's tail call flag was changed false , we report it on error.
   if (RetTy->is__CodeTy() && !isTailCall ) {
-      LLVMContext &Ctx = *DAG.getContext();
-      Ctx.emitError(&CB, "tail call failed on __code");
+      if (CB.getCaller()->getReturnType()->is__CodeTy()) {
+          // LLVMContext &Ctx = *DAG.getContext();
+          //- Ctx.emitError(&CB, "tail call failed on __code");
+          errs() << "tail call failed on __code " + CB.getCaller()->getName() ;
+      }
   }
 #endif
   std::pair<SDValue, SDValue> Result = lowerInvokable(CLI, EHPadBB);
@@ -10633,3 +10636,13 @@
   setValue(&I, DAG.getNode(ISD::MERGE_VALUES, getCurSDLoc(),
                            DAG.getVTList(ValueVTs), Values));
 }
+
+void printInsts(Instruction* inst) { // useless on const Instruction* inst
+  BasicBlock::iterator it(inst);
+  ++it; // After this line, it refers to the instruction after *inst
+  if (it != inst->getParent()->end()) errs() << *it << "\n";
+}
+
+void printInst(Instruction it) {
+  errs() << it << "\n";
+}
--- a/llvm/lib/IR/Instructions.cpp	Sat Jun 06 00:15:13 2020 +0900
+++ b/llvm/lib/IR/Instructions.cpp	Sat Jun 06 13:15:35 2020 +0900
@@ -423,8 +423,11 @@
 //                        CallInst Implementation
 //===----------------------------------------------------------------------===//
 
+static int call_count = 0;
+
 void CallInst::init(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args,
                     ArrayRef<OperandBundleDef> Bundles, const Twine &NameStr) {
+  this->count = call_count++;
   this->FTy = FTy;
   assert(getNumOperands() == Args.size() + CountBundleInputs(Bundles) + 1 &&
          "NumOperands not set up?");
@@ -451,6 +454,7 @@
 }
 
 void CallInst::init(FunctionType *FTy, Value *Func, const Twine &NameStr) {
+  this->count = call_count++;
   this->FTy = FTy;
   assert(getNumOperands() == 1 && "NumOperands not set up?");
   setCalledOperand(Func);