Skip to content

Commit 50d143d

Browse files
authored
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.
1 parent dd96490 commit 50d143d

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

test/test_other.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7286,7 +7286,7 @@ def test_disable_inlining(self):
72867286
create_file('test.c', r'''
72877287
#include <stdio.h>
72887288
7289-
void foo() {
7289+
static void foo() {
72907290
printf("foo\n");
72917291
}
72927292
@@ -7296,17 +7296,11 @@ def test_disable_inlining(self):
72967296
}
72977297
''')
72987298

7299-
# Without the 'INLINING_LIMIT', -O2 inlines foo()
7300-
cmd = [EMCC, '-c', 'test.c', '-O2', '-o', 'test.o', '-sINLINING_LIMIT', '-flto']
7299+
# Without the 'INLINING_LIMIT', -O2 inlines foo() and then DCEs it because it has
7300+
# no callers and is static
7301+
cmd = [EMCC, 'test.c', '-O2', '-o', 'test.o', '-c', '-sINLINING_LIMIT']
73017302
self.run_process(cmd)
7302-
# If foo() had been wrongly inlined above, internalizing foo and running
7303-
# global DCE makes foo DCE'd
7304-
opts = ['-internalize', '-internalize-public-api-list=main', '-globaldce']
7305-
self.run_process([shared.LLVM_OPT] + opts + ['test.o', '-o', 'test2.o'])
7306-
7307-
# To this test to be successful, foo() shouldn't have been inlined above and
7308-
# foo() should be in the function list
7309-
output = self.run_process([shared.EM_NM, 'test2.o'], stdout=PIPE).stdout
7303+
output = self.run_process([common.LLVM_OBJDUMP, '-t', 'test.o'], stdout=PIPE).stdout
73107304
self.assertContained('foo', output)
73117305

73127306
def test_output_eol(self):

tools/shared.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,6 @@ def get_llvm_target():
745745
LLVM_AR = build_llvm_tool_path(exe_suffix('llvm-ar'))
746746
LLVM_DWP = build_llvm_tool_path(exe_suffix('llvm-dwp'))
747747
LLVM_RANLIB = build_llvm_tool_path(exe_suffix('llvm-ranlib'))
748-
LLVM_OPT = os.path.expanduser(build_llvm_tool_path(exe_suffix('opt')))
749748
LLVM_NM = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-nm')))
750749
LLVM_DWARFDUMP = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-dwarfdump')))
751750
LLVM_OBJCOPY = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-objcopy')))

0 commit comments

Comments
 (0)