This is an archive of the discontinued LLVM Phabricator instance.

[PGO][PGSO] SizeOpts changes.
AbandonedPublic

Authored by hjyamauchi on Oct 16 2019, 2:12 PM.

Details

Summary

(Split of off D67120)

SizeOpts/MachineSizeOpts changes for profile guided size optimization.

Event Timeline

hjyamauchi created this revision.Oct 16 2019, 2:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 16 2019, 2:12 PM
davidxl added inline comments.Oct 16 2019, 2:33 PM
llvm/lib/CodeGen/MachineSizeOpts.cpp
29

Is it possible to expose these APIs publicly in the future ? if yes, maybe put it in llvm:: namespace.

79

Is this adapter class needed?

hjyamauchi marked 2 inline comments as done.Oct 17 2019, 8:41 AM
hjyamauchi added inline comments.
llvm/lib/CodeGen/MachineSizeOpts.cpp
29

It should be, but I don't see a need for now as it's used only here. We could do that as need arises in the future.

79

It is used as a template argument for shouldFuncOptimizeForSizeImpl below to allow shouldFuncOptimizeForSizeImpl to be templatized and shared between BB/BFI and MBB/MBFI.

davidxl accepted this revision.Oct 17 2019, 9:26 AM

lgtm

This revision is now accepted and ready to land.Oct 17 2019, 9:26 AM
This revision was automatically updated to reflect the committed changes.
hjyamauchi marked 2 inline comments as done.
This revision is now accepted and ready to land.Oct 19 2019, 10:36 AM
RKSimon requested changes to this revision.Oct 19 2019, 10:37 AM
This revision now requires changes to proceed.Oct 19 2019, 10:37 AM

I believe the build issue was fixed by https://reviews.llvm.org/rL375261

Reproduced. The cause was a missing dependency on the X86 target when the targets to build wasn't (didn't include) X86.

[----------] 1 test from MachineSizeOptsTest
[ RUN      ] MachineSizeOptsTest.Test

Program received signal SIGSEGV, Segmentation fault.
0x00005555556ee854 in llvm::Target::createTargetMachine (this=0x0, TT=..., CPU=..., Features=..., Options=..., RM=..., CM=..., OL=llvm::CodeGenOpt::Default, 
    JIT=false) at ../include/llvm/Support/TargetRegistry.h:400
400	    if (!TargetMachineCtorFn)
(gdb) bt
#0  0x00005555556ee854 in llvm::Target::createTargetMachine (this=0x0, TT=..., CPU=..., Features=..., Options=..., RM=..., CM=..., OL=llvm::CodeGenOpt::Default, 
    JIT=false) at ../include/llvm/Support/TargetRegistry.h:400
#1  0x00005555557253fe in (anonymous namespace)::createTargetMachine () at ../unittests/CodeGen/MachineSizeOptsTest.cpp:34
#2  0x00005555557255ec in (anonymous namespace)::MachineSizeOptsTest::SetUp (this=0x5555588e21a0) at ../unittests/CodeGen/MachineSizeOptsTest.cpp:66
#3  0x0000555556a5354b in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (object=0x5555588e21a0, 
    method=&virtual testing::Test::SetUp(), location=0x555557c0f41b "SetUp()") at ../utils/unittest/googletest/src/gtest.cc:2402
#4  0x0000555556a4e52b in testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=0x5555588e21a0, 
    method=&virtual testing::Test::SetUp(), location=0x555557c0f41b "SetUp()") at ../utils/unittest/googletest/src/gtest.cc:2455
#5  0x0000555556a380d9 in testing::Test::Run (this=0x5555588e21a0) at ../utils/unittest/googletest/src/gtest.cc:2470
#6  0x0000555556a3883a in testing::TestInfo::Run (this=0x5555588bbf80) at ../utils/unittest/googletest/src/gtest.cc:2656
#7  0x0000555556a38de4 in testing::TestCase::Run (this=0x5555588bc110) at ../utils/unittest/googletest/src/gtest.cc:2774
#8  0x0000555556a3e90b in testing::internal::UnitTestImpl::RunAllTests (this=0x5555588b5160) at ../utils/unittest/googletest/src/gtest.cc:4649
#9  0x0000555556a5443a in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x5555588b5160, 
    method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x555556a3e648 <testing::internal::UnitTestImpl::RunAllTests()>, 
    location=0x555557c0fc60 "auxiliary test code (environments or event listeners)") at ../utils/unittest/googletest/src/gtest.cc:2402
#10 0x0000555556a4ee03 in testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x5555588b5160, 
    method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x555556a3e648 <testing::internal::UnitTestImpl::RunAllTests()>, 
    location=0x555557c0fc60 "auxiliary test code (environments or event listeners)") at ../utils/unittest/googletest/src/gtest.cc:2455
#11 0x0000555556a3d8d8 in testing::UnitTest::Run (this=0x555558891dc0 <testing::UnitTest::GetInstance()::instance>)
    at ../utils/unittest/googletest/src/gtest.cc:4257
#12 0x000055555572fd08 in RUN_ALL_TESTS () at ../utils/unittest/googletest/include/gtest/gtest.h:2233
#13 0x000055555572fab9 in main (argc=1, argv=0x7fffffffdb28) at ../unittests/CodeGen/TargetOptionsTest.cpp:75