Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752671AbcKZR0C (ORCPT ); Sat, 26 Nov 2016 12:26:02 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35531 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752240AbcKZRZz (ORCPT ); Sat, 26 Nov 2016 12:25:55 -0500 Date: Sat, 26 Nov 2016 09:25:50 -0800 From: Alexei Starovoitov To: Wang Nan Cc: acme@redhat.com, ast@fb.com, lizefan@huawei.com, hekuang@huawei.com, linux-kernel@vger.kernel.org, pi3orama@163.com, joe@ovn.org, Jiri Olsa Subject: Re: [PATCH v3 14/30] perf clang: Support compile IR to BPF object and add testcase Message-ID: <20161126172548.GF83987@ast-mbp.thefacebook.com> References: <20161126070354.141764-1-wangnan0@huawei.com> <20161126070354.141764-15-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161126070354.141764-15-wangnan0@huawei.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1377 Lines: 36 On Sat, Nov 26, 2016 at 07:03:38AM +0000, Wang Nan wrote: > getBPFObjectFromModule() is introduced to compile LLVM IR(Module) > to BPF object. Add new testcase for it. > > Test result: > $ ./buildperf/perf test -v clang > 51: Test builtin clang support : > 51.1: Test builtin clang compile C source to IR : > --- start --- > test child forked, pid 21822 > test child finished with 0 > ---- end ---- > Test builtin clang support subtest 0: Ok > 51.2: Test builtin clang compile C source to ELF object : > --- start --- > test child forked, pid 21823 > test child finished with 0 > ---- end ---- > Test builtin clang support subtest 1: Ok > > Signed-off-by: Wang Nan ... > + legacy::PassManager PM; > + if (TargetMachine->addPassesToEmitFile(PM, ostream, > + TargetMachine::CGFT_ObjectFile)) { > + llvm::errs() << "TargetMachine can't emit a file of this type\n"; > + return std::unique_ptr>(nullptr);; > + } > + PM.run(*Module); I'm pretty sure you want to add FunctionInlingPass as well otherwise I think llvm won't be doing much inlining and only very very simple programs will compile fine. See what we did on bcc side. Also did you consider skipping elf generation and using in memory instead ? That will improve compile/run time.