[PATCH] D49330: [compiler-rt] Include -lm when using compiler-rt, due to dependencies in some __div methods.
rupprecht created this revision. rupprecht added a reviewer: saugustine. Herald added subscribers: cfe-commits, aheejin, sbc100, dberris, srhines. Some methods in compiler-rt builtins have dependencies on libm. Therefore building with -rtlib=compiler-rt is completely broken if those symbols are used and users don't include -lm themselves. Fixes PR32279 and PR28652. Repository: rC Clang https://reviews.llvm.org/D49330 Files: lib/Driver/ToolChains/CommonArgs.cpp test/Driver/linux-ld.c test/Driver/wasm-toolchain.c test/Driver/wasm-toolchain.cpp Index: test/Driver/wasm-toolchain.cpp === --- test/Driver/wasm-toolchain.cpp +++ test/Driver/wasm-toolchain.cpp @@ -14,10 +14,10 @@ // RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" -// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" +// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-lm" "-o" "a.out" // A basic C++ link command-line with optimization. // RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck -check-prefix=LINK_OPT %s // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" -// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" +// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-lm" "-o" "a.out" Index: test/Driver/wasm-toolchain.c === --- test/Driver/wasm-toolchain.c +++ test/Driver/wasm-toolchain.c @@ -14,10 +14,10 @@ // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" -// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" +// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-lm" "-o" "a.out" // A basic C link command-line with optimization. // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" -// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" +// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-lm" "-o" "a.out" Index: test/Driver/linux-ld.c === --- test/Driver/linux-ld.c +++ test/Driver/linux-ld.c @@ -67,8 +67,10 @@ // CHECK-LD-RT: "-L[[SYSROOT]]/lib" // CHECK-LD-RT: "-L[[SYSROOT]]/usr/lib" // CHECK-LD-RT: libclang_rt.builtins-x86_64.a" +// CHECK-LD-RT: "-lm" // CHECK-LD-RT: "-lc" // CHECK-LD-RT: libclang_rt.builtins-x86_64.a" +// CHECK-LD-RT: "-lm" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=i686-unknown-linux \ @@ -88,8 +90,10 @@ // CHECK-LD-RT-I686: "-L[[SYSROOT]]/lib" // CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib" // CHECK-LD-RT-I686: libclang_rt.builtins-i386.a" +// CHECK-LD-RT-I686: "-lm" // CHECK-LD-RT-I686: "-lc" // CHECK-LD-RT-I686: libclang_rt.builtins-i386.a" +// CHECK-LD-RT-I686: "-lm" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=arm-linux-androideabi \ @@ -103,8 +107,10 @@ // CHECK-LD-RT-ANDROID: "-m" "armelf_linux_eabi" // CHECK-LD-RT-ANDROID: "-dynamic-linker" // CHECK-LD-RT-ANDROID: libclang_rt.builtins-arm-android.a" +// CHECK-LD-RT-ANDROID: "-lm" // CHECK-LD-RT-ANDROID: "-lc" // CHECK-LD-RT-ANDROID: libclang_rt.builtins-arm-android.a" +// CHECK-LD-RT-ANDROID: "-lm" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=x86_64-unknown-linux -rtlib=platform \ Index: lib/Driver/ToolChains/CommonArgs.cpp === --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -1162,6 +1162,8 @@ switch (RLT) { case ToolChain::RLT_CompilerRT: CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins")); +// Some methods such as __divdc3, __divsc3, and __divxc3 rely on libm +CmdArgs.push_back("-lm"); break; case ToolChain::RLT_Libgcc: // Make sure libgcc is not used under MSV
r337082 - Revert "[ThinLTO] Ensure we always select the same function copy to import"
Author: tejohnson Date: Fri Jul 13 18:50:14 2018 New Revision: 337082 URL: http://llvm.org/viewvc/llvm-project?rev=337082&view=rev Log: Revert "[ThinLTO] Ensure we always select the same function copy to import" This reverts commit r337051. Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=337082&r1=337081&r2=337082&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jul 13 18:50:14 2018 @@ -1127,8 +1127,9 @@ static void runThinLTOBackend(ModuleSumm // e.g. record required linkage changes. if (Summary->modulePath() == M->getModuleIdentifier()) continue; -// Add an entry to provoke importing by thinBackend. -ImportList[Summary->modulePath()].insert(GUID); +// Doesn't matter what value we plug in to the map, just needs an entry +// to provoke importing by thinBackend. +ImportList[Summary->modulePath()][GUID] = 1; } std::vector> OwnedImports; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48287: [HIP] Support -fcuda-flush-denormals-to-zero for amdgcn
yaxunl added a comment. In https://reviews.llvm.org/D48287#1138262, @tra wrote: > Using OpenCL's flag for the purpose adds a *third* way we handle denormals > flushing in clang. Now it would be HIP (which is CUDA-like) using OpenCL's > flag for denormals instead of CUDA's one. > You could change AMDGPUTargetInfo::adjustTargetOptions() to use > CGOpts.getLangOpts().CUDADeviceFlushDenormalsToZero instead. That would at > least make HIP and CUDA do the same thing. > > I think it would work better if we could coalesce > CUDADeviceFlushDenormalsToZero and CodeGenOpts.FlushDenorm and, maybe move > the flag to LangOpts , so we could use LangOpts.CUDAIsDevice. Sorry for the delay. CGOpts does not have member function getLangOpts(). It seems whereever we need to refer to LangOpts.CUDADeviceFlushDenormalsToZero, we can use Opts.FlushDenorm, but not true vice versa. Therefore if we want a unified option, Opts.FlushDenorm is a better choice. https://reviews.llvm.org/D48287 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49227: Override a bit fields layout from an external source
aleksandr.urakov added a comment. Thank you! Repository: rL LLVM https://reviews.llvm.org/D49227 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r337085 - Mark one more __wrap_iter operation as constexpr.
Author: marshall Date: Fri Jul 13 20:06:11 2018 New Revision: 337085 URL: http://llvm.org/viewvc/llvm-project?rev=337085&view=rev Log: Mark one more __wrap_iter operation as constexpr. Modified: libcxx/trunk/include/iterator Modified: libcxx/trunk/include/iterator URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=337085&r1=337084&r2=337085&view=diff == --- libcxx/trunk/include/iterator (original) +++ libcxx/trunk/include/iterator Fri Jul 13 20:06:11 2018 @@ -1374,7 +1374,8 @@ public: } _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT_DEBUG {__wrap_iter __tmp(*this); ++(*this); return __tmp;} -_LIBCPP_INLINE_VISIBILITY __wrap_iter& operator--() _NOEXCEPT_DEBUG + +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT_DEBUG { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__decrementable(this), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r337087 - Mark __equal_to 's operations as constexpr.
Author: marshall Date: Fri Jul 13 21:15:19 2018 New Revision: 337087 URL: http://llvm.org/viewvc/llvm-project?rev=337087&view=rev Log: Mark __equal_to 's operations as constexpr. Modified: libcxx/trunk/include/algorithm Modified: libcxx/trunk/include/algorithm URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=337087&r1=337086&r2=337087&view=diff == --- libcxx/trunk/include/algorithm (original) +++ libcxx/trunk/include/algorithm Fri Jul 13 21:15:19 2018 @@ -671,10 +671,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD template struct __equal_to { -_LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} -_LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;} -_LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;} -_LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;} +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;} +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;} +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;} }; template ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"
0x8000- updated this revision to Diff 155549. 0x8000- added a comment. Accept magic values arbitrarily deep in a constant initialization Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49114 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/MagicNumbersCheck.cpp clang-tidy/readability/MagicNumbersCheck.h clang-tidy/readability/ReadabilityTidyModule.cpp docs/ReleaseNotes.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/readability-magic-numbers.rst test/clang-tidy/readability-magic-numbers.cpp Index: test/clang-tidy/readability-magic-numbers.cpp === --- /dev/null +++ test/clang-tidy/readability-magic-numbers.cpp @@ -0,0 +1,151 @@ +// RUN: %check_clang_tidy %s readability-magic-numbers %t + +template +struct ValueBucket { + T value[V]; +}; + +int BadGlobalInt = 5; +// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: magic number integer literal 5 [readability-magic-numbers] + +int IntSquarer(int param) { + return param * param; +} + +void BuggyFunction() { + int BadLocalInt = 6; + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: magic number integer literal 6 [readability-magic-numbers] + + (void)IntSquarer(7); + // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: magic number integer literal 7 [readability-magic-numbers] + + int LocalArray[8]; + // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: magic number integer literal 8 [readability-magic-numbers] + + for (int ii = 0; ii < 8; ++ii) + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: magic number integer literal 8 [readability-magic-numbers] + { +LocalArray[ii] = 3 * ii; +// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: magic number integer literal 3 [readability-magic-numbers] + } + + ValueBucket Bucket; + // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: magic number integer literal 4 [readability-magic-numbers] +} + +class TwoIntContainer { +public: + TwoIntContainer(int val) : anotherMember(val * val), yetAnotherMember(6), anotherConstant(val + val) {} + // CHECK-MESSAGES: :[[@LINE-1]]:73: warning: magic number integer literal 6 [readability-magic-numbers] + + int getValue() const; + +private: + int oneMember = 9; + // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: magic number integer literal 9 [readability-magic-numbers] + + int anotherMember; + + int yetAnotherMember; + + const int oneConstant = 2; + + const int anotherConstant; +}; + +int ValueArray[] = {3, 5}; +// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: magic number integer literal 3 [readability-magic-numbers] +// CHECK-MESSAGES: :[[@LINE-2]]:24: warning: magic number integer literal 5 [readability-magic-numbers] + +float FloatPiVariable = 3.1415926535f; +// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: magic number float literal 3.141592741 [readability-magic-numbers] +double DoublePiVariable = 6.283185307; +// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: magic number float literal 6.283185307 [readability-magic-numbers] + +int getAnswer() { + if (ValueArray[0] < ValueArray[1]) +return ValueArray[1]; + + return -3; // FILENOTFOUND + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: magic number integer literal 3 [readability-magic-numbers] +} + +/* + * Clean code + */ + +#define INT_MACRO 5 + +const int GoodGlobalIntContant = 42; + +constexpr int AlsoGoodGlobalIntContant = 42; + +void SolidFunction() { + const int GoodLocalIntContant = 43; + + (void)IntSquarer(GoodLocalIntContant); + + int LocalArray[INT_MACRO]; + + ValueBucket Bucket; +} + +const int ConstValueArray[] = {7, 9}; + +const int ConstValueArray2D[2][2] = {{7, 9}, {13, 15}}; + +/* + * no warnings for grandfathered values + */ +int GrandfatheredValues[] = {0, 1, 2, 10, 100, -1, -10, -100}; + +/* + * no warnings for enums + */ +enum Smorgasbord { + STARTER, + ALPHA = 3, + BETA = 1 << 5, +}; + +const float FloatPiConstant = 3.1415926535f; +const double DoublePiConstant = 6.283185307; + +double DoubleZeroIsAccepted = 0.0; +float FloatZeroIsAccepted = 0.0f; + +namespace geometry { + +template +struct Point { + T x; + T y; + + explicit Point(T xval, T yval) noexcept : x{xval}, y{yval} { + } +}; + +template +struct Dimension { + T x; + T y; + + explicit Dimension(T xval, T yval) noexcept : x{xval}, y{yval} { + } +}; + +template +struct Rectangle { + Point origin; + Dimension size; + T rotation; // angle of rotation around origin + + Rectangle(Point origin_, Dimension size_, T rotation_ = 0) noexcept : origin{origin_}, size{size_}, rotation{rotation_} { + } + + bool contains(Point point) const; +}; + +} // namespace geometry + +const geometry::Rectangle mandelbrotCanvas{geometry::Point{-2.5, -1}, geometry::Dimension{3.5, 2}}; Index: docs/clang-tidy/checks/readability-magic-numbers.rst === --- /dev/null +++ docs/clang-tidy/checks/readability-magic-numbers.rst @@ -0,0 +1,51 @@ +.. title:: clang-tidy - readability-magic-numbers + +re
[PATCH] D49338: Implement - P0122R7
mclow.lists added inline comments. Comment at: include/span:236 +_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, index_type __count) : __data{__ptr} +{ assert(_Extent == __count); } +_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __f, pointer __l) : __data{__f} These naked `assert` calls need to be `_LIBCPP_ASSERT` https://reviews.llvm.org/D49338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits