[CodeGen] Report error rather than crash when unable to makeLibCall.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Thu, 26 Mar 2015 22:46:58 +0000 (22:46 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Thu, 26 Mar 2015 22:46:58 +0000 (22:46 +0000)
Also, make the assumption explicit in the header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233329 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetLowering.h
lib/CodeGen/SelectionDAG/TargetLowering.cpp

index dd23d8cac56ed1e31c67462ae094753255648e63..29ecedcc6432841e08b0adaf473f8d17e416022b 100644 (file)
@@ -2030,6 +2030,7 @@ public:
                            ISD::CondCode &CCCode, SDLoc DL) const;
 
   /// Returns a pair of (return value, chain).
+  /// It is an error to pass RTLIB::UNKNOWN_LIBCALL as \p LC.
   std::pair<SDValue, SDValue> makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC,
                                           EVT RetVT, const SDValue *Ops,
                                           unsigned NumOps, bool isSigned,
index c382fe0d6fb9f7bebb76869e6a386fec0c972110..ddbf0b2dd532311b7c7424723de37068e937b4f9 100644 (file)
@@ -100,6 +100,8 @@ TargetLowering::makeLibCall(SelectionDAG &DAG,
     Entry.isZExt = !shouldSignExtendTypeInLibCall(Ops[i].getValueType(), isSigned);
     Args.push_back(Entry);
   }
+  if (LC == RTLIB::UNKNOWN_LIBCALL)
+    report_fatal_error("Unsupported library call operation!");
   SDValue Callee = DAG.getExternalSymbol(getLibcallName(LC), getPointerTy());
 
   Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());