r257004 - [WebAssembly] Only enable --gc-sections when optimizations are enabled.
Dan Gohman via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 6 16:32:04 PST 2016
Author: djg
Date: Wed Jan 6 18:32:04 2016
New Revision: 257004
URL: http://llvm.org/viewvc/llvm-project?rev=257004&view=rev
Log:
[WebAssembly] Only enable --gc-sections when optimizations are enabled.
Also, revamp the wasm-toolchain.c test and add a test to ensure that
a user-supplied --no-gc-sections comes after --gc-sections.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/wasm-toolchain.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257004&r1=257003&r2=257004&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan 6 18:32:04 2016
@@ -6537,7 +6537,8 @@ void wasm::Linker::ConstructJob(Compilat
// Enable garbage collection of unused input sections by default, since code
// size is of particular importance.
- CmdArgs.push_back("--gc-sections");
+ if (areOptimizationsEnabled(Args))
+ CmdArgs.push_back("--gc-sections");
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
CmdArgs.push_back("-o");
Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=257004&r1=257003&r2=257004&view=diff
==============================================================================
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Wed Jan 6 18:32:04 2016
@@ -1,3 +1,23 @@
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown -x assembler %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
-// AS_LINK: clang{{.*}}" "-cc1as" {{.*}} "-o" "[[temp:[^"]*]]"
-// AS_LINK: lld{{.*}}" "-flavor" "ld" "--gc-sections" "[[temp]]" "-o" "a.out"
+// A basic clang -cc1 command-line.
+
+// RUN: %clang %s -### -target wasm32-unknown-unknown 2>&1 | FileCheck -check-prefix=CC1 %s
+// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}}
+
+// A basic C link command-line.
+
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown %s 2>&1 | FileCheck -check-prefix=LINK %s
+// LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK: lld{{.*}}" "-flavor" "ld" "[[temp]]" "-o" "a.out"
+
+// A basic C link command-line with optimization.
+
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_OPT: lld{{.*}}" "-flavor" "ld" "--gc-sections" "[[temp]]" "-o" "a.out"
+
+// Ditto, but ensure that a user --no-gc-sections comes after the
+// default --gc-sections.
+
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown -Wl,--no-gc-sections %s 2>&1 | FileCheck -check-prefix=NO_GC_SECTIONS %s
+// NO_GC_SECTIONS: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "ld" "--gc-sections" "--no-gc-sections" "[[temp]]" "-o" "a.out"
More information about the cfe-commits
mailing list