[llvm] r263350 - Add echo test for constant data arrays in the LLVM C API
Amaury Sechet via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 12 16:58:26 PST 2016
Author: deadalnix
Date: Sat Mar 12 18:58:25 2016
New Revision: 263350
URL: http://llvm.org/viewvc/llvm-project?rev=263350&view=rev
Log:
Add echo test for constant data arrays in the LLVM C API
Modified:
llvm/trunk/test/Bindings/llvm-c/echo.ll
llvm/trunk/tools/llvm-c-test/echo.cpp
Modified: llvm/trunk/test/Bindings/llvm-c/echo.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/llvm-c/echo.ll?rev=263350&r1=263349&r2=263350&view=diff
==============================================================================
--- llvm/trunk/test/Bindings/llvm-c/echo.ll (original)
+++ llvm/trunk/test/Bindings/llvm-c/echo.ll Sat Mar 12 18:58:25 2016
@@ -11,6 +11,8 @@ target triple = "x86_64-apple-macosx10.1
@ext = external global i32*
@cst = constant %S { i64 1, %S* @cst }
@tl = thread_local global { i64, %S* } { i64 1, %S* @cst }
+ at arr = linkonce_odr global [5 x i8] [ i8 2, i8 3, i8 5, i8 7, i8 11 ]
+ at str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
@hidden = hidden global i32 7
@protected = protected global i32 23
@section = global i32 27, section ".custom"
Modified: llvm/trunk/tools/llvm-c-test/echo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-c-test/echo.cpp?rev=263350&r1=263349&r2=263350&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-c-test/echo.cpp (original)
+++ llvm/trunk/tools/llvm-c-test/echo.cpp Sat Mar 12 18:58:25 2016
@@ -259,6 +259,16 @@ LLVMValueRef clone_constant(LLVMValueRef
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
if (LLVMIsAConstantStruct(Cst)) {
LLVMTypeRef Ty = TypeCloner(M).Clone(Cst);
More information about the llvm-commits
mailing list