[cfe-dev] question regarding the C++ test case under LLVM test

Jonathan Roelofs via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 20 13:18:10 PDT 2016



On 9/20/16 12:22 PM, Lin, Jin via cfe-dev wrote:
> Hi,
>
>
>
> I would like to have the following test case only running under Linux
> instead of Windows. Can someone shed me the light on how to make it work?
>
>
> The second question is on how to modify the RUN command to run it under
> windows.  If clangxx is used, the dirver-mode is set to g++. I have to
> specify the driver mode to be msvc. Please note that the test caseI has
> header file so that I cannot simply use clang_cc1.

The RUN command doesn't do what you think it does. The RUN line you've 
got just runs the compiler, and checks the IR that comes out of it for 
particular patterns (using FileCheck). However, it seems like you're 
asking about how to *execute* a testcase... In general, clang tests 
should not be execution tests. Rather, they should only test codegen, 
and codegen should be the same no matter what the host is. There are a 
few exceptions here and there where host-specific functionality needs to 
be tested, but codegen is not one of them.


Jon

>
>
>
> Thanks,
>
>
>
> Jin
>
>
>
> FILE
>
> // RUN: %clangxx  -target  x86_64-unknown-linux-gnu  -Xclang
> -fintel-compatibility -O3 %s  -Xclang -disable-llvm-optzns   -emit-llvm
> -S -o - | FileCheck %s
>
>
>
> // Check that llvm.intel.std.container.ptr intrinsic is generated.
>
> //
>
> #include <vector>

p.s. you probably want to expand this ^ out so that your testcase 
doesn't depend on the host environment. Rhetorical question: what 
happens to your testcase if the host's <vector> comes from libstdc++ vs 
if it comes from libc++?

>
> #define CONST_VECSIZE 2050
>
>
>
> float TIME,RESULT;
>
> std::vector< std::vector<float> > a(CONST_VECSIZE);
>
> std::vector< std::vector<float> > b(CONST_VECSIZE),c(CONST_VECSIZE);
>
> extern void foo(std::vector< std::vector<float> > *);
>
> void test_vector()
>
> {
>
>   int i, j, k;
>
>
>
>
>
>   for(i=0;i<CONST_VECSIZE;i++)
>
>     for(k=0;k<CONST_VECSIZE;k++)
>
>       for(j=0;j<CONST_VECSIZE;j++)
>
>             c[i][j] = c[i][j] + a[i][k]* b[k][j];
>
>
>
> }
>
> // CHECK:  %{{.*}} = call %"class.std::vector.0"**
> @"llvm.std.container.ptr.p0p0class.std::vector.0"(%"class.std::vector.0"**
> %{{.*}})
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded


More information about the cfe-dev mailing list