forked from OSchip/llvm-project
Use report_fatal_error more consistently in the C API echo test
llvm-svn: 260849
This commit is contained in:
parent
c679dbd344
commit
d01c8614dc
|
@ -155,10 +155,8 @@ struct TypeCloner {
|
||||||
|
|
||||||
static ValueMap clone_params(LLVMValueRef Src, LLVMValueRef Dst) {
|
static ValueMap clone_params(LLVMValueRef Src, LLVMValueRef Dst) {
|
||||||
unsigned Count = LLVMCountParams(Src);
|
unsigned Count = LLVMCountParams(Src);
|
||||||
if (Count != LLVMCountParams(Dst)) {
|
if (Count != LLVMCountParams(Dst))
|
||||||
fprintf(stderr, "Parameter count mismatch\n");
|
report_fatal_error("Parameter count mismatch");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueMap VMap;
|
ValueMap VMap;
|
||||||
if (Count == 0)
|
if (Count == 0)
|
||||||
|
@ -183,49 +181,32 @@ static ValueMap clone_params(LLVMValueRef Src, LLVMValueRef Dst) {
|
||||||
SrcNext = LLVMGetNextParam(SrcCur);
|
SrcNext = LLVMGetNextParam(SrcCur);
|
||||||
DstNext = LLVMGetNextParam(DstCur);
|
DstNext = LLVMGetNextParam(DstCur);
|
||||||
if (SrcNext == nullptr && DstNext == nullptr) {
|
if (SrcNext == nullptr && DstNext == nullptr) {
|
||||||
if (SrcCur != SrcLast) {
|
if (SrcCur != SrcLast)
|
||||||
fprintf(stderr, "SrcLast param does not match End\n");
|
report_fatal_error("SrcLast param does not match End");
|
||||||
exit(-1);
|
if (DstCur != DstLast)
|
||||||
}
|
report_fatal_error("DstLast param does not match End");
|
||||||
|
|
||||||
if (DstCur != DstLast) {
|
|
||||||
fprintf(stderr, "DstLast param does not match End\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SrcNext == nullptr) {
|
if (SrcNext == nullptr)
|
||||||
fprintf(stderr, "SrcNext was unexpectedly null\n");
|
report_fatal_error("SrcNext was unexpectedly null");
|
||||||
exit(-1);
|
if (DstNext == nullptr)
|
||||||
}
|
report_fatal_error("DstNext was unexpectedly null");
|
||||||
|
|
||||||
if (DstNext == nullptr) {
|
|
||||||
fprintf(stderr, "DstNext was unexpectedly null\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
LLVMValueRef SrcPrev = LLVMGetPreviousParam(SrcNext);
|
LLVMValueRef SrcPrev = LLVMGetPreviousParam(SrcNext);
|
||||||
if (SrcPrev != SrcCur) {
|
if (SrcPrev != SrcCur)
|
||||||
fprintf(stderr, "SrcNext.Previous param is not Current\n");
|
report_fatal_error("SrcNext.Previous param is not Current");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
LLVMValueRef DstPrev = LLVMGetPreviousParam(DstNext);
|
LLVMValueRef DstPrev = LLVMGetPreviousParam(DstNext);
|
||||||
if (DstPrev != DstCur) {
|
if (DstPrev != DstCur)
|
||||||
fprintf(stderr, "DstNext.Previous param is not Current\n");
|
report_fatal_error("DstNext.Previous param is not Current");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SrcCur = SrcNext;
|
SrcCur = SrcNext;
|
||||||
DstCur = DstNext;
|
DstCur = DstNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Count != 0) {
|
if (Count != 0)
|
||||||
fprintf(stderr, "Parameter count does not match iteration\n");
|
report_fatal_error("Parameter count does not match iteration");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return VMap;
|
return VMap;
|
||||||
}
|
}
|
||||||
|
@ -515,12 +496,11 @@ struct FunCloner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Name = LLVMGetBasicBlockName(Src);
|
|
||||||
|
|
||||||
LLVMValueRef V = LLVMBasicBlockAsValue(Src);
|
LLVMValueRef V = LLVMBasicBlockAsValue(Src);
|
||||||
if (!LLVMValueIsBasicBlock(V) || LLVMValueAsBasicBlock(V) != Src)
|
if (!LLVMValueIsBasicBlock(V) || LLVMValueAsBasicBlock(V) != Src)
|
||||||
report_fatal_error("Basic block is not a basic block");
|
report_fatal_error("Basic block is not a basic block");
|
||||||
|
|
||||||
|
const char *Name = LLVMGetBasicBlockName(Src);
|
||||||
const char *VName = LLVMGetValueName(V);
|
const char *VName = LLVMGetValueName(V);
|
||||||
if (Name != VName)
|
if (Name != VName)
|
||||||
report_fatal_error("Basic block name mismatch");
|
report_fatal_error("Basic block name mismatch");
|
||||||
|
@ -541,11 +521,8 @@ struct FunCloner {
|
||||||
LLVMValueRef Last = LLVMGetLastInstruction(Src);
|
LLVMValueRef Last = LLVMGetLastInstruction(Src);
|
||||||
|
|
||||||
if (First == nullptr) {
|
if (First == nullptr) {
|
||||||
if (Last != nullptr) {
|
if (Last != nullptr)
|
||||||
fprintf(stderr, "Has no first instruction, but last one\n");
|
report_fatal_error("Has no first instruction, but last one");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return BB;
|
return BB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,19 +536,14 @@ struct FunCloner {
|
||||||
CloneInstruction(Cur, Builder);
|
CloneInstruction(Cur, Builder);
|
||||||
Next = LLVMGetNextInstruction(Cur);
|
Next = LLVMGetNextInstruction(Cur);
|
||||||
if (Next == nullptr) {
|
if (Next == nullptr) {
|
||||||
if (Cur != Last) {
|
if (Cur != Last)
|
||||||
fprintf(stderr, "Final instruction does not match Last\n");
|
report_fatal_error("Final instruction does not match Last");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef Prev = LLVMGetPreviousInstruction(Next);
|
LLVMValueRef Prev = LLVMGetPreviousInstruction(Next);
|
||||||
if (Prev != Cur) {
|
if (Prev != Cur)
|
||||||
fprintf(stderr, "Next.Previous instruction is not Current\n");
|
report_fatal_error("Next.Previous instruction is not Current");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Cur = Next;
|
Cur = Next;
|
||||||
}
|
}
|
||||||
|
@ -595,27 +567,20 @@ struct FunCloner {
|
||||||
Count--;
|
Count--;
|
||||||
Next = LLVMGetNextBasicBlock(Cur);
|
Next = LLVMGetNextBasicBlock(Cur);
|
||||||
if (Next == nullptr) {
|
if (Next == nullptr) {
|
||||||
if (Cur != Last) {
|
if (Cur != Last)
|
||||||
fprintf(stderr, "Final basic block does not match Last\n");
|
report_fatal_error("Final basic block does not match Last");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMBasicBlockRef Prev = LLVMGetPreviousBasicBlock(Next);
|
LLVMBasicBlockRef Prev = LLVMGetPreviousBasicBlock(Next);
|
||||||
if (Prev != Cur) {
|
if (Prev != Cur)
|
||||||
fprintf(stderr, "Next.Previous basic bloc is not Current\n");
|
report_fatal_error("Next.Previous basic bloc is not Current");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Cur = Next;
|
Cur = Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Count != 0) {
|
if (Count != 0)
|
||||||
fprintf(stderr, "Basic block count does not match iterration\n");
|
report_fatal_error("Basic block count does not match iterration");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -643,19 +608,14 @@ static void clone_functions(LLVMModuleRef Src, LLVMModuleRef Dst) {
|
||||||
clone_function(Cur, Dst);
|
clone_function(Cur, Dst);
|
||||||
Next = LLVMGetNextFunction(Cur);
|
Next = LLVMGetNextFunction(Cur);
|
||||||
if (Next == nullptr) {
|
if (Next == nullptr) {
|
||||||
if (Cur != End) {
|
if (Cur != End)
|
||||||
fprintf(stderr, "Last function does not match End\n");
|
report_fatal_error("Last function does not match End");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef Prev = LLVMGetPreviousFunction(Next);
|
LLVMValueRef Prev = LLVMGetPreviousFunction(Next);
|
||||||
if (Prev != Cur) {
|
if (Prev != Cur)
|
||||||
fprintf(stderr, "Next.Previous function is not Current\n");
|
report_fatal_error("Next.Previous function is not Current");
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Cur = Next;
|
Cur = Next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue