Don't barf on empty basic blocks. Do not rely on assert
[oota-llvm.git] / lib / VMCore / Core.cpp
index 34a0e13a2bee64f85c4538843e0001d2a3f01aa5..61ff6a8c00d66747eca9996cb36a833beca68504 100644 (file)
@@ -562,7 +562,6 @@ void LLVMSetThreadLocal(LLVMValueRef GlobalVar, int IsThreadLocal) {
 }
 
 int LLVMIsGlobalConstant(LLVMValueRef GlobalVar) {
-  bool res = unwrap<GlobalVariable>(GlobalVar)->isConstant();
   return unwrap<GlobalVariable>(GlobalVar)->isConstant();
 }
 
@@ -684,6 +683,27 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
   assert(0 && "LLVMSetInstructionCallConv applies only to call and invoke!");
 }
 
+/*--.. Operations on phi nodes .............................................--*/
+
+void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
+                     LLVMBasicBlockRef *IncomingBlocks, unsigned Count) {
+  PHINode *PhiVal = unwrap<PHINode>(PhiNode);
+  for (unsigned I = 0; I != Count; ++I)
+    PhiVal->addIncoming(unwrap(IncomingValues[I]), unwrap(IncomingBlocks[I]));
+}
+
+unsigned LLVMCountIncoming(LLVMValueRef PhiNode) {
+  return unwrap<PHINode>(PhiNode)->getNumIncomingValues();
+}
+
+LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index) {
+  return wrap(unwrap<PHINode>(PhiNode)->getIncomingValue(Index));
+}
+
+LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index) {
+  return wrap(unwrap<PHINode>(PhiNode)->getIncomingBlock(Index));
+}
+
 
 /*===-- Instruction builders ----------------------------------------------===*/