Skip to content

Commit

Permalink
Remove use of LLVM's opt from test_noinline (#18300)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dschuff authored Dec 2, 2022
1 parent dd96490 commit 50d143d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
16 changes: 5 additions & 11 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -7286,7 +7286,7 @@ def test_disable_inlining(self):
create_file('test.c', r'''
#include <stdio.h>
void foo() {
static void foo() {
printf("foo\n");
}
Expand All @@ -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):
Expand Down
1 change: 0 additions & 1 deletion tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand Down

0 comments on commit 50d143d

Please sign in to comment.