mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-02 00:16:25 +00:00
Do some refactoring in constant generation in the C API echo test. NFC
llvm-svn: 260941
This commit is contained in:
parent
7ffd22e2c1
commit
b292899083
@ -221,14 +221,12 @@ LLVMValueRef clone_constant(LLVMValueRef Cst, LLVMModuleRef M) {
|
|||||||
const char *Name = LLVMGetValueName(Cst);
|
const char *Name = LLVMGetValueName(Cst);
|
||||||
|
|
||||||
// Try function
|
// Try function
|
||||||
LLVMValueRef Dst = LLVMGetNamedFunction(M, Name);
|
if (LLVMIsAFunction(Cst))
|
||||||
if (Dst != nullptr)
|
return LLVMGetNamedFunction(M, Name);
|
||||||
return Dst;
|
|
||||||
|
|
||||||
// Try global variable
|
// Try global variable
|
||||||
Dst = LLVMGetNamedGlobal(M, Name);
|
if (LLVMIsAGlobalVariable(Cst))
|
||||||
if (Dst != nullptr)
|
return LLVMGetNamedGlobal(M, Name);
|
||||||
return Dst;
|
|
||||||
|
|
||||||
fprintf(stderr, "Could not find @%s\n", Name);
|
fprintf(stderr, "Could not find @%s\n", Name);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@ -243,8 +241,12 @@ LLVMValueRef clone_constant(LLVMValueRef Cst, LLVMModuleRef M) {
|
|||||||
if (LLVMIsUndef(Cst))
|
if (LLVMIsUndef(Cst))
|
||||||
return LLVMGetUndef(TypeCloner(M).Clone(Cst));
|
return LLVMGetUndef(TypeCloner(M).Clone(Cst));
|
||||||
|
|
||||||
// This kind of constant is not supported.
|
// This kind of constant is not supported
|
||||||
report_fatal_error("Unsupported contant type");
|
if (!LLVMIsAConstantExpr(Cst))
|
||||||
|
report_fatal_error("Expected a constant expression");
|
||||||
|
|
||||||
|
// At this point, it must be a constant expression
|
||||||
|
report_fatal_error("ConstantExpression are not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FunCloner {
|
struct FunCloner {
|
||||||
|
Loading…
Reference in New Issue
Block a user