[PATCH] D50729: [WebAssembly] Don't compress LEBs by default

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 14 12:12:02 PDT 2018


sbc100 created this revision.
Herald added subscribers: llvm-commits, JDevlieghere, sunfish, aheejin, jgravelle-google, aprantl, dschuff.

LEB compression breaks debug info so we don't want to enable
it by default, even at high optimization levels.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D50729

Files:
  test/wasm/compress-relocs.ll
  wasm/Driver.cpp
  wasm/Options.td


Index: wasm/Options.td
===================================================================
--- wasm/Options.td
+++ wasm/Options.td
@@ -23,6 +23,9 @@
 def color_diagnostics_eq: J<"color-diagnostics=">,
   HelpText<"Use colors in diagnostics; one of 'always', 'never', 'auto'">;
 
+def compress_relocations: F<"compress-relocations">,
+  HelpText<"Compress the relocation targets in the code section.">;
+
 defm demangle: B<"demangle",
     "Demangle symbol names",
     "Do not demangle symbol names">;
Index: wasm/Driver.cpp
===================================================================
--- wasm/Driver.cpp
+++ wasm/Driver.cpp
@@ -395,6 +395,7 @@
   Config->SearchPaths = args::getStrings(Args, OPT_L);
   Config->StripAll = Args.hasArg(OPT_strip_all);
   Config->StripDebug = Args.hasArg(OPT_strip_debug);
+  Config->CompressRelocTargets = Args.hasArg(OPT_compress_relocations);
   Config->StackFirst = Args.hasArg(OPT_stack_first);
   Config->ThinLTOCacheDir = Args.getLastArgValue(OPT_thinlto_cache_dir);
   Config->ThinLTOCachePolicy = CHECK(
@@ -410,7 +411,9 @@
   Config->ZStackSize =
       args::getZOptionValue(Args, OPT_z, "stack-size", WasmPageSize);
 
-  Config->CompressRelocTargets = Config->Optimize > 0 && !Config->Relocatable;
+  if (!Config->StripDebug && !Config->StripAll && Config->CompressRelocTargets)
+    error("--compress-relocations is incompatible with output debug"
+          " information. Please pass --strip-debug or --strip-all");
 
   if (Config->LTOO > 3)
     error("invalid optimization level for LTO: " + Twine(Config->LTOO));
Index: test/wasm/compress-relocs.ll
===================================================================
--- test/wasm/compress-relocs.ll
+++ test/wasm/compress-relocs.ll
@@ -2,8 +2,10 @@
 ; RUN: llc -filetype=obj %s -o %t.o
 ; RUN: wasm-ld -o %t.wasm %t2.o %t.o
 ; RUN: obj2yaml %t.wasm | FileCheck %s
-
-; RUN: wasm-ld -O2 -o %t-compressed.wasm %t2.o %t.o
+; RUN: wasm-ld -O2 -o %t-opt.wasm %t2.o %t.o
+; RUN: obj2yaml %t-opt.wasm | FileCheck %s
+; RUN: not wasm-ld --compress-relocations -o %t-compressed.wasm %t2.o %t.o 2>&1 | FileCheck %s -check-prefix=ERROR
+; RUN: wasm-ld --strip-debug --compress-relocations -o %t-compressed.wasm %t2.o %t.o
 ; RUN: obj2yaml %t-compressed.wasm | FileCheck %s -check-prefix=COMPRESS
 
 target triple = "wasm32-unknown-unknown-wasm"
@@ -18,5 +20,7 @@
   ret void
 }
 
+; ERROR: wasm-ld: error: --compress-relocations is incompatible with output debug information. Please pass --strip-debug or --strip-all
+
 ; CHECK:    Body:            4100280284888080002100410028028088808000118080808000001A2000118180808000001A0B
 ; COMPRESS: Body:            41002802840821004100280280081100001A20001101001A0B


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50729.160664.patch
Type: text/x-patch
Size: 2708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180814/ead9484e/attachment.bin>


More information about the llvm-commits mailing list