forked from OSchip/llvm-project
Add echo test for constant data arrays in the LLVM C API
llvm-svn: 263350
This commit is contained in:
parent
006ce6327e
commit
b325686764
|
@ -11,6 +11,8 @@ target triple = "x86_64-apple-macosx10.11.0"
|
||||||
@ext = external global i32*
|
@ext = external global i32*
|
||||||
@cst = constant %S { i64 1, %S* @cst }
|
@cst = constant %S { i64 1, %S* @cst }
|
||||||
@tl = thread_local global { i64, %S* } { i64 1, %S* @cst }
|
@tl = thread_local global { i64, %S* } { i64 1, %S* @cst }
|
||||||
|
@arr = linkonce_odr global [5 x i8] [ i8 2, i8 3, i8 5, i8 7, i8 11 ]
|
||||||
|
@str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
|
||||||
@hidden = hidden global i32 7
|
@hidden = hidden global i32 7
|
||||||
@protected = protected global i32 23
|
@protected = protected global i32 23
|
||||||
@section = global i32 27, section ".custom"
|
@section = global i32 27, section ".custom"
|
||||||
|
|
|
@ -259,6 +259,16 @@ LLVMValueRef clone_constant(LLVMValueRef Cst, LLVMModuleRef M) {
|
||||||
return LLVMConstArray(LLVMGetElementType(Ty), Elts.data(), EltCount);
|
return LLVMConstArray(LLVMGetElementType(Ty), Elts.data(), EltCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try contant data array
|
||||||
|
if (LLVMIsAConstantDataArray(Cst)) {
|
||||||
|
LLVMTypeRef Ty = TypeCloner(M).Clone(Cst);
|
||||||
|
unsigned EltCount = LLVMGetArrayLength(Ty);
|
||||||
|
SmallVector<LLVMValueRef, 8> Elts;
|
||||||
|
for (unsigned i = 0; i < EltCount; i++)
|
||||||
|
Elts.push_back(clone_constant(LLVMGetElementAsConstant(Cst, i), M));
|
||||||
|
return LLVMConstArray(LLVMGetElementType(Ty), Elts.data(), EltCount);
|
||||||
|
}
|
||||||
|
|
||||||
// Try constant struct
|
// Try constant struct
|
||||||
if (LLVMIsAConstantStruct(Cst)) {
|
if (LLVMIsAConstantStruct(Cst)) {
|
||||||
LLVMTypeRef Ty = TypeCloner(M).Clone(Cst);
|
LLVMTypeRef Ty = TypeCloner(M).Clone(Cst);
|
||||||
|
|
Loading…
Reference in New Issue