From 50d143d60918af74054af84e4965338935d462ef Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 2 Dec 2022 08:34:20 -0800 Subject: [PATCH] Remove use of LLVM's opt from test_noinline (#18300) Instead rely on the linker's builtin DCE to ensure the function still has a caller. This removes all uses of LLVM opt from emscripten. --- test/test_other.py | 16 +++++----------- tools/shared.py | 1 - 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/test/test_other.py b/test/test_other.py index c30055cfe9d9b..b62f9576619f7 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -7286,7 +7286,7 @@ def test_disable_inlining(self): create_file('test.c', r''' #include -void foo() { +static void foo() { printf("foo\n"); } @@ -7296,17 +7296,11 @@ def test_disable_inlining(self): } ''') - # Without the 'INLINING_LIMIT', -O2 inlines foo() - cmd = [EMCC, '-c', 'test.c', '-O2', '-o', 'test.o', '-sINLINING_LIMIT', '-flto'] + # Without the 'INLINING_LIMIT', -O2 inlines foo() and then DCEs it because it has + # no callers and is static + cmd = [EMCC, 'test.c', '-O2', '-o', 'test.o', '-c', '-sINLINING_LIMIT'] self.run_process(cmd) - # If foo() had been wrongly inlined above, internalizing foo and running - # global DCE makes foo DCE'd - opts = ['-internalize', '-internalize-public-api-list=main', '-globaldce'] - self.run_process([shared.LLVM_OPT] + opts + ['test.o', '-o', 'test2.o']) - - # To this test to be successful, foo() shouldn't have been inlined above and - # foo() should be in the function list - output = self.run_process([shared.EM_NM, 'test2.o'], stdout=PIPE).stdout + output = self.run_process([common.LLVM_OBJDUMP, '-t', 'test.o'], stdout=PIPE).stdout self.assertContained('foo', output) def test_output_eol(self): diff --git a/tools/shared.py b/tools/shared.py index 20800fa3d684a..075dae345f94d 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -745,7 +745,6 @@ def get_llvm_target(): LLVM_AR = build_llvm_tool_path(exe_suffix('llvm-ar')) LLVM_DWP = build_llvm_tool_path(exe_suffix('llvm-dwp')) LLVM_RANLIB = build_llvm_tool_path(exe_suffix('llvm-ranlib')) -LLVM_OPT = os.path.expanduser(build_llvm_tool_path(exe_suffix('opt'))) LLVM_NM = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-nm'))) LLVM_DWARFDUMP = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-dwarfdump'))) LLVM_OBJCOPY = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-objcopy')))