Verified Commit 34e97b73 authored by nagayama15's avatar nagayama15

add optimization targets for compound passes

parent 14fce2f6
...@@ -104,6 +104,10 @@ namespace kyut { ...@@ -104,6 +104,10 @@ namespace kyut {
const auto chunk_end = std::end(chunk); const auto chunk_end = std::end(chunk);
const std::size_t count = std::distance(chunk_begin, chunk_end); const std::size_t count = std::distance(chunk_begin, chunk_end);
if (count < 2) {
return 0;
}
const std::size_t bit_width = factorial_bit_width_table[count]; const std::size_t bit_width = factorial_bit_width_table[count];
// Extract watermark. // Extract watermark.
...@@ -117,7 +121,11 @@ namespace kyut { ...@@ -117,7 +121,11 @@ namespace kyut {
return !less(*a, *(begin + i)) && !less(*(begin + i), *a); return !less(*a, *(begin + i)) && !less(*(begin + i), *a);
}); });
assert(found != std::end(chunk)); // FIXME: sometimes crashing here (maybe count < 2) // assert(found != std::end(chunk)); // FIXME: sometimes crashing here
if (found == std::end(chunk)) {
base *= count - i;
continue;
}
const std::size_t pos = std::distance(it, found); const std::size_t pos = std::distance(it, found);
......
...@@ -10,7 +10,7 @@ METHODS.each do |method| ...@@ -10,7 +10,7 @@ METHODS.each do |method|
OPT_PASSES.each do |pass| OPT_PASSES.each do |pass|
b = a.to_s.end_with?(".wasm.txt") ? a.sub(".wasm.txt", "-#{pass}.wasm.txt") : a.sub(".txt", "-#{pass}.txt") b = a.to_s.end_with?(".wasm.txt") ? a.sub(".wasm.txt", "-#{pass}.wasm.txt") : a.sub(".txt", "-#{pass}.txt")
puts "#{a.basename} - #{b.basename}: #{method[:name]}, #{pass}, #{FileUtils.cmp(a, b)}" puts "#{a.basename} - #{b.basename}: #{method[:name]}, #{pass}, #{FileUtils.cmp(a, b) ? "○" : "☓"}"
end end
end end
end end
...@@ -51,19 +51,26 @@ OPT_PASSES = [ ...@@ -51,19 +51,26 @@ OPT_PASSES = [
"optimize-instructions", "optimize-instructions",
"optimize-stack-ir", "optimize-stack-ir",
"pick-load-signs", "pick-load-signs",
"precompute-propagate",
"precompute", "precompute",
"precompute-propagate",
"remove-unused-brs", "remove-unused-brs",
"remove-unused-module-elements", "remove-unused-module-elements",
"remove-unused-names", "remove-unused-names",
"reorder-locals", "reorder-locals",
"rse", "rse",
"simplify-globals-optimizing",
"simplify-globals", "simplify-globals",
"simplify-locals-nostructure", "simplify-globals-optimizing",
"simplify-locals", "simplify-locals",
"simplify-locals-nostructure",
"ssa-nomerge", "ssa-nomerge",
"vacuum", "vacuum",
"O1",
"O2",
"O3",
"O4",
"Os",
"Oz",
] ]
WATERMARK = "N7AStlK2gioIqeRi" WATERMARK = "N7AStlK2gioIqeRi"
...@@ -79,7 +86,7 @@ def embed(file, out, method, watermark, chunk_size = 20) ...@@ -79,7 +86,7 @@ def embed(file, out, method, watermark, chunk_size = 20)
end end
def optimize(file, out, pass) def optimize(file, out, pass)
output = IO.popen([WASM_OPT, "-o", out.to_s, "--#{pass}", file.to_s]).read output = IO.popen([WASM_OPT, "-o", out.to_s, pass.start_with?("O") ? "-#{pass}" : "--#{pass}", file.to_s]).read
puts "optimize #{file}, #{out}, #{pass}, #{output}" puts "optimize #{file}, #{out}, #{pass}, #{output}"
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment