[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 14:51:12 PDT 2016



On 9/20/16 3:43 PM, Lin, Jin wrote:
>
>
> -----Original Message----- From: Jonathan Roelofs
> [mailto:jonathan at codesourcery.com] Sent: Tuesday, September 20, 2016
> 1:18 PM To: Lin, Jin <jin.lin at intel.com>; cfe-dev at lists.llvm.org
> Subject: Re: [cfe-dev] question regarding the C++ test case under
> LLVM test
>
>
>
> 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.
>
>
> ************** I used "llvm-lit -v" to test my test case. So I know
> exactly what the script is. I am not asking to execute the test case.
> In fact, what I ask for is to compile the test case and emit the LLVM
> IR under Linux and Windows.

Sorry for the misunderstanding.

> The difference of this test file from
> other files in the directory clang/test  is that the test file
> includes the header file. My point is, with different OS, the header
> file might be different.

Even with the same OS, the header might be different (see my "p.s." from 
below).

Your best bet is to write the minimal version of std::vector that you 
need to test the functionality you're trying to test, and have it inline 
in your testcase.... depending on the host environment via #include's is 
an anti-pattern in clang's testsuite.


Jon

>
> Script: -- clang --driver-mode=g++   -target
> x86_64-unknown-linux-gnu   -O3
> ./llvm/tools/clang/test/CodeGen/std-container-ptr.cpp  -Xclang
> -disable-llvm-optzns   -emit-llvm -S -o - | FileCheck
> ./llvm/tools/clang/test/CodeGen/intel/std-container-ptr.cpp
>
>
> 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
>

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


More information about the cfe-dev mailing list