aheejin created this revision. aheejin added a reviewer: dschuff. Herald added subscribers: cfe-commits, jfb, sunfish, jgravelle-google, sbc100. Herald added a project: clang.
In wasm, we always use '-matomics' when we use '-pthread'. This will make users type one less option and options will be more consistent. Repository: rC Clang https://reviews.llvm.org/D57874 Files: lib/Frontend/CompilerInvocation.cpp test/Driver/wasm32-unknown-unknown.cpp test/Driver/wasm64-unknown-unknown.cpp Index: test/Driver/wasm64-unknown-unknown.cpp =================================================================== --- test/Driver/wasm64-unknown-unknown.cpp +++ test/Driver/wasm64-unknown-unknown.cpp @@ -120,3 +120,6 @@ // CHECK: SwitchILi8 Switch<sizeof(va_list)>(); } + +// -pthread turns on -matomics +// THREADS: attributes #{{[[0-9]+}} = {{{.*}}"target-features"="+atomics"{{.*}}} Index: test/Driver/wasm32-unknown-unknown.cpp =================================================================== --- test/Driver/wasm32-unknown-unknown.cpp +++ test/Driver/wasm32-unknown-unknown.cpp @@ -120,3 +120,6 @@ // CHECK: SwitchILi4 Switch<sizeof(va_list)>(); } + +// -pthread turns on -matomics +// THREADS: attributes #{{[[0-9]+}} = {{{.*}}"target-features"="+atomics"{{.*}}} Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -3332,6 +3332,11 @@ Res.getDiagnosticOpts().Warnings.push_back("spir-compat"); } + if (Arch == llvm::Triple::wasm32 || Arch == llvm::Triple::wasm64) { + if (LangOpts.POSIXThreads) + Res.getTargetOpts().FeaturesAsWritten.push_back("+atomics"); + } + // If sanitizer is enabled, disable OPT_ffine_grained_bitfield_accesses. if (Res.getCodeGenOpts().FineGrainedBitfieldAccesses && !Res.getLangOpts()->Sanitize.empty()) {
Index: test/Driver/wasm64-unknown-unknown.cpp =================================================================== --- test/Driver/wasm64-unknown-unknown.cpp +++ test/Driver/wasm64-unknown-unknown.cpp @@ -120,3 +120,6 @@ // CHECK: SwitchILi8 Switch<sizeof(va_list)>(); } + +// -pthread turns on -matomics +// THREADS: attributes #{{[[0-9]+}} = {{{.*}}"target-features"="+atomics"{{.*}}} Index: test/Driver/wasm32-unknown-unknown.cpp =================================================================== --- test/Driver/wasm32-unknown-unknown.cpp +++ test/Driver/wasm32-unknown-unknown.cpp @@ -120,3 +120,6 @@ // CHECK: SwitchILi4 Switch<sizeof(va_list)>(); } + +// -pthread turns on -matomics +// THREADS: attributes #{{[[0-9]+}} = {{{.*}}"target-features"="+atomics"{{.*}}} Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -3332,6 +3332,11 @@ Res.getDiagnosticOpts().Warnings.push_back("spir-compat"); } + if (Arch == llvm::Triple::wasm32 || Arch == llvm::Triple::wasm64) { + if (LangOpts.POSIXThreads) + Res.getTargetOpts().FeaturesAsWritten.push_back("+atomics"); + } + // If sanitizer is enabled, disable OPT_ffine_grained_bitfield_accesses. if (Res.getCodeGenOpts().FineGrainedBitfieldAccesses && !Res.getLangOpts()->Sanitize.empty()) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits