mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-14 20:10:58 +00:00
Do some refactoring in constant generation in the C API echo test. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260941 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2c44092d73
commit
f1671f6231
@ -221,14 +221,12 @@ LLVMValueRef clone_constant(LLVMValueRef Cst, LLVMModuleRef M) {
|
||||
const char *Name = LLVMGetValueName(Cst);
|
||||
|
||||
// Try function
|
||||
LLVMValueRef Dst = LLVMGetNamedFunction(M, Name);
|
||||
if (Dst != nullptr)
|
||||
return Dst;
|
||||
if (LLVMIsAFunction(Cst))
|
||||
return LLVMGetNamedFunction(M, Name);
|
||||
|
||||
// Try global variable
|
||||
Dst = LLVMGetNamedGlobal(M, Name);
|
||||
if (Dst != nullptr)
|
||||
return Dst;
|
||||
if (LLVMIsAGlobalVariable(Cst))
|
||||
return LLVMGetNamedGlobal(M, Name);
|
||||
|
||||
fprintf(stderr, "Could not find @%s\n", Name);
|
||||
exit(-1);
|
||||
@ -243,8 +241,12 @@ LLVMValueRef clone_constant(LLVMValueRef Cst, LLVMModuleRef M) {
|
||||
if (LLVMIsUndef(Cst))
|
||||
return LLVMGetUndef(TypeCloner(M).Clone(Cst));
|
||||
|
||||
// This kind of constant is not supported.
|
||||
report_fatal_error("Unsupported contant type");
|
||||
// This kind of constant is not supported
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user