[PATCH] D15784: Enable 2 warnings on MSVC, turn on StringPooling & intrinsic functions

Alexander Riccio via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 26 23:39:40 PST 2015


ariccio created this revision.
ariccio added reviewers: chandlerc, rafael.
ariccio added a subscriber: llvm-commits.

This patch passes four additional options to MSVC when building LLVM.
These four options do not generate any new warnings, and slightly improves codegen.

The four options:



  - [[ https://msdn.microsoft.com/en-us/library/dn449508.aspx | /Zc:strictStrings (Disable string literal type conversion) ]] prevents initializing a //non-const// char*/wchar_t* with a string literal

  - [[ https://msdn.microsoft.com/en-us/library/dn449507.aspx | /Zc:rvalueCast (Enforce type conversion rules) ]] prevents nonconformant rvalue/rvalue-reference casting 

  - [[ https://msdn.microsoft.com/en-us/library/s0s0asdt.aspx | /GF (Eliminate Duplicate Strings) ]] pools string literals, which would otherwise waste space

  - [[ https://msdn.microsoft.com/en-us/library/f99tchzc.aspx | /Oi (Generate Intrinsic Functions) ]] greenlights the compiler to replace certain function calls with compiler intrinsics, where it's faster to do so.



The first three are straightforward, and I don't expect any controversy.

Generating intrinsic functions may be problematic if LLVM itself needs ANSI floating point conformance (I have no idea)



http://reviews.llvm.org/D15784

Files:
  cmake/modules/HandleLLVMOptions.cmake

Index: cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- cmake/modules/HandleLLVMOptions.cmake
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -360,6 +360,20 @@
 
   append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
 
+  # Disable string literal const->non-const type conversion
+  # "When specified, the compiler requires strict const-qualification
+  # conformance for pointers initialized by using string literals."
+  append("/Zc:strictStrings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+
+  # Eliminate Duplicate Strings
+  append("/GF" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+
+  # Generate Intrinsic Functions
+  append("/Oi" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+
+  # Enforce type conversion rules
+  append("/Zc:rvalueCast" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+
   # Disable sized deallocation if the flag is supported. MSVC fails to compile
   # the operator new overload in User otherwise.
   check_c_compiler_flag("/WX /Zc:sizedDealloc-" SUPPORTS_SIZED_DEALLOC)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15784.43648.patch
Type: text/x-patch
Size: 1003 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151227/ba15b962/attachment.bin>


More information about the llvm-commits mailing list