r314524 - Fix Modules/{builtin-import.mm, umbrella-header-include-builtin.mm} to be able to handle non-Darwin targets

2017-09-29 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Fri Sep 29 08:45:34 2017
New Revision: 314524

URL: http://llvm.org/viewvc/llvm-project?rev=314524&view=rev
Log:
Fix Modules/{builtin-import.mm,umbrella-header-include-builtin.mm} to be able 
to handle non-Darwin targets

Summary: Also makes them pass on Darwin, if the default target triple is a 
Linux triple.

Reviewers: bruno, rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D38364

Modified:
cfe/trunk/test/Modules/builtin-import.mm
cfe/trunk/test/Modules/umbrella-header-include-builtin.mm

Modified: cfe/trunk/test/Modules/builtin-import.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/builtin-import.mm?rev=314524&r1=314523&r2=314524&view=diff
==
--- cfe/trunk/test/Modules/builtin-import.mm (original)
+++ cfe/trunk/test/Modules/builtin-import.mm Fri Sep 29 08:45:34 2017
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s
 
 #include 
 #include 

Modified: cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/umbrella-header-include-builtin.mm?rev=314524&r1=314523&r2=314524&view=diff
==
--- cfe/trunk/test/Modules/umbrella-header-include-builtin.mm (original)
+++ cfe/trunk/test/Modules/umbrella-header-include-builtin.mm Fri Sep 29 
08:45:34 2017
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 
-F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include 
-F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
 
 #include 
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r338552 - Add REQUIRES: native to a test that assumes it

2018-08-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Wed Aug  1 06:41:11 2018
New Revision: 338552

URL: http://llvm.org/viewvc/llvm-project?rev=338552&view=rev
Log:
Add REQUIRES: native to a test that assumes it

Modified:
cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c

Modified: cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c?rev=338552&r1=338551&r2=338552&view=diff
==
--- cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c (original)
+++ cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c Wed Aug  1 06:41:11 
2018
@@ -1,6 +1,6 @@
 // Check that SDKROOT does not infer simulator on when it points to a regular
 // SDK.
-// REQUIRES: system-darwin
+// REQUIRES: system-darwin && native
 //
 // RUN: rm -rf %t/SDKs/iPhoneOS8.0.0.sdk
 // RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r338553 - Use a dummy target so the test passes when default target is for a toolchain implements useIntegratedAs() -> true

2018-08-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Wed Aug  1 06:41:42 2018
New Revision: 338553

URL: http://llvm.org/viewvc/llvm-project?rev=338553&view=rev
Log:
Use a dummy target so the test passes when default target is for a toolchain 
implements useIntegratedAs() -> true

Modified:
cfe/trunk/test/Driver/integrated-as.c

Modified: cfe/trunk/test/Driver/integrated-as.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/integrated-as.c?rev=338553&r1=338552&r2=338553&view=diff
==
--- cfe/trunk/test/Driver/integrated-as.c (original)
+++ cfe/trunk/test/Driver/integrated-as.c Wed Aug  1 06:41:42 2018
@@ -7,7 +7,7 @@
 
 // FIAS: cc1as
 
-// RUN: %clang -### -fno-integrated-as -S %s 2>&1 \
+// RUN: %clang -target none -### -fno-integrated-as -S %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix NOFIAS
 
 // NOFIAS-NOT: cc1as


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r324884 - ASan+operator new[]: Add an option for more thorough operator new[] cookie poisoning

2018-02-12 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Mon Feb 12 03:49:02 2018
New Revision: 324884

URL: http://llvm.org/viewvc/llvm-project?rev=324884&view=rev
Log:
ASan+operator new[]: Add an option for more thorough operator new[] cookie 
poisoning

Summary:
Right now clang is skipping array cookie poisoning for any operator
new[] which is not part of the set of replaceable global allocation
functions.

This commit adds a flag to tell clang to poison all operator new[]
cookies.

A previous review was poisoning all array cookies unconditionally, but
there is an edge case which would stop working under ASan (a custom
operator new[] saves whatever pointer it returned, and then accesses
it).

This newer revision adds a command line argument to toggle this feature.

Original revision: https://reviews.llvm.org/D41301
Compiler-rt test revision with an explanation of the edge case: 
https://reviews.llvm.org/D41664

Reviewers: rjmccall, kcc, rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D43013

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=324884&r1=324883&r2=324884&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Feb 12 03:49:02 2018
@@ -898,6 +898,14 @@ def fno_sanitize_address_use_after_scope
Group,
Flags<[CoreOption, DriverOption]>,
HelpText<"Disable use-after-scope 
detection in AddressSanitizer">;
+def fsanitize_address_poison_class_member_array_new_cookie
+: Flag<[ "-" ], "fsanitize-address-poison-class-member-array-new-cookie">,
+  Group,
+  HelpText<"Enable poisoning array cookies when using class member 
operator new[] in AddressSanitizer">;
+def fno_sanitize_address_poison_class_member_array_new_cookie
+: Flag<[ "-" ], 
"fno-sanitize-address-poison-class-member-array-new-cookie">,
+  Group,
+  HelpText<"Disable poisoning array cookies when using class member 
operator new[] in AddressSanitizer">;
 def fsanitize_address_globals_dead_stripping : Flag<["-"], 
"fsanitize-address-globals-dead-stripping">,
 Group,
 HelpText<"Enable linker dead stripping 
of globals in AddressSanitizer">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=324884&r1=324883&r2=324884&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Feb 12 03:49:02 2018
@@ -159,6 +159,9 @@ CODEGENOPT(NewStructPathTBAA , 1, 0) ///
 CODEGENOPT(SaveTempLabels, 1, 0) ///< Save temporary labels.
 CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope 
detection
 ///< in AddressSanitizer
+CODEGENOPT(SanitizeAddressPoisonClassMemberArrayNewCookie, 1,
+   0) ///< Enable poisoning operator new[] which is not a replaceable
+  ///< global allocation function in AddressSanitizer
 CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead 
stripping
   ///< of globals in 
AddressSanitizer
 CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=324884&r1=324883&r2=324884&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon Feb 12 03:49:02 2018
@@ -1848,7 +1848,8 @@ Address ItaniumCXXABI::InitializeArrayCo
 
   // Handle the array cookie specially in ASan.
   if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0 &&
-  expr->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
+  (expr->getOperatorNew()->isReplaceableGlobalAllocationFunction() ||
+   CGM.getCodeGenOpts().SanitizeAddressPoisonClassMemberArrayNewCookie)) {
 // The store to the CookiePtr does not need to be instrumented.
 CGM.getSanitizerMetadata()->disableSanitizerForInstruction(SI);
 llvm::FunctionType *FTy =

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.

r321645 - ASan+operator new[]: Fix operator new[] cookie poisoning

2018-01-02 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Jan  2 05:21:50 2018
New Revision: 321645

URL: http://llvm.org/viewvc/llvm-project?rev=321645&view=rev
Log:
ASan+operator new[]: Fix operator new[] cookie poisoning

Summary:
The C++ Itanium ABI says:
No cookie is required if the new operator being used is ::operator 
new[](size_t, void*).

We should only avoid poisoning the cookie if we're calling this
operator, not others. This is dealt with before the call to
InitializeArrayCookie.

Reviewers: rjmccall, kcc, rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D41301

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=321645&r1=321644&r2=321645&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Tue Jan  2 05:21:50 2018
@@ -1847,8 +1847,7 @@ Address ItaniumCXXABI::InitializeArrayCo
   llvm::Instruction *SI = CGF.Builder.CreateStore(NumElements, NumElementsPtr);
 
   // Handle the array cookie specially in ASan.
-  if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0 &&
-  expr->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
+  if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0) {
 // The store to the CookiePtr does not need to be instrumented.
 CGM.getSanitizerMetadata()->disableSanitizerForInstruction(SI);
 llvm::FunctionType *FTy =

Modified: cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp?rev=321645&r1=321644&r2=321645&view=diff
==
--- cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp (original)
+++ cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp Tue Jan  2 
05:21:50 2018
@@ -7,7 +7,7 @@ namespace std {
   std::nothrow_t nothrow;
 }
 void *operator new[](size_t, const std::nothrow_t &) throw();
-void *operator new[](size_t, char *);
+void *operator new[](size_t, void *);
 
 struct C {
   int x;
@@ -53,3 +53,11 @@ C *CallPlacementNew() {
 }
 // ASAN-LABEL: CallPlacementNew
 // ASAN-NOT: __asan_poison_cxx_array_cookie
+
+void *operator new[](size_t n, int);
+
+C *CallNewWithArgs() {
+// ASAN-LABEL: CallNewWithArgs
+// ASAN: call void @__asan_poison_cxx_array_cookie
+  return new (123) C[20];
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321647 - Revert "ASan+operator new[]: Fix operator new[] cookie poisoning"

2018-01-02 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Jan  2 05:46:12 2018
New Revision: 321647

URL: http://llvm.org/viewvc/llvm-project?rev=321647&view=rev
Log:
Revert "ASan+operator new[]: Fix operator new[] cookie poisoning"

This reverts r321645.

I missed a compiler-rt test that needs updating.

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=321647&r1=321646&r2=321647&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Tue Jan  2 05:46:12 2018
@@ -1847,7 +1847,8 @@ Address ItaniumCXXABI::InitializeArrayCo
   llvm::Instruction *SI = CGF.Builder.CreateStore(NumElements, NumElementsPtr);
 
   // Handle the array cookie specially in ASan.
-  if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0) {
+  if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0 &&
+  expr->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
 // The store to the CookiePtr does not need to be instrumented.
 CGM.getSanitizerMetadata()->disableSanitizerForInstruction(SI);
 llvm::FunctionType *FTy =

Modified: cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp?rev=321647&r1=321646&r2=321647&view=diff
==
--- cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp (original)
+++ cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp Tue Jan  2 
05:46:12 2018
@@ -7,7 +7,7 @@ namespace std {
   std::nothrow_t nothrow;
 }
 void *operator new[](size_t, const std::nothrow_t &) throw();
-void *operator new[](size_t, void *);
+void *operator new[](size_t, char *);
 
 struct C {
   int x;
@@ -53,11 +53,3 @@ C *CallPlacementNew() {
 }
 // ASAN-LABEL: CallPlacementNew
 // ASAN-NOT: __asan_poison_cxx_array_cookie
-
-void *operator new[](size_t n, int);
-
-C *CallNewWithArgs() {
-// ASAN-LABEL: CallNewWithArgs
-// ASAN: call void @__asan_poison_cxx_array_cookie
-  return new (123) C[20];
-}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D50901: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks

2018-10-10 Thread Filipe Cabecinhas via cfe-commits
LGTM on the clang side too.

Thank you,
 Filipe

On Wed, 10 Oct 2018 at 23:33, Richard Smith - zygoloid via Phabricator <
revi...@reviews.llvm.org> wrote:

> rsmith accepted this revision.
> rsmith added a comment.
> This revision is now accepted and ready to land.
>
> This looks good to me. Sounds like @filcab is intending on doing another
> round of review too, so it'd make sense to double-check there before
> committing.
>
>
>
> 
> Comment at: docs/UndefinedBehaviorSanitizer.rst:101
> + conversions - when either one, or both of the types are signed.
>   Issues caught by this sanitizer are not undefined behavior,
>   but are often unintentional.
> 
> this sanitizer -> these sanitizers
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D50901
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r346001 - Change -fsanitize-address-poison-class-member-array-new-cookie to -fsanitize-address-poison-custom-array-cookie

2018-11-02 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Fri Nov  2 10:29:04 2018
New Revision: 346001

URL: http://llvm.org/viewvc/llvm-project?rev=346001&view=rev
Log:
Change -fsanitize-address-poison-class-member-array-new-cookie to 
-fsanitize-address-poison-custom-array-cookie

Handle it in the driver and propagate it to cc1

Reviewers: rjmccall, kcc, rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D52615

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=346001&r1=346000&r2=346001&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Fri Nov  2 10:29:04 2018
@@ -800,9 +800,11 @@ Level of field padding for AddressSaniti
 
 Enable linker dead stripping of globals in AddressSanitizer
 
-.. option:: -fsanitize-address-poison-class-member-array-new-cookie, 
-fno-sanitize-address-poison-class-member-array-new-cookie
+.. option:: -fsanitize-address-poison-custom-array-cookie, 
-fno-sanitize-address-poison-custom-array-cookie
 
-Enable poisoning array cookies when using class member operator new\[\] in 
AddressSanitizer
+Enable "poisoning" array cookies when allocating arrays with a custom operator 
new\[\] in Address Sanitizer, preventing accesses to the cookies from user 
code. An array cookie is a small implementation-defined header added to certain 
array allocations to record metadata such as the length of the array. Accesses 
to array cookies from user code are technically allowed by the standard but are 
more likely to be the result of an out-of-bounds array access.
+
+An operator new\[\] is "custom" if it is not one of the allocation functions 
provided by the C++ standard library. Array cookies from non-custom allocation 
functions are always poisoned.
 
 .. option:: -fsanitize-address-use-after-scope, 
-fno-sanitize-address-use-after-scope
 

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=346001&r1=346000&r2=346001&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Nov  2 10:29:04 2018
@@ -3000,8 +3000,8 @@ Execute ``clang-cl /?`` to see a list of
   -fno-debug-macroDo not emit macro debug information
   -fno-delayed-template-parsing
   Disable delayed template parsing
-  -fno-sanitize-address-poison-class-member-array-new-cookie
-  Disable poisoning array cookies when using class 
member operator new[] in AddressSanitizer
+  -fno-sanitize-address-poison-custom-array-cookie
+  Disable poisoning array cookies when using 
custom operator new[] in AddressSanitizer
   -fno-sanitize-address-use-after-scope
   Disable use-after-scope detection in 
AddressSanitizer
   -fno-sanitize-blacklist Don't use blacklist file for sanitizers
@@ -3037,8 +3037,8 @@ Execute ``clang-cl /?`` to see a list of
   Level of field padding for AddressSanitizer
   -fsanitize-address-globals-dead-stripping
   Enable linker dead stripping of globals in 
AddressSanitizer
-  -fsanitize-address-poison-class-member-array-new-cookie
-  Enable poisoning array cookies when using class 
member operator new[] in AddressSanitizer
+  -fsanitize-address-poison-custom-array-cookie
+  Enable poisoning array cookies when using custom 
operator new[] in AddressSanitizer
   -fsanitize-address-use-after-scope
   Enable use-after-scope detection in 
AddressSanitizer
   -fsanitize-blacklist=

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=346001&r1=346000&r2=346001&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Nov  2 10:29:04 2018
@@ -971,14 +971,14 @@ def fno_sanitize_address_use_after_scope
Group,
Flags<[CoreOption, Drive

Re: [PATCH] D50901: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks

2018-10-08 Thread Filipe Cabecinhas via cfe-commits
Sorry about that. I’m away today but I don’t think you’ve answered my
questions about “why not support standalone UBSan in tests”. Sorry if I
missed the answers if you did. Will review the latest tomorrow.

Thank you,
 Filipe

On Mon, 8 Oct 2018 at 07:48, Roman Lebedev via Phabricator <
revi...@reviews.llvm.org> wrote:

> lebedev.ri added a comment.
>
> Ping! It seemed we were so close here :)
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D50901
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335858 - Fix test that was failing on Windows due to too many backslashes

2018-06-28 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Thu Jun 28 07:16:13 2018
New Revision: 335858

URL: http://llvm.org/viewvc/llvm-project?rev=335858&view=rev
Log:
Fix test that was failing on Windows due to too many backslashes

Modified:
cfe/trunk/test/Driver/linux-per-target-runtime-dir.c

Modified: cfe/trunk/test/Driver/linux-per-target-runtime-dir.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-per-target-runtime-dir.c?rev=335858&r1=335857&r2=335858&view=diff
==
--- cfe/trunk/test/Driver/linux-per-target-runtime-dir.c (original)
+++ cfe/trunk/test/Driver/linux-per-target-runtime-dir.c Thu Jun 28 07:16:13 
2018
@@ -18,4 +18,4 @@
 // RUN: --target=x86_64-linux-gnu \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
-// CHECK-CLANGRT-X8664: 
x86_64-linux-gnu{{/|}}lib{{/|}}libclang_rt.builtins.a
+// CHECK-CLANGRT-X8664: 
x86_64-linux-gnu{{/|\\}}lib{{/|\\}}libclang_rt.builtins.a


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D63194: [clangd] Link and initialize target infos

2020-04-10 Thread Filipe Cabecinhas via cfe-commits
Hi Kadir,

Can you fix the target_info.test clangd test you committed in this
revision, please?
I see you've tried fixing it later by adding `REQUIRES:
x86-registered-target`, but now it's never running because that feature
isn't (ever) set.
Here's a buildbot run showing it as unsupported (x86 target is built):
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/26746/steps/test-check-all/logs/stdio

I saw you tried to fix the test in r364413 ([clangd] Disable failing
unittest on non-x86 platforms) because it was always failing. The problem
is that, even though the feature check is needed, the test still isn't
working well. I just ran it manually and didn't get the target changed from
my host one.

Here's a diff for the feature check that you can apply to propagate the
feature. But we still need to get the clangd code fixed so it picks up the
target:

```
diff --git a/clang-tools-extra/clangd/test/lit.cfg.py
b/clang-tools-extra/clangd/test/lit.cfg.py
index 5030ca356ef..54406498af0 100644
--- a/clang-tools-extra/clangd/test/lit.cfg.py
+++ b/clang-tools-extra/clangd/test/lit.cfg.py
@@ -3,6 +3,19 @@ import lit.llvm
 lit.llvm.initialize(lit_config, config)
 lit.llvm.llvm_config.use_clang()

+# required for target_info.test
+def calculate_arch_features(arch_string):
+features = []
+for arch in arch_string.split():
+features.append(arch.lower() + '-registered-target')
+return features
+
+lit.llvm.llvm_config.feature_config(
+[('--assertion-mode', {'ON': 'asserts'}),
+ ('--cxxflags', {r'-D_GLIBCXX_DEBUG\b': 'libstdcxx-safe-mode'}),
+ ('--targets-built', calculate_arch_features)
+ ])
+
 config.name = 'Clangd'
 config.suffixes = ['.test']
 config.excludes = ['Inputs']
```

Thank you,

  Filipe

  Filipe


On Wed, Jun 26, 2019 at 8:48 AM Kadir Cetinkaya via Phabricator via
cfe-commits  wrote:

> kadircet closed this revision.
> kadircet added a comment.
>
> Landed as rL364387 
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D63194/new/
>
> https://reviews.llvm.org/D63194
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D63194: [clangd] Link and initialize target infos

2020-04-14 Thread Filipe Cabecinhas via cfe-commits
Hi Kadir,

Thank you for looking into this.
Unfortunately, I can't repro this anymore. I wonder if I had a weird stale
clangd or something. Current test (now changed to armv7) does set the
target properly. When I tried last time, it wasn't setting it, and was
defaulting to my system's (darwin).

Thank you,
  Filipe


On Sat, Apr 11, 2020 at 5:20 PM Kadir Çetinkaya  wrote:

> Hi Filipe! Thanks for letting me know, I've sent
> https://reviews.llvm.org/D77944 to enable this in clangd lit config.
>
> Regarding the failure, I can't seem to repro on machines I have access to.
> The premerge-tests also seems to be succeeding, please see
> https://results.llvm-merge-guard.org/BETA_amd64_debian_testing_clang8-626/console-log.txt
> .
>
> Can you provide more info about how you've ran the test?
>
> On Fri, Apr 10, 2020 at 4:23 PM Filipe Cabecinhas 
> wrote:
>
>> Hi Kadir,
>>
>> Can you fix the target_info.test clangd test you committed in this
>> revision, please?
>> I see you've tried fixing it later by adding `REQUIRES:
>> x86-registered-target`, but now it's never running because that feature
>> isn't (ever) set.
>> Here's a buildbot run showing it as unsupported (x86 target is built):
>> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/26746/steps/test-check-all/logs/stdio
>>
>> I saw you tried to fix the test in r364413 ([clangd] Disable failing
>> unittest on non-x86 platforms) because it was always failing. The problem
>> is that, even though the feature check is needed, the test still isn't
>> working well. I just ran it manually and didn't get the target changed from
>> my host one.
>>
>> Here's a diff for the feature check that you can apply to propagate the
>> feature. But we still need to get the clangd code fixed so it picks up the
>> target:
>>
>> ```
>> diff --git a/clang-tools-extra/clangd/test/lit.cfg.py
>> b/clang-tools-extra/clangd/test/lit.cfg.py
>> index 5030ca356ef..54406498af0 100644
>> --- a/clang-tools-extra/clangd/test/lit.cfg.py
>> +++ b/clang-tools-extra/clangd/test/lit.cfg.py
>> @@ -3,6 +3,19 @@ import lit.llvm
>>  lit.llvm.initialize(lit_config, config)
>>  lit.llvm.llvm_config.use_clang()
>>
>> +# required for target_info.test
>> +def calculate_arch_features(arch_string):
>> +features = []
>> +for arch in arch_string.split():
>> +features.append(arch.lower() + '-registered-target')
>> +return features
>> +
>> +lit.llvm.llvm_config.feature_config(
>> +[('--assertion-mode', {'ON': 'asserts'}),
>> + ('--cxxflags', {r'-D_GLIBCXX_DEBUG\b': 'libstdcxx-safe-mode'}),
>> + ('--targets-built', calculate_arch_features)
>> + ])
>> +
>>  config.name = 'Clangd'
>>  config.suffixes = ['.test']
>>  config.excludes = ['Inputs']
>> ```
>>
>> Thank you,
>>
>>   Filipe
>>
>>   Filipe
>>
>>
>> On Wed, Jun 26, 2019 at 8:48 AM Kadir Cetinkaya via Phabricator via
>> cfe-commits  wrote:
>>
>>> kadircet closed this revision.
>>> kadircet added a comment.
>>>
>>> Landed as rL364387 
>>>
>>>
>>> Repository:
>>>   rG LLVM Github Monorepo
>>>
>>> CHANGES SINCE LAST ACTION
>>>   https://reviews.llvm.org/D63194/new/
>>>
>>> https://reviews.llvm.org/D63194
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25199: [ubsan] Sanitize deleted pointers

2016-10-04 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

In https://reviews.llvm.org/D25199#560061, @vsk wrote:

> My question was about whether it's possible to resume normal program 
> execution after printing the stack trace from the segv handler. I had assumed 
> this is not possible, and (mistakenly) thought that you were suggesting this 
> approach.


I guess we can eventually add a warning if you have this check + trap-function. 
If there's really a need for it.



> UndefinedBehaviorSanitizer.rst:122
> +  -  ``-fsanitize=value-after-delete``: Set the value of the pointer
> + passed in a delete expression to 0xDEADBEEF.
>-  ``-fsanitize=vla-bound``: A variable-length array whose bound

Why just `delete` and not `free()`?

> CGExprScalar.cpp:416
> +  if (arg->IgnoreImplicit()->isLValue() &&
> +  !arg->HasSideEffects(CGF.getContext())) {
> +LValue LHS = EmitLValue(arg);

Missing a test for this condition.

> sanitize-value-after-delete.cpp:2
> +// Test -fsanitize-value-after-delete
> +// RUN: %clang_cc1 -O3 -fsanitize=value-after-delete -disable-llvm-optzns 
> -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
> +

Please keep the test simple. You don't even need C++11 (in addition to the 
flags vsk mentioned).

> sanitize-value-after-delete.cpp:22
> +// CHECK: store {{.*}} inttoptr (i64 -2401053088876216593 {{.*}} %p2
> +// CHECK-NOT: store {{.*}} inttoptr (i64 -2401053088876216593 {{.*}} %p2
> +// CHECK-LABEL: DO_NOT_MODIFY

Why?

https://reviews.llvm.org/D25199



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291236 - [ubsan] Minimize size of data for type_mismatch (Redo of D19667)

2017-01-06 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Fri Jan  6 08:40:12 2017
New Revision: 291236

URL: http://llvm.org/viewvc/llvm-project?rev=291236&view=rev
Log:
[ubsan] Minimize size of data for type_mismatch (Redo of D19667)

Summary:
This patch makes the type_mismatch static data 7 bytes smaller (and it
ends up being 16 bytes smaller due to alignment restrictions, at least
on some x86-64 environments).

It revs up the type_mismatch handler version since we're breaking binary
compatibility. I will soon post a patch for the compiler-rt side.

Reviewers: rsmith, kcc, vitalybuka, pgousseau, gbedwell

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D28242

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/catch-undef-behavior.c
cfe/trunk/test/CodeGen/sanitize-recover.c
cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=291236&r1=291235&r2=291236&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Jan  6 08:40:12 2017
@@ -604,12 +604,13 @@ void CodeGenFunction::EmitTypeCheck(Type
   }
 
   if (Checks.size() > 0) {
+// Make sure we're not losing information. Alignment needs to be a power of
+// 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
 llvm::Constant *StaticData[] = {
- EmitCheckSourceLocation(Loc),
-  EmitCheckTypeDescriptor(Ty),
-  llvm::ConstantInt::get(SizeTy, AlignVal),
-  llvm::ConstantInt::get(Int8Ty, TCK)
-};
+EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty),
+llvm::ConstantInt::get(Int8Ty, AlignVal ? llvm::Log2_64(AlignVal) : 1),
+llvm::ConstantInt::get(Int8Ty, TCK)};
 EmitCheck(Checks, SanitizerHandler::TypeMismatch, StaticData, Ptr);
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=291236&r1=291235&r2=291236&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Jan  6 08:40:12 2017
@@ -120,7 +120,7 @@ enum TypeEvaluationKind {
   SANITIZER_CHECK(OutOfBounds, out_of_bounds, 0)   
\
   SANITIZER_CHECK(ShiftOutOfBounds, shift_out_of_bounds, 0)
\
   SANITIZER_CHECK(SubOverflow, sub_overflow, 0)
\
-  SANITIZER_CHECK(TypeMismatch, type_mismatch, 0)  
\
+  SANITIZER_CHECK(TypeMismatch, type_mismatch, 1)  
\
   SANITIZER_CHECK(VLABoundNotPositive, vla_bound_not_positive, 0)
 
 enum SanitizerHandler {

Modified: cfe/trunk/test/CodeGen/catch-undef-behavior.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/catch-undef-behavior.c?rev=291236&r1=291235&r2=291236&view=diff
==
--- cfe/trunk/test/CodeGen/catch-undef-behavior.c (original)
+++ cfe/trunk/test/CodeGen/catch-undef-behavior.c Fri Jan  6 08:40:12 2017
@@ -6,16 +6,16 @@
 // CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x 
i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 
 // FIXME: When we only emit each type once, use [[INT]] more below.
-// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 
100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
-// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
+// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 
100, i32 5 {{.*}} @[[INT]], i8 2, i8 1
+// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i8 2, i8 0
 // CHECK-UBSAN: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, 
{{.*}} @{{.*}}
 // CHECK-UBSAN: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, 
{{.*}} @{{.*}}
-// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 
4, i8 0 }
-// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 
4, i8 1 }
+// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i8 
2, i8 0 }
+// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i8 
2, i8 1 }
 
 // CHECK-UBSAN: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, 
[11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
 
-// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} 
@[[STRUCT_S]], i64 4, i8 3 }
+// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} 
@[[STRUCT_S]], i8 2, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LIN

Re: [PATCH] D23498: Left shifts of negative values are defined if -fwrapv is set

2016-08-16 Thread Filipe Cabecinhas via cfe-commits
LGTM.

Thank you,

 Filipe

On Tue, Aug 16, 2016 at 10:23 AM, Davide Italiano  wrote:
> davide added a comment.
>
> The `Sema` bits look fine to me. I'll let Filipe comment on the sanitizer 
> part.
>
>
> https://reviews.llvm.org/D23498
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21695: [clang] Version support for UBSan handlers

2016-08-17 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

In https://reviews.llvm.org/D21695#514080, @vsk wrote:

> Running sanitized programs in production sounds strange to me. But, if there 
> isn't really a cost to supporting this, I suppose it's fine.


It does, and most likely this change wouldn't affect them, as I would guess 
people running sanitizers in production would probably use sanitize-trap.
But it's being done on parts of Android at least:
https://twitter.com/CopperheadOS/status/717086242966351872


https://reviews.llvm.org/D21695



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24048: [Driver] [Darwin] Add sanitizer libraries even if -nodefaultlibs is passed

2016-08-30 Thread Filipe Cabecinhas via cfe-commits
I don't think so. "No default libs" should mean "no default libs", not
"some default libs". Maybe you're using an alternate sanitizer lib or
something, hence usage of that flag.

Thank you,

 Filipe

On Tuesday, 30 August 2016, Chris Bieneman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> beanz created this revision.
> beanz added reviewers: zaks.anna, kubabrecka, bogner.
> beanz added a subscriber: cfe-commits.
>
> The -nodefaultlibs and -nostdlib flags suppress all the runtime libraries
> that the driver puts on the link line. This feels wrong. If a user
> specifies "-fsanitize=" I think it is expected that the sanitizer
> library would be included on the link line.
>
> https://reviews.llvm.org/D24048
>
> Files:
>   lib/Driver/ToolChains.cpp
>   lib/Driver/ToolChains.h
>   lib/Driver/Tools.cpp
>
> Index: lib/Driver/Tools.cpp
> ===
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -8032,6 +8032,8 @@
>
>  // Let the tool chain choose which runtime library to link.
>  getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
> +  } else {
> +getMachOToolChain().AddLinkSanitizerLibArgs(Args, CmdArgs);
>}
>
>if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
> Index: lib/Driver/ToolChains.h
> ===
> --- lib/Driver/ToolChains.h
> +++ lib/Driver/ToolChains.h
> @@ -282,6 +282,10 @@
>virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
>   llvm::opt::ArgStringList &CmdArgs)
> const;
>
> +  virtual void
> +  AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
> +  llvm::opt::ArgStringList &CmdArgs) const {}
> +
>virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
>llvm::opt::ArgStringList &CmdArgs)
> const {
>}
> @@ -571,6 +575,10 @@
>
>RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const
> override;
>
> +  void
> +  AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
> +  llvm::opt::ArgStringList &CmdArgs) const
> override;
> +
>void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
>   llvm::opt::ArgStringList &CmdArgs) const
> override;
>
> Index: lib/Driver/ToolChains.cpp
> ===
> --- lib/Driver/ToolChains.cpp
> +++ lib/Driver/ToolChains.cpp
> @@ -425,22 +425,7 @@
>  return;
>}
>
> -  const SanitizerArgs &Sanitize = getSanitizerArgs();
> -  if (Sanitize.needsAsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
> -  if (Sanitize.needsUbsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
> -  if (Sanitize.needsTsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
> -  if (Sanitize.needsStatsRt()) {
> -StringRef OS = isTargetMacOS() ? "osx" : "iossim";
> -AddLinkRuntimeLib(Args, CmdArgs,
> -  (Twine("libclang_rt.stats_client_") + OS +
> ".a").str(),
> -  /*AlwaysLink=*/true);
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
> -  }
> -  if (Sanitize.needsEsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
> +  AddLinkSanitizerLibArgs(Args, CmdArgs);
>
>// Otherwise link libSystem, then the dynamic runtime library, and
> finally any
>// target specific static runtime library.
> @@ -495,6 +480,26 @@
>}
>  }
>
> +void DarwinClang::AddLinkSanitizerLibArgs(
> +const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
> const {
> +  const SanitizerArgs &Sanitize = getSanitizerArgs();
> +  if (Sanitize.needsAsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
> +  if (Sanitize.needsUbsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
> +  if (Sanitize.needsTsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
> +  if (Sanitize.needsStatsRt()) {
> +StringRef OS = isTargetMacOS() ? "osx" : "iossim";
> +AddLinkRuntimeLib(Args, CmdArgs,
> +  (Twine("libclang_rt.stats_client_") + OS +
> ".a").str(),
> +  /*AlwaysLink=*/true);
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
> +  }
> +  if (Sanitize.needsEsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
> +}
> +
>  void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
>const OptTable &Opts = getDriver().getOpts();
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24048: [Driver] [Darwin] Add sanitizer libraries even if -nodefaultlibs is passed

2016-08-30 Thread Filipe Cabecinhas via cfe-commits
Haha, the joke is on me. I had the opposite opinion two years ago (I
guess by virtue of working on the sanitizers for a while, I've come to
see them as default libs?).

Making the behavior more consistent is good, and the r218541
discussion (+220455) makes me think your patch is good. We end up
having *some* weird behavior when mixing this type of flags. But I
think Bruno's suggestion to warn (I think maybe documenting it is
enough, though) might be good.

Thank you,

 Filipe


On Tue, Aug 30, 2016 at 9:15 PM, Bruno Cardoso Lopes via cfe-commits
 wrote:
> bruno added a subscriber: bruno.
> bruno added a comment.
>
> Regardless of the way we decide to go with this, it would be nice if a driver 
> level warning is used to tell users about any  non-obvious assumed behavior 
> when these flags are used together.
>
>
> https://reviews.llvm.org/D24048
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24048: [Driver] [Darwin] Add sanitizer libraries even if -nodefaultlibs is passed

2016-09-08 Thread Filipe Cabecinhas via cfe-commits
It seems some people on this thread (I'm sorry if everyone is taking this
into account, but it seemed to me that this was going unnoticed, I want to
make sure everyone is on the same page) is only talking about linking (or
not) the sanitizer runtimes. But that's not the only thing.

Depending on the OS, -fsanitize will also link in the sanitizer's
dependencies, which might include libdl, libc++, and others. That was the
reason why the patch was reverted last time we tried to change this flag's
behavior: a sanitized libc++ needs the sanitizer libs, but not libc++...
And it might need other dependencies for the sanitizers.

Maybe have something like:
-fsanitize=blah links all libs
-fsanitize=blah -nodefaultlibs links nothing
And then have two flags for explicitly linking either the sanitizer flag or
the dependencies? Libc++ would still have the problem of wanting some
dependencies but not all, though :-(

Thank you,

 Filipe

On Thursday, 8 September 2016, Anna Zaks  wrote:

> zaks.anna added a comment.
>
> > I don't see the point of adding another flag to control this when we
> already have a perfectly good set of
>
> >  flags that already do the right thing -- that takes us three levels
> deep in flags overriding the behavior of
>
> >  other flags, and I don't see how it actually helps our users in any way.
>
>
> Going with silently linking the sanitizer runtimes when -nostdlib is
> passed will cause regressions in user experience. They will start getting
> inexplicable run time failures instead of build failures. Which solution do
> you propose to fix this problem?
>
> This specific situation comes up often on internal mailing lists, so we
> should not go for a solution that regresses the behavior on Darwin.
>
>
> https://reviews.llvm.org/D24048
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24628: [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiber

2016-09-16 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

Please add some printf calls to the test, to show that you have the correct 
stack+size, too.

Thanks for working on this.
Filipe



Comment at: lib/asan/asan_thread.cc:141
@@ -140,3 +140,3 @@
   if (!fake_stack_save && current_fake_stack)
 current_fake_stack->Destroy(this->tid());
 }

Please make sure you're accounting for this. It seems the test is always 
passing nullptr to start_switch, which shouldn't be done unless you're 
finishing up a fiber execution, IIRC.


Comment at: lib/asan/asan_thread.cc:162
@@ -155,1 +161,3 @@
+*size_old = stack_top_ - stack_bottom_;
+  }
   stack_bottom_ = next_stack_bottom_;

I think the usual style is: one statement => no braces.


Comment at: test/asan/TestCases/Linux/swapcontext_annotation.cc:9
@@ -8,3 +8,3 @@
 // This test is too subtle to try on non-x86 arch for now.
-// REQUIRES: x86_64-supported-target,i386-supported-target
+// REQUIRES: x86-target-arch
 

blastrock wrote:
> andriigrynenko wrote:
> > The test was actually broken in trunk (not updated for the fakestack 
> > argument). Apparently it was never run (considered unsupported) because of 
> > wrong targets here. 
> Indeed, my bad, I forgot to compile and run the tests after the last 
> modification I made to that patch. Sorry for that.
> 
> I didn't need to change this line to run them on my computer though, but if 
> you know what you are doing with this line, it's ok. And it's strange indeed 
> that no buildfarm caught this...
They wouldn't catch tests not being run.
Test with LLVM_LIT_ARGS=-v (instead of -sv) on your cmake config and 
double-check that the tests are run.


Comment at: test/asan/TestCases/Linux/swapcontext_annotation.cc:47
@@ -46,3 +46,3 @@
   CallNoReturn();
-  __sanitizer_finish_switch_fiber();
+  __sanitizer_finish_switch_fiber(NULL, NULL, NULL);
 

dvyukov wrote:
> #include  for NULL
nit: nullptr?


https://reviews.llvm.org/D24628



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r293343 - [ubsan] Sanity-check shift amounts before truncation (fixes PR27271)

2017-01-30 Thread Filipe Cabecinhas via cfe-commits
Another example + possible fix (two WidthMinusOne, one per (possibly
different) bitwidth): (not fully tested)

int f() {
  return 0 << 0L;
}

diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 40d949dece..5c9055d49a 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -2751,8 +2751,9 @@ Value *ScalarExprEmitter::EmitShl(const BinOpInfo &Ops) {
isa(Ops.LHS->getType())) {
 CodeGenFunction::SanitizerScope SanScope(&CGF);
 SmallVector, 2> Checks;
-llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, Ops.RHS);
-llvm::Value *ValidExponent = Builder.CreateICmpULE(Ops.RHS, WidthMinusOne);
+llvm::Value *WidthMinusOneRHS = GetWidthMinusOneValue(Ops.LHS, Ops.RHS);
+llvm::Value *WidthMinusOneLHS = GetWidthMinusOneValue(Ops.LHS, Ops.LHS);
+llvm::Value *ValidExponent = Builder.CreateICmpULE(Ops.RHS,
WidthMinusOneRHS);

 if (SanitizeExponent) {
   Checks.push_back(
@@ -2768,11 +2769,11 @@ Value *ScalarExprEmitter::EmitShl(const
BinOpInfo &Ops) {
   llvm::BasicBlock *CheckShiftBase = CGF.createBasicBlock("check");
   Builder.CreateCondBr(ValidExponent, CheckShiftBase, Cont);
   CGF.EmitBlock(CheckShiftBase);
-  llvm::Value *BitsShiftedOff =
-Builder.CreateLShr(Ops.LHS,
-   Builder.CreateSub(WidthMinusOne, RHS, "shl.zeros",
- /*NUW*/true, /*NSW*/true),
-   "shl.check");
+  llvm::Value *BitsShiftedOff = Builder.CreateLShr(
+  Ops.LHS,
+  Builder.CreateSub(WidthMinusOneLHS, RHS, "shl.zeros",
+/*NUW*/ true, /*NSW*/ true),
+  "shl.check");
   if (CGF.getLangOpts().CPlusPlus) {
 // In C99, we are not permitted to shift a 1 bit into the sign bit.
 // Under C++11's rules, shifting a 1 bit into the sign bit is
  F


On Mon, Jan 30, 2017 at 11:51 AM, Alex L via cfe-commits
 wrote:
> Hi Vedant,
>
> This commit has caused a compiler crash in our stage 2 green dragon
> ASAN+Ubsan bot
> (http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_build/). I have
> reverted it in r293475. The following example reproduces the crash with
> -fsanitize=undefined :
>
>   typedef unsigned long long uint64_t;
>   typedef signed long long int64_t;
>
>   uint64_t foo(int64_t x, unsigned i) {
>return x << i;
>   }
>
> Alex
>
>
> On 27 January 2017 at 23:02, Vedant Kumar via cfe-commits
>  wrote:
>>
>> Author: vedantk
>> Date: Fri Jan 27 17:02:44 2017
>> New Revision: 293343
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=293343&view=rev
>> Log:
>> [ubsan] Sanity-check shift amounts before truncation (fixes PR27271)
>>
>> Ubsan does not report UB shifts in some cases where the shift exponent
>> needs to be truncated to match the type of the shift base. We perform a
>> range check on the truncated shift amount, leading to false negatives.
>>
>> Fix the issue (PR27271) by performing the range check on the original
>> shift amount.
>>
>> Differential Revision: https://reviews.llvm.org/D29234
>>
>> Added:
>> cfe/trunk/test/CodeGen/ubsan-shift.c
>> Modified:
>> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=293343&r1=293342&r2=293343&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Jan 27 17:02:44 2017
>> @@ -2751,8 +2751,8 @@ Value *ScalarExprEmitter::EmitShl(const
>> isa(Ops.LHS->getType())) {
>>  CodeGenFunction::SanitizerScope SanScope(&CGF);
>>  SmallVector, 2> Checks;
>> -llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, RHS);
>> -llvm::Value *ValidExponent = Builder.CreateICmpULE(RHS,
>> WidthMinusOne);
>> +llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, Ops.RHS);
>> +llvm::Value *ValidExponent = Builder.CreateICmpULE(Ops.RHS,
>> WidthMinusOne);
>>
>>  if (SanitizeExponent) {
>>Checks.push_back(
>>
>> Added: cfe/trunk/test/CodeGen/ubsan-shift.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-shift.c?rev=293343&view=auto
>>
>> ==
>> --- cfe/trunk/test/CodeGen/ubsan-shift.c (added)
>> +++ cfe/trunk/test/CodeGen/ubsan-shift.c Fri Jan 27 17:02:44 2017
>> @@ -0,0 +1,29 @@
>> +// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsanitize=shift-exponent
>> -emit-llvm %s -o - | FileCheck %s
>> +
>> +// CHECK-LABEL: define i32 @f1
>> +int f1(int c, int shamt) {
>> +// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
>> +// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
>> +  return 1 << (c << shamt);
>> +}
>> +
>> +// CHECK-LABEL: define i32 @f2
>> +int f2(long c, int shamt) {
>> +// CHECK: icmp ul

r289444 - [clang] Version support for UBSan handlers

2016-12-12 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Mon Dec 12 10:18:40 2016
New Revision: 289444

URL: http://llvm.org/viewvc/llvm-project?rev=289444&view=rev
Log:
[clang] Version support for UBSan handlers

This adds a way for us to version any UBSan handler by itself.
The patch overrides D21289 for a better implementation (we're able to
rev up a single handler).

After this, then we can land a slight modification of D19667+D19668.

We probably don't want to keep all the versions in compiler-rt (maybe we
want to deprecate on one release and remove the old handler on the next
one?), but with this patch we will loudly fail to compile when mixing
incompatible handler calls, instead of silently compiling and then
providing bad error messages.

Reviewers: kcc, samsonov, rsmith, vsk

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D21695

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=289444&r1=289443&r2=289444&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Dec 12 10:18:40 2016
@@ -959,8 +959,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   SanitizerScope SanScope(this);
   EmitCheck(std::make_pair(static_cast(Builder.getFalse()),
SanitizerKind::Unreachable),
-"builtin_unreachable", 
EmitCheckSourceLocation(E->getExprLoc()),
-None);
+SanitizerHandler::BuiltinUnreachable,
+EmitCheckSourceLocation(E->getExprLoc()), None);
 } else
   Builder.CreateUnreachable();
 

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=289444&r1=289443&r2=289444&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Dec 12 10:18:40 2016
@@ -2862,7 +2862,7 @@ void CodeGenFunction::EmitFunctionEpilog
 EmitCheckSourceLocation(RetNNAttr->getLocation()),
 };
 EmitCheck(std::make_pair(Cond, SanitizerKind::ReturnsNonnullAttribute),
-  "nonnull_return", StaticData, None);
+  SanitizerHandler::NonnullReturn, StaticData, None);
   }
 }
 Ret = Builder.CreateRet(RV);
@@ -3202,7 +3202,7 @@ void CodeGenFunction::EmitNonNullArgChec
   llvm::ConstantInt::get(Int32Ty, ArgNo + 1),
   };
   EmitCheck(std::make_pair(Cond, SanitizerKind::NonnullAttribute),
-"nonnull_arg", StaticData, None);
+SanitizerHandler::NonnullArg, StaticData, None);
 }
 
 void CodeGenFunction::EmitCallArgs(

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=289444&r1=289443&r2=289444&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Dec 12 10:18:40 2016
@@ -2802,8 +2802,8 @@ void CodeGenFunction::EmitVTablePtrCheck
   llvm::MDString::get(CGM.getLLVMContext(), "all-vtables"));
   llvm::Value *ValidVtable = Builder.CreateCall(
   CGM.getIntrinsic(llvm::Intrinsic::type_test), {CastedVTable, 
AllVtables});
-  EmitCheck(std::make_pair(TypeTest, M), "cfi_check_fail", StaticData,
-{CastedVTable, ValidVtable});
+  EmitCheck(std::make_pair(TypeTest, M), SanitizerHandler::CFICheckFail,
+StaticData, {CastedVTable, ValidVtable});
 }
 
 bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) 
{
@@ -2835,7 +2835,7 @@ llvm::Value *CodeGenFunction::EmitVTable
   llvm::Value *CheckResult = Builder.CreateExtractValue(CheckedLoad, 1);
 
   EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall),
-"cfi_check_fail", nullptr, nullptr);
+SanitizerHandler::CFICheckFail, nullptr, nullptr);
 
   return Builder.CreateBitCast(
   Builder.CreateExtractValue(CheckedLoad, 0),

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=289444&r1=289443&r2=289444&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Dec 12 10:18:40 2016
@@ -608,7 +608,7 @@ void CodeGenFunction::EmitTypeCheck(Type
   llvm::ConstantInt::get(SizeTy, AlignVal),
   llvm::ConstantInt::get(Int8Ty, TCK)
 };
-EmitCheck(Checks, "type_mismatch", Static

r289446 - [Fix] Add missing include from r289444.

2016-12-12 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Mon Dec 12 10:43:40 2016
New Revision: 289446

URL: http://llvm.org/viewvc/llvm-project?rev=289446&view=rev
Log:
[Fix] Add missing include from r289444.

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=289446&r1=289445&r2=289446&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Dec 12 10:43:40 2016
@@ -37,6 +37,8 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
 
+#include 
+
 using namespace clang;
 using namespace CodeGen;
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21695: [clang] Version support for UBSan handlers

2016-12-12 Thread Filipe Cabecinhas via cfe-commits
Thanks Vedant!
Andrew: does Android not support C++11? I don't understand why it wouldn't
have these funcions.

Thank you,

 Filipe

On Mon, 12 Dec 2016 at 18:58, Vedant Kumar  wrote:

>
>
> > On Dec 12, 2016, at 10:17 AM, Andrew Ford via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
> >
>
> > andrewford added a comment.
>
> >
>
> > This broke the build on android due to use of std::to_string. Would
> someone mind changing it to llvm::to_string, I don't have commit access to
> change it myself. Thanks!
>
>
>
> Should be done with r289452.
>
>
>
> vedant
>
>
>
> >
>
> >
>
> > Repository:
>
> >  rL LLVM
>
> >
>
> > https://reviews.llvm.org/D21695
>
> >
>
> >
>
> >
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-09-10 Thread Filipe Cabecinhas via cfe-commits
filcab abandoned this revision.
filcab added a comment.

We don't need this anymore, since we're making some internal changes.
Thank you for the feedback!



Comment at: include/clang/Driver/Options.td:1853-1854
@@ -1853,1 +1852,4 @@
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker ">, 
Group;
+def linker : Separate<["-"], "linker">, Alias, 
MetaVarName<"">;
+def linker_EQ : Joined<["-"], "linker=">, Alias;
 

echristo wrote:
> Any reason to have both options?
I went and double-checked our docs. We should only need one.


Comment at: include/clang/Driver/Options.td:1853
@@ -1853,1 +1852,3 @@
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker ">, 
Group;
+def linker_EQ : Joined<["-"], "linker=">, Alias, 
MetaVarName<"">;
 

echristo wrote:
> thakis wrote:
> > Any reason to have another alias for this at all? Does gcc understand this 
> > spelling? If not, could you limit this flag to PS4 targets? (I'm guessing 
> > you need it for PS4 targets for some reason.)
> Any reason? (And I'm not sure how to limit it btw on target).
Same here, no idea how to limit the flag to a specific target.


Comment at: test/Driver/fuse-ld.c:27-33
@@ -26,1 +26,9 @@
 
+// -linker= is an alias to fuse-ld. Don't need to retry all combinations
+// RUN: %clang %s -### -linker gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// CHECK-FREEBSD-LINKER-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
+

echristo wrote:
> Bet this doesn't work :)
Derp. Sorry.


Comment at: test/Driver/fuse-ld.c:32-33
@@ +31,4 @@
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// CHECK-FREEBSD-LINKER-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
+

pcc wrote:
> Prefix mismatch here.
Ah yes. Thanks!


http://reviews.llvm.org/D11737



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11279: Initial patch for PS4 toolchain

2015-09-10 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 34522.
filcab marked 12 inline comments as done.
filcab added a comment.
This revision is now accepted and ready to land.

Addressed review comments.


http://reviews.llvm.org/D11279

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  lib/Frontend/InitHeaderSearch.cpp
  test/Driver/Inputs/scei-ps4_tree/target/include/.keep
  test/Driver/Inputs/scei-ps4_tree/target/include_common/.keep
  test/Driver/debug-options.c
  test/Driver/ps4-header-search.c
  test/Driver/ps4-linker-non-win.c
  test/Driver/ps4-linker-win.c
  test/Driver/ps4-pic.c
  test/Driver/ps4-sdk-root.c
  test/Driver/rtti-options.cpp
  test/Driver/stack-protector.c

Index: test/Driver/stack-protector.c
===
--- test/Driver/stack-protector.c
+++ test/Driver/stack-protector.c
@@ -23,3 +23,12 @@
 // RUN: %clang -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=SSP-ALL
 // SSP-ALL: "-stack-protector" "3"
 // SSP-ALL-NOT: "-stack-protector-buffer-size" 
+
+// RUN: %clang -target x86_64-scei-ps4 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4
+// RUN: %clang -target x86_64-scei-ps4 -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4
+// SSP-PS4: "-stack-protector" "2"
+// SSP-PS4-NOT: "-stack-protector-buffer-size"
+
+// RUN: %clang -target x86_64-scei-ps4 -fstack-protector --param ssp-buffer-size=16 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4-BUF
+// SSP-PS4-BUF: "-stack-protector" "2"
+// SSP-PS4-BUF: "-stack-protector-buffer-size" "16"
Index: test/Driver/rtti-options.cpp
===
--- test/Driver/rtti-options.cpp
+++ test/Driver/rtti-options.cpp
@@ -34,7 +34,8 @@
 // RUN: %clang -x c++ -### -c -target x86_64-unknown-unknown -fexceptions %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 
 // -frtti + exceptions
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
+// ps4 needs -nostdinc due to having warnings if the SDK is not installed
+// RUN: %clang -### -c -nostdinc -target x86_64-scei-ps4 -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 
 // -f{no-,}rtti/default
Index: test/Driver/ps4-sdk-root.c
===
--- /dev/null
+++ test/Driver/ps4-sdk-root.c
@@ -0,0 +1,48 @@
+// REQUIRES: x86-registered-target
+
+// Check that ps4-clang doesn't report a warning message when locating
+// system header files (either by looking at the value of SCE_PS4_SDK_DIR
+// or relative to the location of the compiler driver), if "-nostdinc",
+// "--sysroot" or "-isysroot" option is specified on the command line.
+// Otherwise, check that ps4-clang reports a warning.
+
+// Check that clang doesn't report a warning message when locating
+// system libraries (either by looking at the value of SCE_PS4_SDK_DIR
+// or relative to the location of the compiler driver), if "-c", "-S", "-E",
+// "--sysroot", "-nostdlib" or "-nodefaultlibs" option is specified on
+// the command line.
+// Otherwise, check that ps4-clang reports a warning.
+
+// setting up SCE_PS4_SDK_DIR to existing location, which is not a PS4 SDK.
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -### -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s
+
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -### -c -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -### -S -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -### -E -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -### -emit-ast -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -### -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s
+
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -### -c -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -### -S -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -### -E -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -### -emit-ast -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+
+//

Re: [PATCH] D11757: Propagate SourceLocations through to get a Loc on float_cast_overflow

2015-08-10 Thread Filipe Cabecinhas via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL244568: Propagate SourceLocations through to get a Loc on 
float_cast_overflow (authored by filcab).

Changed prior to commit:
  http://reviews.llvm.org/D11757?vs=31429&id=31765#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11757

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprComplex.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/catch-undef-behavior.c

Index: cfe/trunk/test/CodeGen/catch-undef-behavior.c
===
--- cfe/trunk/test/CodeGen/catch-undef-behavior.c
+++ cfe/trunk/test/CodeGen/catch-undef-behavior.c
@@ -19,6 +19,17 @@
 // CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i64 4, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[LINE_1000:.*]] = {{.*}}, i32 1000, i32 10 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[FP16:.*]] = private unnamed_addr constant { i16, i16, [9 x i8] } { i16 1, i16 16, [9 x i8] c"'__fp16'\00" }
+// CHECK-UBSAN: @[[LINE_1100:.*]] = {{.*}}, i32 1100, i32 8 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[LINE_1200:.*]] = {{.*}}, i32 1200, i32 10 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[LINE_1300:.*]] = {{.*}}, i32 1300, i32 10 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[LINE_1400:.*]] = {{.*}}, i32 1400, i32 10 {{.*}} @{{.*}} }
+// Make sure we check the fp16 type_mismatch data so we can easily match the signed char float_cast_overflow
+// CHECK-UBSAN: @[[LINE_1500:.*]] = {{.*}}, i32 1500, i32 10 {{.*}} @[[FP16]], {{.*}} }
+// CHECK-UBSAN: @[[SCHAR:.*]] = private unnamed_addr constant { i16, i16, [14 x i8] } { i16 0, i16 7, [14 x i8] c"'signed char'\00" }
+// CHECK-UBSAN: @[[LINE_1500:.*]] = {{.*}}, i32 1500, i32 10 {{.*}} @[[FP16]], {{.*}} }
+// CHECK-UBSAN: @[[LINE_1600:.*]] = {{.*}}, i32 1600, i32 10 {{.*}} @{{.*}} }
 
 // CHECK-NULL: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}}
 
@@ -209,10 +220,11 @@
   // CHECK-COMMON: %[[INBOUNDS:.*]] = icmp ule i128 %{{.*}}, -20282409603651670423947251286016
   // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1000]] to i8*),
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1000
   return n;
 }
 
@@ -223,10 +235,11 @@
   // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
   // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1100]] to i8*),
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1100
   *p = n;
 }
 
@@ -239,10 +252,11 @@
 
   // CHECK-UBSAN: %[[CAST:.*]] = bitcast float %[[F]] to i32
   // CHECK-UBSAN: %[[ARG:.*]] = zext i32 %[[CAST]] to i64
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow({{.*}}, i64 %[[ARG]]
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1200]] to i8*), i64 %[[ARG]]
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1200
   return f;
 }
 
@@ -257,10 +271,11 @@
 
   // CHECK-UBSAN: store x86_fp80 %[[F]], x86_fp80* %[[ALLOCA:.*]], !nosanitize
   // CHECK-UBSAN: %[[ARG:.*]] = ptrtoint x86_fp80* %[[ALLOCA]] to i64
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow({{.*}}, i64 %[[ARG]]
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1300]] to i8*), i64 %[[ARG]]
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1300
   return ld;
 }
 
@@ -271,10 +286,11 @@
   // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
   // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1400]] to i8*),
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1400
   return f;
 }
 
@@ -285,10 +301,11 @@
   // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
   // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1500]] to i8*),
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1500
   return *p;
 }
 
@@ -301,10 +318

r244568 - Propagate SourceLocations through to get a Loc on float_cast_overflow

2015-08-10 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Mon Aug 10 23:19:28 2015
New Revision: 244568

URL: http://llvm.org/viewvc/llvm-project?rev=244568&view=rev
Log:
Propagate SourceLocations through to get a Loc on float_cast_overflow

Summary:
float_cast_overflow is the only UBSan check without a source location attached.
This patch propagates SourceLocations where necessary to get them to the
EmitCheck() call.

Reviewers: rsmith, ABataev, rjmccall

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11757

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/catch-undef-behavior.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=244568&r1=244567&r2=244568&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Aug 10 23:19:28 2015
@@ -96,10 +96,12 @@ llvm::Value *CodeGenFunction::EvaluateEx
   }
 
   QualType BoolTy = getContext().BoolTy;
+  SourceLocation Loc = E->getExprLoc();
   if (!E->getType()->isAnyComplexType())
-return EmitScalarConversion(EmitScalarExpr(E), E->getType(), BoolTy);
+return EmitScalarConversion(EmitScalarExpr(E), E->getType(), BoolTy, Loc);
 
-  return EmitComplexToScalarConversion(EmitComplexExpr(E), 
E->getType(),BoolTy);
+  return EmitComplexToScalarConversion(EmitComplexExpr(E), E->getType(), 
BoolTy,
+   Loc);
 }
 
 /// EmitIgnoredExpr - Emit code to compute the specified expression,

Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=244568&r1=244567&r2=244568&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Mon Aug 10 23:19:28 2015
@@ -85,10 +85,10 @@ public:
 
   /// Emit a cast from complex value Val to DestType.
   ComplexPairTy EmitComplexToComplexCast(ComplexPairTy Val, QualType SrcType,
- QualType DestType);
+ QualType DestType, SourceLocation 
Loc);
   /// Emit a cast from scalar value Val to DestType.
   ComplexPairTy EmitScalarToComplexCast(llvm::Value *Val, QualType SrcType,
-QualType DestType);
+QualType DestType, SourceLocation Loc);
 
   
//======//
   //Visitor Methods
@@ -394,7 +394,8 @@ ComplexPairTy ComplexExprEmitter::VisitS
 /// Emit a cast from complex value Val to DestType.
 ComplexPairTy ComplexExprEmitter::EmitComplexToComplexCast(ComplexPairTy Val,
QualType SrcType,
-   QualType DestType) {
+   QualType DestType,
+   SourceLocation Loc) 
{
   // Get the src/dest element type.
   SrcType = SrcType->castAs()->getElementType();
   DestType = DestType->castAs()->getElementType();
@@ -402,17 +403,18 @@ ComplexPairTy ComplexExprEmitter::EmitCo
   // C99 6.3.1.6: When a value of complex type is converted to another
   // complex type, both the real and imaginary parts follow the conversion
   // rules for the corresponding real types.
-  Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType);
-  Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType);
+  Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType, Loc);
+  Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType, Loc);
   return Val;
 }
 
 ComplexPairTy ComplexExprEmitter::EmitScalarToComplexCast(llvm::Value *Val,
   QualType SrcType,
-  QualType DestType) {
+  QualType DestType,
+  SourceLocation Loc) {
   // Convert the input element to the element type of the complex.
   DestType = DestType->castAs()->getElementType();
-  Val = CGF.EmitScalarConversion(Val, SrcType, DestType);
+  Val = CGF.EmitScalarConversion(Val, SrcType, DestType, Loc);
 
   // Return (realval, 0).
   return ComplexPairTy(Val, llvm::Constant::getNullValue(Val->getType()));
@@ -488,14 +490,15 @@ ComplexPairTy ComplexExprEmitter::EmitCa
 
   case CK_FloatingRealToComplex:
   case CK_IntegralRealToCompl

Re: [PATCH] D12215: [UBSan] Add the ability to print more precise error kind in summary line.

2015-08-20 Thread Filipe Cabecinhas via cfe-commits
filcab added a subscriber: filcab.
filcab added a comment.

Looks good.



Comment at: lib/ubsan/ubsan_flags.inc:26
@@ +25,2 @@
+UBSAN_FLAG(bool, report_error_type, false,
+"Print specific error type instead of 'undefined-behavior' in 
summary.")

Do we care that much about keeping the "always say 'undefined-behavior'" 
behavior around?


http://reviews.llvm.org/D12215



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12181: [sanitizer] Add -fsanitize-trap-function.

2015-08-20 Thread Filipe Cabecinhas via cfe-commits
filcab added a subscriber: filcab.
filcab added a comment.

Looks good, thanks for working on this.
I added some code style comments.



Comment at: lib/CodeGen/CGExpr.cpp:2399
@@ -2385,1 +2398,3 @@
+
+void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked, const std::string 
&TrapFuncName) {
   llvm::BasicBlock *Cont = createBasicBlock("cont");

80 columns


Comment at: lib/CodeGen/CGExpr.cpp:2408
@@ -2392,3 +2407,3 @@
 EmitBlock(TrapBB);
-llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap);
+llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap, 
TrapFuncName);
 TrapCall->setDoesNotReturn();

80 columns.


Comment at: lib/CodeGen/CGExpr.cpp:2419
@@ -2403,3 +2418,3 @@
 
-llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID) {
+llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID, 
const std::string &TrapFuncName) {
   llvm::CallInst *TrapCall = Builder.CreateCall(CGM.getIntrinsic(IntrID));

80 columns.


Comment at: lib/CodeGen/CGExpr.cpp:2425
@@ -2409,3 +2424,3 @@
"trap-func-name",
-   CGM.getCodeGenOpts().TrapFuncName);
+   TrapFuncName);
 

Please run clang-format on lines you change.


Comment at: lib/CodeGen/CodeGenFunction.h:2887
@@ -2886,2 +2886,3 @@
 
   /// \brief Create a basic block that will call the trap intrinsic, and emit a
+  /// conditional branch to it, for the -fsanitize checks.

Don't add `\brief` if the comment is just one sentence (if you want to remove 
ones that were there previously, don't do it in the same commit, though).
I would probably remove the first comma, too.


Comment at: lib/CodeGen/CodeGenFunction.h:2904
@@ +2903,3 @@
+
+  /// \brief Emit a call to trap or debugtrap and attach function attribute
+  /// "trap-func-name" if nonempty.

Again, don't add `\brief`.


Comment at: lib/Frontend/CompilerInvocation.cpp:684
@@ -683,2 +683,3 @@
   Opts.SanitizeTrap);
+  Opts.SanitizeTrapFuncName = 
Args.getLastArgValue(OPT_fsanitize_trap_function_EQ);
 

clang-format here.


http://reviews.llvm.org/D12181



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12181: [sanitizer] Add -fsanitize-trap-function.

2015-08-20 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

It seems you missed some `\brief`. Other than that, no complaints on this side.



Comment at: lib/CodeGen/CGExpr.cpp:2303
@@ -2302,4 +2302,3 @@
 
-  if (TrapCond)
-EmitTrapCheck(TrapCond);
+  if (TrapCond) EmitSanitizeTrapCheck(TrapCond);
   if (!FatalCond && !RecoverableCond)

Did clang-format do this?


Comment at: lib/CodeGen/CodeGenFunction.h:2900
@@ +2899,3 @@
+ private:
+  /// \brief Create a basic block that will call the specified trap function,
+  /// and emit a conditional branch to it.

There's still a `\brief` here.


Comment at: lib/CodeGen/CodeGenFunction.h:2904
@@ +2903,3 @@
+
+  /// \brief Emit a call to trap or debugtrap and attach function attribute
+  /// "trap-func-name" if nonempty.

I still see `\brief`.


http://reviews.llvm.org/D12181



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-08-24 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 33030.
filcab marked an inline comment as done.
filcab added a comment.

Addressed Eric's comment.


http://reviews.llvm.org/D11737

Files:
  include/clang/Driver/Options.td
  test/Driver/fuse-ld.c

Index: test/Driver/fuse-ld.c
===
--- test/Driver/fuse-ld.c
+++ test/Driver/fuse-ld.c
@@ -24,6 +24,20 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
+// -linker= is an alias to fuse-ld. Don't need to retry all combinations
+// RUN: %clang %s -### -linker gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// CHECK-FREEBSD-LINKER-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
+
+// RUN: %clang %s -### -linker=gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// CHECK-FREEBSD-LINKEREQ-GOLD: 
Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
 
 
 // RUN: %clang %s -### \
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,7 +1849,8 @@
 
 def fprofile_dir : Joined<["-"], "fprofile-dir=">, 
Group;
 
-def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group;
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker ">, 
Group;
+def linker_EQ : Joined<["-"], "linker=">, Alias, 
MetaVarName<"">;
 
 defm align_functions : BooleanFFlag<"align-functions">, 
Group;
 def falign_functions_EQ : Joined<["-"], "falign-functions=">, 
Group;


Index: test/Driver/fuse-ld.c
===
--- test/Driver/fuse-ld.c
+++ test/Driver/fuse-ld.c
@@ -24,6 +24,20 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
+// -linker= is an alias to fuse-ld. Don't need to retry all combinations
+// RUN: %clang %s -### -linker gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// CHECK-FREEBSD-LINKER-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
+
+// RUN: %clang %s -### -linker=gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// CHECK-FREEBSD-LINKEREQ-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
 
 
 // RUN: %clang %s -### \
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,7 +1849,8 @@
 
 def fprofile_dir : Joined<["-"], "fprofile-dir=">, Group;
 
-def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group;
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker ">, Group;
+def linker_EQ : Joined<["-"], "linker=">, Alias, MetaVarName<"">;
 
 defm align_functions : BooleanFFlag<"align-functions">, Group;
 def falign_functions_EQ : Joined<["-"], "falign-functions=">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-08-25 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 33085.
filcab marked 3 inline comments as done.
filcab added a comment.

Addressed comments.


http://reviews.llvm.org/D11737

Files:
  include/clang/Driver/Options.td
  test/Driver/fuse-ld.c

Index: test/Driver/fuse-ld.c
===
--- test/Driver/fuse-ld.c
+++ test/Driver/fuse-ld.c
@@ -24,6 +24,13 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
+// -linker= is an alias to fuse-ld. Don't need to retry all combinations
+// RUN: %clang %s -### -linker=gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-LINKEREQ-GOLD
+// CHECK-FREEBSD-LINKEREQ-GOLD: 
Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
 
 
 // RUN: %clang %s -### \
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,7 +1849,8 @@
 
 def fprofile_dir : Joined<["-"], "fprofile-dir=">, 
Group;
 
-def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group;
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker ">, 
Group;
+def linker_EQ : Joined<["-"], "linker=">, Alias, 
MetaVarName<"">;
 
 defm align_functions : BooleanFFlag<"align-functions">, 
Group;
 def falign_functions_EQ : Joined<["-"], "falign-functions=">, 
Group;


Index: test/Driver/fuse-ld.c
===
--- test/Driver/fuse-ld.c
+++ test/Driver/fuse-ld.c
@@ -24,6 +24,13 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
+// -linker= is an alias to fuse-ld. Don't need to retry all combinations
+// RUN: %clang %s -### -linker=gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-LINKEREQ-GOLD
+// CHECK-FREEBSD-LINKEREQ-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
 
 
 // RUN: %clang %s -### \
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,7 +1849,8 @@
 
 def fprofile_dir : Joined<["-"], "fprofile-dir=">, Group;
 
-def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group;
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker ">, Group;
+def linker_EQ : Joined<["-"], "linker=">, Alias, MetaVarName<"">;
 
 defm align_functions : BooleanFFlag<"align-functions">, Group;
 def falign_functions_EQ : Joined<["-"], "falign-functions=">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-08-25 Thread Filipe Cabecinhas via cfe-commits
Hi Richard,

We wouldn't be able to link with libs matching "libinker=*.{dylib,so,...}",
I guess. If that is a big problem and you'd prefer that we keep this as a
private patch, let me know.

Thank you,

  Filipe

On Mon, Aug 24, 2015 at 6:45 PM, Richard Smith 
wrote:

> On Mon, Aug 24, 2015 at 5:50 PM, Eric Christopher via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> echristo added inline comments.
>>
>> 
>> Comment at: include/clang/Driver/Options.td:1853
>> @@ -1853,1 +1852,3 @@
>> +def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker
>> ">, Group;
>> +def linker_EQ : Joined<["-"], "linker=">, Alias,
>> MetaVarName<"">;
>>
>> 
>> thakis wrote:
>> > Any reason to have another alias for this at all? Does gcc understand
>> this spelling? If not, could you limit this flag to PS4 targets? (I'm
>> guessing you need it for PS4 targets for some reason.)
>> Any reason? (And I'm not sure how to limit it btw on target).
>
>
> -l already has a meaning; adding a different flag starting with -l is a
> bad idea.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-08-25 Thread Filipe Cabecinhas via cfe-commits
Hi Richard,

On Tue, Aug 25, 2015 at 11:01 AM, Richard Smith 
wrote:

> On Aug 25, 2015 10:26 AM, "Filipe Cabecinhas" <
> filcab+llvm.phabrica...@gmail.com> wrote:
> >
> > Hi Richard,
> >
> > We wouldn't be able to link with libs matching
> "libinker=*.{dylib,so,...}", I guess. If that is a big problem and you'd
> prefer that we keep this as a private patch, let me know.
>
> I don't think it's a big problem, more just a "try to pick better flag
> names in future" comment :) It sounds like you guys have existing systems
> that depend on this name, so while I'm not really overjoyed about this,
> accepting it for compatibility seems OK.
>
Thanks.

> Can we produce an accompanying "deprecated" warning suggesting use of the
> other name?
>
Not on our side. If you still want the warning, I'd prefer to just keep the
flag private than to have the option+warning upstream (basically just for
PS4 toolchain use) and have a private patch to remove the warning anyway.

Let me know what you think,

  Filipe

> Thank you,
> >
> >   Filipe
> >
> >
> > On Mon, Aug 24, 2015 at 6:45 PM, Richard Smith 
> wrote:
> >>
> >> On Mon, Aug 24, 2015 at 5:50 PM, Eric Christopher via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>>
> >>> echristo added inline comments.
> >>>
> >>> 
> >>> Comment at: include/clang/Driver/Options.td:1853
> >>> @@ -1853,1 +1852,3 @@
> >>> +def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker
> ">, Group;
> >>> +def linker_EQ : Joined<["-"], "linker=">, Alias,
> MetaVarName<"">;
> >>>
> >>> 
> >>> thakis wrote:
> >>> > Any reason to have another alias for this at all? Does gcc
> understand this spelling? If not, could you limit this flag to PS4 targets?
> (I'm guessing you need it for PS4 targets for some reason.)
> >>> Any reason? (And I'm not sure how to limit it btw on target).
> >>
> >>
> >> -l already has a meaning; adding a different flag starting with -l is a
> bad idea.
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13482: Revised Initial patch for PS4 toolchain

2015-10-08 Thread Filipe Cabecinhas via cfe-commits
filcab accepted this revision.
filcab added a comment.
This revision is now accepted and ready to land.

LGTM. But let's wait for a !Sony dev to say something too.


Repository:
  rL LLVM

http://reviews.llvm.org/D13482



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r250293 - Bring back r250262: PS4 toolchain

2015-10-14 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Wed Oct 14 07:25:43 2015
New Revision: 250293

URL: http://llvm.org/viewvc/llvm-project?rev=250293&view=rev
Log:
Bring back r250262: PS4 toolchain

There was a minor problem with a test. Sorry for the noise yesterday.

This patch adds missing pieces to clang, including the PS4 toolchain
definition, added warnings, PS4 defaults, and Driver changes needed for
our compiler.

A patch by Filipe Cabecinhas, Pierre Gousseau and Katya Romanova!

Differential Revision: http://reviews.llvm.org/D13482

Added:
cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include/.keep
cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include_common/.keep
cfe/trunk/test/Driver/no-integrated-as.s
cfe/trunk/test/Driver/ps4-header-search.c
cfe/trunk/test/Driver/ps4-linker-non-win.c
cfe/trunk/test/Driver/ps4-linker-win.c
cfe/trunk/test/Driver/ps4-pic.c
cfe/trunk/test/Driver/ps4-sdk-root.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/test/Driver/debug-options.c
cfe/trunk/test/Driver/stack-protector.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=250293&r1=250292&r2=250293&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Oct 14 07:25:43 
2015
@@ -196,4 +196,18 @@ def warn_target_unsupported_nan2008 : Wa
 def warn_target_unsupported_nanlegacy : Warning<
   "ignoring '-mnan=legacy' option because the '%0' architecture does not 
support it">,
   InGroup;
+
+def warn_drv_unable_to_find_directory_expected : Warning<
+  "unable to find %0 directory, expected to be in '%1'">,
+  InGroup, DefaultIgnore;
+
+def warn_drv_ps4_force_pic : Warning<
+  "option '%0' was ignored by the PS4 toolchain, using '-fPIC'">,
+  InGroup;
+
+def warn_drv_ps4_sdk_dir : Warning<
+  "environment variable SCE_PS4_SDK_DIR is set, but points to invalid or 
nonexistent directory '%0'">,
+  InGroup;
+
+def err_drv_unsupported_linker : Error<"unsupported value '%0' for -linker 
option">;
 }

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=250293&r1=250292&r2=250293&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Oct 14 07:25:43 2015
@@ -823,3 +823,7 @@ def CudaCompat : DiagGroup<"cuda-compat"
 
 // A warning group for things that will change semantics in the future.
 def FutureCompat : DiagGroup<"future-compat">;
+
+def InvalidOrNonExistentDirectory : 
DiagGroup<"invalid-or-nonexistent-directory">;
+
+def OptionIgnored : DiagGroup<"option-ignored">;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=250293&r1=250292&r2=250293&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Oct 14 07:25:43 2015
@@ -2261,6 +2261,9 @@ const ToolChain &Driver::getToolChain(co
 case llvm::Triple::CUDA:
   TC = new toolchains::CudaToolChain(*this, Target, Args);
   break;
+case llvm::Triple::PS4:
+  TC = new toolchains::PS4CPU(*this, Target, Args);
+  break;
 default:
   // Of these targets, Hexagon is the only one that might have
   // an OS of Linux, in which case it got handled above already.

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=250293&r1=250292&r2=250293&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Oct 14 07:25:43 2015
@@ -4066,3 +4066,77 @@ void WebAssembly::addClangTargetOptions(
  options::OPT_fno_use_init_array, true))
 CC1Args.push_back("-fuse-init-array");
 }
+
+PS4CPU::PS4CPU(const Driver &D, const llvm::Triple &Triple, const ArgList 
&Args)
+: Generic_ELF(D, Triple, Args) {
+  if (Args.hasArg(options::OPT_static))
+D.Diag(diag::err_drv_unsupported_opt_for_target) << "-static" << "PS4";
+
+  // Determine where to find the PS4 libraries. We use SCE_PS4_SDK_DIR
+  // if it exists; otherwise use the driver's installation path, which
+  // should be /host_tools/bin.
+

Re: [PATCH] D13482: Revised Initial patch for PS4 toolchain

2015-10-14 Thread Filipe Cabecinhas via cfe-commits
Hi all,

I have harnessed the powers of time zones and did the last tweak we needed
to get it comitted.
It's still going through some bots, but I don't foresee big problems. The
fast bots liked it.

Thanks to everyone that reviewed it and worked on it!

  Filipe

On Wed, Oct 14, 2015 at 8:54 AM, Romanova, Katya <
katya_roman...@playstation.sony.com> wrote:

> Hi Sean,
>
>
>
> I don’t think that the whole patch should have been reverted. There were
> much easier way to make the PS4 bot green. A single test could have been
> marked as “XFAIL: ps4” for a few hours until a better solution is
> implemented. Reverting this huge patch is more drastic measure that might
> cause more problems later.
>
>
>
> As you saw in my previous email, I kept an eye on the bots, noticed the
> failure on PS4 buildbot, explained why it happened in the email and ask
> community for an opinion if it could be temporarily marked as “XFAIL” for
> ps4 only. I had to leave work at certain point. When I got home, I saw that
> you reverted the whole fix. Now I will have to go through all the pain with
> maintaining a huge commit, instead of making one line change affecting one
> of the tests on PS4 platform only… But, I guess, if it’s a general
> practice,  then it’s a different story. I was not aware of this practice
> and I thought that the other solution was much more reasonable.
>
>
>
> Thank you for letting me know about 
> LLVM_DEFAULT_TARGET_TRIPLE=x86_64-scei-ps4.
> I will definitely run it before the next commit.
>
>
>
> Katya.
>
>
>
>
>
> *From:* Sean Silva [mailto:chisophu...@gmail.com]
> *Sent:* Tuesday, October 13, 2015 11:56 PM
> *To:* Eric Christopher
> *Cc:* reviews+d13482+public+a1a9627af638c...@reviews.llvm.org; Romanova,
> Katya; Alex Rosenberg; Robinson, Paul; filcab+llvm.phabrica...@gmail.com;
> Jonathan Roelofs; Bedwell, Greg; pierregoussea...@gmail.com; Anton
> Korobeynikov; Takumi NAKAMURA; cfe-commits
> *Subject:* Re: [PATCH] D13482: Revised Initial patch for PS4 toolchain
>
>
>
>
>
>
>
> On Tue, Oct 13, 2015 at 11:40 PM, Eric Christopher 
> wrote:
>
>
>
> On Tue, Oct 13, 2015 at 11:38 PM Sean Silva  wrote:
>
> On Tue, Oct 13, 2015 at 11:33 PM, Eric Christopher 
> wrote:
>
> It was already reverted, but I agree, let's get this fixed first.
>
>
>
> It was reintroduced in r250252. It is breaking
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/1362
>
>
>
>
>
> Ah, I missed that. Yeah, please go ahead and revert for now.
>
>
>
> reverted in r250273
>
> (bot is back to green:
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/1363
> )
>
>
>
> Katya - remember to run the tests
> with LLVM_DEFAULT_TARGET_TRIPLE=x86_64-scei-ps4 (and also remember to keep
> an eye on the bots after committing)
>
>
>
> -- Sean Silva
>
>
>
>
>
> Thanks!
>
>
>
> -eric
>
>
>
> -- Sean Silva
>
>
>
>
>
> Thanks!
>
>
>
> -eric
>
>
>
> On Tue, Oct 13, 2015 at 11:33 PM Sean Silva  wrote:
>
> On Tue, Oct 13, 2015 at 7:51 PM, Katya Romanova <
> katya_roman...@playstation.sony.com> wrote:
>
> kromanova added a comment.
>
> Hi,
>
> The initial PS4 patch caused a test failure (debug-options.c) on the PS4
> bot. I suspect that I know why the problem happens, but I'm not sure what
> will be the best way to handle it. If someone knows how to fix this test
> more "elegantly", I would appreciate their advice.
>
> FAIL: Clang :: Driver/debug-options.c (3509 of 24708)
>
> - TEST 'Clang :: Driver/debug-options.c' FAILED 
>
> Script:
> ---
>
> /home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/./bin/clang
> -### -c -g
> /home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.src/tools/clang/test/Driver/debug-options.c
> -target x86_64-linux-gnu 2>&1  |
> /home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/./bin/FileCheck
> -check-prefix=G /home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-
> 
>
> /home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/./bin/clang
> -### -g
> /home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.src/tools/clang/test/Driver/debug-options.c
> 2>&1 |
> /home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/./bin/FileCheck
> -check-prefix=CI
> /home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.src/tools/clang/test/Driver/debug-options.c
>
> 
>
> Exit Code: 1
>
> Command Outp

r250298 - Tweak a -g related test for the PS4

2015-10-14 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Wed Oct 14 09:45:36 2015
New Revision: 250298

URL: http://llvm.org/viewvc/llvm-project?rev=250298&view=rev
Log:
Tweak a -g related test for the PS4

Make sure we're matching what we want:
 - Always have -generate-arange-section (independent of -g)
 - Emit a -dwarf-version=... when -g is there.

Modified:
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=250298&r1=250297&r2=250298&view=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Wed Oct 14 09:45:36 2015
@@ -30,7 +30,7 @@
 // On the PS4, -g defaults to -gno-column-info, and we always generate the
 // arange section.
 // RUN: %clang -### -c %s -target x86_64-scei-ps4 2>&1 \
-// RUN: | FileCheck -check-prefix=G_PS4 %s
+// RUN: | FileCheck -check-prefix=NOG_PS4 %s
 // RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
 // RUN: | FileCheck -check-prefix=G_PS4 %s
 // RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
@@ -98,7 +98,13 @@
 // G_DARWIN: "-cc1"
 // G_DARWIN: "-dwarf-version=2"
 //
+// NOG_PS4: "-cc1"
+// NOG_PS4-NOT "-dwarf-version=
+// NOG_PS4: "-generate-arange-section"
+// NOG_PS4-NOT: "-dwarf-version=
+//
 // G_PS4: "-cc1"
+// G_PS4: "-dwarf-version=
 // G_PS4: "-generate-arange-section"
 //
 // G_D2: "-cc1"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13482: Revised Initial patch for PS4 toolchain

2015-10-15 Thread Filipe Cabecinhas via cfe-commits
Hi Katya,

On Thu, Oct 15, 2015 at 2:01 AM, Romanova, Katya <
katya_roman...@playstation.sony.com> wrote:

> Filipe,
>
> I have one question regarding the change in debug-option.c that you made
> to get the builds green again… (r250294).
>
>
>
> Basically you changed the generic run line that used to test the drivers
> for every single platform
>
> // RUN: %clang -### -g %s 2>&1 | FileCheck -check-prefix=CI %s
>
>
>
> into the run line that tests x86_64 drivers only.
>
> // RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \
>
> // | FileCheck -check-prefix=CI %s
>
>
>
> By making this change, we reduced driver coverage for the other platforms,
> e.g. AMD.  This run line will continue to pass for AMD irrespective of
> whether the AMD driver enabled or disabled emitting column information by
> default. I suspect that **non**-x86_64 developers won't be happy that we
> reduced their drivers’ test coverage without letting them know.
>

>
> Is there a better way to address this issue?
>

As far as I can tell, only the PS4 differs from the default in column info:
  // PS4 defaults to no column info
  if (Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info,
   /*Default=*/ !IsPS4CPU))
CmdArgs.push_back("-dwarf-column-info");

There are practically no other mentions of "column.?info" (case-insensitive
regex) in the clang driver. And almost no other mentions in clang, except
for actually emitting if the setting is on.

I think the platform that deviates from the default should add their tests,
but also make the tests that assumed everyone had the same default still
pass. This will force us to hard-code a triple, since we can't test every
other triple we can use in clang. I ended up using x86_64, because it was
already used in the file anyway. And I tend to use "unknown-unknown" for
vendor and OS, since those should get us to the "default" handling,
whatever that is.

>From what I understand, it’s impossible now to execute a specific RUN line
> for all the platforms, except platform . However, it’s easy to do it
> for the whole file (XFAIL: ). Does anyone know how hard it would be to
> expand lit functionality to do XFAIL:  for a block of RUN lines in a
> file (e.g. XFAIL : begin:  …. XFAIL : end : ? Or, even a simpler
> approach: force XFAIL to take effect only for the RUN lines that follow
> XFAIL line. It will definitely add much more power/flexibility to FAIL
> functionality in lit. It might also reduce test code duplication. What do
> you think?
>
Most tests are very generic and have to do with what clang supports
"everywhere". The driver has some special cases, especially due to the
default triple, but I'm not sure it's a problem big enough to warrant doing
all that work. I would be ok with it, but don't see a huge benefit coming
out of there.

But for now (for our specific problem)  maybe it’s better to remove the run
> lines that work differently for PS4 and for the rest of the world from
> debug_options.c  file and place them into a ps4 specific file (e.g.
> ps4-Gcolumn-info.c) and into non-ps4 generic file (e.g gcolumn-info.c) and
> make gcolumn-info.c to XFAIL for PS4. We could do this extraction for
> gcolumn_info, debug_aranges, and anything else that is different for PS4
> and everyone else,
>
Splitting the file and adding complementary XFAILs would bring up
additional problems and maintenance burden.

We would have to copy over all of the tests from debug_options.c that we
still want to do on the PS4 (at the very least all the generic ones).
Whenever something changed, people would have to change both files in the
same way.

And since we're the only ones that diverge from the "default" and we're
testing the default and our special case, I don't think there is a problem
with the test.

 Filipe

Katya.
>
>
>
>
>
> *From:* fil...@gmail.com [mailto:fil...@gmail.com] *On Behalf Of *Filipe
> Cabecinhas
> *Sent:* Wednesday, October 14, 2015 6:11 AM
> *To:* Romanova, Katya
> *Cc:* Sean Silva; Eric Christopher;
> reviews+d13482+public+a1a9627af638c...@reviews.llvm.org; Alex Rosenberg;
> Robinson, Paul; Jonathan Roelofs; Bedwell, Greg;
> pierregoussea...@gmail.com; Anton Korobeynikov; Takumi NAKAMURA;
> cfe-commits
>
> *Subject:* Re: [PATCH] D13482: Revised Initial patch for PS4 toolchain
>
>
>
> Hi all,
>
>
>
> I have harnessed the powers of time zones and did the last tweak we needed
> to get it comitted.
>
> It's still going through some bots, but I don't foresee big problems. The
> fast bots liked it.
>
>
>
> Thanks to everyone that reviewed it and worked on it!
>
>
>
>   Filipe
>
>
>
> On Wed, Oct 14, 2015 at 8:54 AM, Romanova, Katya <
> katya_roman...@playstation.sony.com> wrote:
>
> Hi Sean,
>
>
>
> I don’t think that the whole patch should have been reverted. There were
> much easier way to make the PS4 bot green. A single test could have been
> marked as “XFAIL: ps4” for a few hours until a better solution is
> implemented. Reverting this huge p

r250516 - [PS4] Add missing tests for -fsanitize=...

2015-10-16 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Fri Oct 16 10:08:01 2015
New Revision: 250516

URL: http://llvm.org/viewvc/llvm-project?rev=250516&view=rev
Log:
[PS4] Add missing tests for -fsanitize=...

Modified:
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=250516&r1=250515&r2=250516&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Fri Oct 16 10:08:01 2015
@@ -292,3 +292,16 @@
 // RUN: %clang -target powerpc64-unknown-linux-gnu -fsanitize=memory %s -### 
2>&1 | FileCheck %s -check-prefix=CHECK-SANM
 // RUN: %clang -target powerpc64le-unknown-linux-gnu -fsanitize=memory %s -### 
2>&1 | FileCheck %s -check-prefix=CHECK-SANM
 // CHECK-SANM: "-fsanitize=memory"
+
+// RUN: %clang -target x86_64-scei-ps4 -fsanitize=function 
-fsanitize=undefined %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-FSAN-UBSAN-PS4
+// CHECK-FSAN-UBSAN-PS4: unsupported option '-fsanitize=function' for target 
'x86_64-scei-ps4'
+// RUN: %clang -target x86_64-scei-ps4 -fsanitize=function %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FSAN-PS4
+// CHECK-FSAN-PS4: unsupported option '-fsanitize=function' for target 
'x86_64-scei-ps4'
+// RUN: %clang -target x86_64-scei-ps4 -fsanitize=dataflow %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-DFSAN-PS4
+// CHECK-DFSAN-PS4: unsupported option '-fsanitize=dataflow' for target 
'x86_64-scei-ps4'
+// RUN: %clang -target x86_64-scei-ps4 -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-LSAN-PS4
+// CHECK-LSAN-PS4: unsupported option '-fsanitize=leak' for target 
'x86_64-scei-ps4'
+// RUN: %clang -target x86_64-scei-ps4 -fsanitize=memory %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-MSAN-PS4
+// CHECK-MSAN-PS4: unsupported option '-fsanitize=memory' for target 
'x86_64-scei-ps4'
+// RUN: %clang -target x86_64-scei-ps4 -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-PS4
+// CHECK-TSAN-PS4: unsupported option '-fsanitize=thread' for target 
'x86_64-scei-ps4'

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=250516&r1=250515&r2=250516&view=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Fri Oct 16 10:08:01 2015
@@ -334,3 +334,24 @@
 //
 // CHECK-SAFESTACK-ANDROID-AARCH64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-SAFESTACK-ANDROID-AARCH64-NOT: libclang_rt.safestack
+
+// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-scei-ps4 \
+// RUN: -shared \
+// RUN:   | FileCheck --check-prefix=CHECK-UBSAN-PS4 %s
+// CHECK-UBSAN-PS4: "{{.*}}ld{{(.exe)?}}"
+// CHECK-UBSAN-PS4: -lSceDbgUBSanitizer_stub_weak
+
+// RUN: %clang -fsanitize=address %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-scei-ps4 \
+// RUN: -shared \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-PS4 %s
+// CHECK-ASAN-PS4: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak
+
+// RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-scei-ps4 \
+// RUN: -shared \
+// RUN:   | FileCheck --check-prefix=CHECK-AUBSAN-PS4 %s
+// CHECK-AUBSAN-PS4: "{{.*}}ld{{(.exe)?}}"
+// CHECK-AUBSAN-PS4: -lSceDbgAddressSanitizer_stub_weak


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r250514 - PS4: Make sure to add the sanitizer runtime before any linker input

2015-10-16 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Fri Oct 16 10:07:48 2015
New Revision: 250514

URL: http://llvm.org/viewvc/llvm-project?rev=250514&view=rev
Log:
PS4: Make sure to add the sanitizer runtime before any linker input

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=250514&r1=250513&r2=250514&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 16 10:07:48 2015
@@ -10017,6 +10017,8 @@ static void ConstructPS4LinkJob(const To
 assert(Output.isNothing() && "Invalid output.");
   }
 
+  AddPS4SanitizerArgs(ToolChain, CmdArgs);
+
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
   Args.AddAllArgs(CmdArgs, options::OPT_e);
@@ -10034,7 +10036,6 @@ static void ConstructPS4LinkJob(const To
   }
 
   AddPS4ProfileRT(ToolChain, Args, CmdArgs);
-  AddPS4SanitizerArgs(ToolChain, CmdArgs);
 
   const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("ps4-ld"));
 
@@ -10087,6 +10088,8 @@ static void ConstructGoldLinkJob(const T
 assert(Output.isNothing() && "Invalid output.");
   }
 
+  AddPS4SanitizerArgs(ToolChain, CmdArgs);
+
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nostartfiles)) {
 const char *crt1 = NULL;
@@ -10214,7 +10217,6 @@ static void ConstructGoldLinkJob(const T
   }
 
   AddPS4ProfileRT(ToolChain, Args, CmdArgs);
-  AddPS4SanitizerArgs(ToolChain, CmdArgs);
 
   const char *Exec =
 #ifdef LLVM_ON_WIN32


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r250515 - PS4: Add tests for rtti/vptr-sanitizer interaction

2015-10-16 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Fri Oct 16 10:07:56 2015
New Revision: 250515

URL: http://llvm.org/viewvc/llvm-project?rev=250515&view=rev
Log:
PS4: Add tests for rtti/vptr-sanitizer interaction

Modified:
cfe/trunk/test/Driver/rtti-options.cpp

Modified: cfe/trunk/test/Driver/rtti-options.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rtti-options.cpp?rev=250515&r1=250514&r2=250515&view=diff
==
--- cfe/trunk/test/Driver/rtti-options.cpp (original)
+++ cfe/trunk/test/Driver/rtti-options.cpp Fri Oct 16 10:07:56 2015
@@ -21,6 +21,10 @@
 // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=vptr -fno-rtti 
%s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s
 // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined %s 
2>&1 | FileCheck -check-prefix=CHECK-OK %s
 // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined 
-frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
+// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr %s 2>&1 | 
FileCheck -check-prefix=CHECK-SAN-WARN %s
+// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -frtti %s 2>&1 
| FileCheck -check-prefix=CHECK-OK %s
+// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -fno-rtti %s 
2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s
+// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=undefined -frtti %s 
2>&1 | FileCheck -check-prefix=CHECK-OK %s
 
 // Exceptions + no/default rtti
 // RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions -fno-rtti %s 
2>&1 | FileCheck -check-prefix=CHECK-EXC-ERROR-CXX %s
@@ -46,6 +50,7 @@
 // RUN: %clang -### -c -target x86_64-unknown-unknown %s 2>&1 | FileCheck 
-check-prefix=CHECK-RTTI %s
 
 // CHECK-UNUSED: warning: argument unused during compilation: 
'-fcxx-exceptions'
+// CHECK-SAN-WARN: implicitly disabling vptr sanitizer because rtti wasn't 
enabled
 // CHECK-SAN-ERROR: invalid argument '-fsanitize=vptr' not allowed with 
'-fno-rtti'
 // CHECK-EXC-WARN: implicitly enabling rtti for exception handling
 // CHECK-EXC-ERROR: invalid argument '-fno-rtti' not allowed with 
'-fexceptions'


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r250514 - PS4: Make sure to add the sanitizer runtime before any linker input

2015-10-19 Thread Filipe Cabecinhas via cfe-commits
I don't see this. Do you have a log for them?

Thank you,

  Filipe

On Fri, Oct 16, 2015 at 11:52 PM, Artem Belevich via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Filipe,
>
> FYI, this change appears to introduce a somewhat subtle problem. clang
> compiled with itself starts producing (false positive?) warnings about
> uninitialized variables. I didn't get a chance to dig deeper yet.
>
> --Artem
>
> On Fri, Oct 16, 2015 at 8:07 AM, Filipe Cabecinhas via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: filcab
>> Date: Fri Oct 16 10:07:48 2015
>> New Revision: 250514
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=250514&view=rev
>> Log:
>> PS4: Make sure to add the sanitizer runtime before any linker input
>>
>> Modified:
>> cfe/trunk/lib/Driver/Tools.cpp
>>
>> Modified: cfe/trunk/lib/Driver/Tools.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=250514&r1=250513&r2=250514&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Driver/Tools.cpp (original)
>> +++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 16 10:07:48 2015
>> @@ -10017,6 +10017,8 @@ static void ConstructPS4LinkJob(const To
>>  assert(Output.isNothing() && "Invalid output.");
>>}
>>
>> +  AddPS4SanitizerArgs(ToolChain, CmdArgs);
>> +
>>Args.AddAllArgs(CmdArgs, options::OPT_L);
>>Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
>>Args.AddAllArgs(CmdArgs, options::OPT_e);
>> @@ -10034,7 +10036,6 @@ static void ConstructPS4LinkJob(const To
>>}
>>
>>AddPS4ProfileRT(ToolChain, Args, CmdArgs);
>> -  AddPS4SanitizerArgs(ToolChain, CmdArgs);
>>
>>const char *Exec =
>> Args.MakeArgString(ToolChain.GetProgramPath("ps4-ld"));
>>
>> @@ -10087,6 +10088,8 @@ static void ConstructGoldLinkJob(const T
>>  assert(Output.isNothing() && "Invalid output.");
>>}
>>
>> +  AddPS4SanitizerArgs(ToolChain, CmdArgs);
>> +
>>if (!Args.hasArg(options::OPT_nostdlib) &&
>>!Args.hasArg(options::OPT_nostartfiles)) {
>>  const char *crt1 = NULL;
>> @@ -10214,7 +10217,6 @@ static void ConstructGoldLinkJob(const T
>>}
>>
>>AddPS4ProfileRT(ToolChain, Args, CmdArgs);
>> -  AddPS4SanitizerArgs(ToolChain, CmdArgs);
>>
>>const char *Exec =
>>  #ifdef LLVM_ON_WIN32
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
>
> --
> --Artem Belevich
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11757: Propagate SourceLocations through to get a Loc on float_cast_overflow

2015-08-05 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

Marking Richard's comment as done.


http://reviews.llvm.org/D11757



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11757: Propagate SourceLocations through to get a Loc on float_cast_overflow

2015-08-05 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 31429.
filcab added a comment.

Rebasing off of current trunk.

compiler-rt patch posted at http://reviews.llvm.org/D11793


http://reviews.llvm.org/D11757

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/catch-undef-behavior.c

Index: test/CodeGen/catch-undef-behavior.c
===
--- test/CodeGen/catch-undef-behavior.c
+++ test/CodeGen/catch-undef-behavior.c
@@ -19,6 +19,17 @@
 // CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i64 4, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[LINE_1000:.*]] = {{.*}}, i32 1000, i32 10 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[FP16:.*]] = private unnamed_addr constant { i16, i16, [9 x i8] } { i16 1, i16 16, [9 x i8] c"'__fp16'\00" }
+// CHECK-UBSAN: @[[LINE_1100:.*]] = {{.*}}, i32 1100, i32 8 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[LINE_1200:.*]] = {{.*}}, i32 1200, i32 10 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[LINE_1300:.*]] = {{.*}}, i32 1300, i32 10 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[LINE_1400:.*]] = {{.*}}, i32 1400, i32 10 {{.*}} @{{.*}} }
+// Make sure we check the fp16 type_mismatch data so we can easily match the signed char float_cast_overflow
+// CHECK-UBSAN: @[[LINE_1500:.*]] = {{.*}}, i32 1500, i32 10 {{.*}} @[[FP16]], {{.*}} }
+// CHECK-UBSAN: @[[SCHAR:.*]] = private unnamed_addr constant { i16, i16, [14 x i8] } { i16 0, i16 7, [14 x i8] c"'signed char'\00" }
+// CHECK-UBSAN: @[[LINE_1500:.*]] = {{.*}}, i32 1500, i32 10 {{.*}} @[[FP16]], {{.*}} }
+// CHECK-UBSAN: @[[LINE_1600:.*]] = {{.*}}, i32 1600, i32 10 {{.*}} @{{.*}} }
 
 // CHECK-NULL: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}}
 
@@ -209,10 +220,11 @@
   // CHECK-COMMON: %[[INBOUNDS:.*]] = icmp ule i128 %{{.*}}, -20282409603651670423947251286016
   // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1000]] to i8*),
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1000
   return n;
 }
 
@@ -223,10 +235,11 @@
   // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
   // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1100]] to i8*),
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1100
   *p = n;
 }
 
@@ -239,10 +252,11 @@
 
   // CHECK-UBSAN: %[[CAST:.*]] = bitcast float %[[F]] to i32
   // CHECK-UBSAN: %[[ARG:.*]] = zext i32 %[[CAST]] to i64
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow({{.*}}, i64 %[[ARG]]
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1200]] to i8*), i64 %[[ARG]]
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1200
   return f;
 }
 
@@ -257,10 +271,11 @@
 
   // CHECK-UBSAN: store x86_fp80 %[[F]], x86_fp80* %[[ALLOCA:.*]], !nosanitize
   // CHECK-UBSAN: %[[ARG:.*]] = ptrtoint x86_fp80* %[[ALLOCA]] to i64
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow({{.*}}, i64 %[[ARG]]
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1300]] to i8*), i64 %[[ARG]]
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1300
   return ld;
 }
 
@@ -271,10 +286,11 @@
   // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
   // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1400]] to i8*),
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1400
   return f;
 }
 
@@ -285,10 +301,11 @@
   // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
   // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(i8* bitcast ({{.*}} @[[LINE_1500]] to i8*),
 
   // CHECK-TRAP:  call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
+#line 1500
   return *p;
 }
 
@@ -301,10 +318,11 @@
   // CHECK-COMMON: %[[INBOUNDS:.*]] = xor i1 %[[OUTOFBOUNDS]], true
   // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-UBSAN: call void @__ubsan_handle_flo

r244433 - [tests] Remove calls to grep

2015-08-10 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Mon Aug 10 02:01:11 2015
New Revision: 244433

URL: http://llvm.org/viewvc/llvm-project?rev=244433&view=rev
Log:
[tests] Remove calls to grep

Modified:
cfe/trunk/test/Index/warning-flags.c

Modified: cfe/trunk/test/Index/warning-flags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/warning-flags.c?rev=244433&r1=244432&r2=244433&view=diff
==
--- cfe/trunk/test/Index/warning-flags.c (original)
+++ cfe/trunk/test/Index/warning-flags.c Mon Aug 10 02:01:11 2015
@@ -5,9 +5,9 @@ int *bar(float *f) { return f; }
 // RUN: c-index-test -test-load-source-reparse 5 all %s 2>&1|FileCheck 
-check-prefix=CHECK-BOTH-WARNINGS %s
 // RUN: c-index-test -test-load-source all -Wno-return-type  %s 2>&1|FileCheck 
-check-prefix=CHECK-SECOND-WARNING %s
 // RUN: c-index-test -test-load-source-reparse 5 all -Wno-return-type %s 
2>&1|FileCheck -check-prefix=CHECK-SECOND-WARNING %s
-// RUN: c-index-test -test-load-source all -w %s 2>&1|not grep warning:
-// RUN: c-index-test -test-load-source-reparse 5 all -w %s 2>&1|not grep 
warning:
-// RUN: c-index-test -test-load-source all -w -O4 %s 2>&1|not grep warning:
+// RUN: c-index-test -test-load-source all -w %s 2>&1 | FileCheck 
-check-prefix=NOWARNINGS %s
+// RUN: c-index-test -test-load-source-reparse 5 all -w %s 2>&1 | FileCheck 
-check-prefix=NOWARNINGS %s
+// RUN: c-index-test -test-load-source all -w -O4 %s 2>&1 | FileCheck 
-check-prefix=NOWARNINGS %s
 
 // CHECK-BOTH-WARNINGS: warning: control reaches end of non-void function
 // CHECK-BOTH-WARNINGS: warning: incompatible pointer types returning 'float 
*' from a function with result type 'int *'
@@ -15,3 +15,4 @@ int *bar(float *f) { return f; }
 // CHECK-SECOND-WARNING-NOT:control reaches end of non-void
 // CHECK-SECOND-WARNING: warning: incompatible pointer types returning 'float 
*' from a function with result type 'int *'
 
+// NOWARNINGS-NOT: warning:


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11737: Add -linker (and -linker=) alias for -fuse-ld=

2015-08-10 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 31693.
filcab added a comment.

Update to latest trunk. Ping.


http://reviews.llvm.org/D11737

Files:
  include/clang/Driver/Options.td
  test/Driver/fuse-ld.c

Index: test/Driver/fuse-ld.c
===
--- test/Driver/fuse-ld.c
+++ test/Driver/fuse-ld.c
@@ -24,6 +24,20 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
+// -linker= is an alias to fuse-ld. Don't need to retry all combinations
+// RUN: %clang %s -### -linker gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// CHECK-FREEBSD-LINKER-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
+
+// RUN: %clang %s -### -linker=gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// CHECK-FREEBSD-LINKEREQ-GOLD: 
Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
 
 
 // RUN: %clang %s -### \
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,7 +1849,9 @@
 
 def fprofile_dir : Joined<["-"], "fprofile-dir=">, 
Group;
 
-def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group;
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker ">, 
Group;
+def linker : Separate<["-"], "linker">, Alias, 
MetaVarName<"">;
+def linker_EQ : Joined<["-"], "linker=">, Alias;
 
 defm align_functions : BooleanFFlag<"align-functions">, 
Group;
 def falign_functions_EQ : Joined<["-"], "falign-functions=">, 
Group;


Index: test/Driver/fuse-ld.c
===
--- test/Driver/fuse-ld.c
+++ test/Driver/fuse-ld.c
@@ -24,6 +24,20 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
+// -linker= is an alias to fuse-ld. Don't need to retry all combinations
+// RUN: %clang %s -### -linker gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// CHECK-FREEBSD-LINKER-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
+
+// RUN: %clang %s -### -linker=gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// CHECK-FREEBSD-LINKEREQ-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
 
 
 // RUN: %clang %s -### \
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,7 +1849,9 @@
 
 def fprofile_dir : Joined<["-"], "fprofile-dir=">, Group;
 
-def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group;
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, HelpText<"Use linker ">, Group;
+def linker : Separate<["-"], "linker">, Alias, MetaVarName<"">;
+def linker_EQ : Joined<["-"], "linker=">, Alias;
 
 defm align_functions : BooleanFFlag<"align-functions">, Group;
 def falign_functions_EQ : Joined<["-"], "falign-functions=">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-19 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

Thanks a lot for working on this!

Filipe


https://reviews.llvm.org/D22463



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21695: [clang] Version support for UBSan handlers

2016-08-09 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

Ping!


https://reviews.llvm.org/D21695



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21695: [clang] Version support for UBSan handlers

2016-08-12 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

In https://reviews.llvm.org/D21695#510788, @vsk wrote:

> After reading through the discussion in https://reviews.llvm.org/D19668, I 
> don't think I understood the pros/cons of using a single ABI check (like asan 
> does) versus adding version numbers to each handler routine. With the latter 
> approach, wouldn't users only be able to link old object files with new 
> runtimes if we never delete old checks? If that's the case, and assuming that 
> we'd like to delete old checks, a single version symbol check would 
> accomplish the same thing.


With ASan it's very easy to add a single symbol for all of it, since it's a 
single pass, and when it runs, instrumentation is added. For UBSan it depends 
on it being enabled and you hitting a place where it checks for it. We can emit 
the version check symbol in emitCheckHandlerCall, though.

With split versioning, as long as the checks you enable don't get different 
versions (it's rare that we change checks, too), they'll still work (arguably 
this is not as valuable as I think it is, but things like Android frameworks 
enabling UBSan checks in production might make it more valuable).
With a single version for "UBSan", you get more problems:

- Should you rev when *adding* check handlers?
  - If so, why would I need a newer lib just because it includes a new check, 
even if I don't use that?
- You'll need to rev up, and use a newer version of the library even if the 
checks' interface (for the ones you're using) hasn't changed.



Comment at: lib/CodeGen/CGExpr.cpp:2473
@@ +2472,3 @@
+  ("__ubsan_handle_" + CheckName +
+   (CheckInfo.Version ? "_v" + std::to_string(CheckInfo.Version) : "") +
+   (NeedsAbortSuffix ? "_abort" : ""))

vsk wrote:
> Wdyt of dropping the "_vN" component if the version is 0? That's one less 
> compiler-rt change that we'd need.
That's what it's doing:
  (CheckInfo.Version ? "_v" + std::to_string(CheckInfo.Version) : "")



https://reviews.llvm.org/D21695



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23498: Left shifts of negative values are defined if -fwrapv is set

2016-08-15 Thread Filipe Cabecinhas via cfe-commits
filcab added a subscriber: filcab.


Comment at: test/CodeGen/wrapv-lshr-sanitize.c:1
@@ +1,2 @@
+// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple 
x86_64-linux-gnu -fwrapv | opt -instnamer -S | FileCheck %s
+

Do you really need `instnamer`?


Comment at: test/Sema/negative-shift-wrapv.c:9
@@ +8,3 @@
+  int i;
+  i = -1 << (WORD_BIT - 1); // no-warning
+}

It's a bit weird to have the test function be dead code, but I don't see a big 
problem anyway.

Do you need to do the whole `WORD_BIT` thing? I'd rather just shift -1 by 1 
(which is already UB in non -fwrapv world, but defined in -fwrapv world).


https://reviews.llvm.org/D23498



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-04-28 Thread Filipe Cabecinhas via cfe-commits
filcab created this revision.
filcab added a reviewer: rsmith.
filcab added a subscriber: cfe-commits.

This option allows the user to control how much of the file name is
emitted by UBSan. Tuning this option allows one to save space in the
resulting binary, which is helpful for restricted execution
environments.

With a positive N, UBSan skips the first N path components.
With a negative N, UBSan only keeps the last N path components.

http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fubsan-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fubsan-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+// We can't easily check stripping one or two levels.
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test.CodeGen.ubsan-strip-path-components\.cpp}}\00", align 1
+
+// We have an optional space in the regex in the next line because the }} eagerly closes the regex
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{([^\\/]*)?(.[^\\/]+).}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{.}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -783,6 +783,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip =
+  getLastArgIntValue(Args, OPT_fubsan_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5621,6 +5621,9 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(options::OPT_fubsan_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/

[PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-04-28 Thread Filipe Cabecinhas via cfe-commits
filcab created this revision.
filcab added reviewers: kcc, samsonov, rsmith.
filcab added a subscriber: cfe-commits.

This patch makes the type_mismatch static data 7 bytes smaller (and it ends up
being 16 bytes smaller due to alignment restrictions, at least on some x86-64
environments).

Currently, I have no binary compatibility for using an older object file
(compiled before this change) with a newer clang. Depending on the compiler-rt
code review, this patch might be updated to better signal to the library that
this object has this new binary format.

http://reviews.llvm.org/D19667

Files:
  lib/CodeGen/CGExpr.cpp

Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -575,12 +575,12 @@
   }
 
   if (Checks.size() > 0) {
+// Make sure we're not losing information. Alignment needs to be a power 
of 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
 llvm::Constant *StaticData[] = {
- EmitCheckSourceLocation(Loc),
-  EmitCheckTypeDescriptor(Ty),
-  llvm::ConstantInt::get(SizeTy, AlignVal),
-  llvm::ConstantInt::get(Int8Ty, TCK)
-};
+EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty),
+llvm::ConstantInt::get(Int8Ty, llvm::Log2_64(AlignVal)),
+llvm::ConstantInt::get(Int8Ty, TCK)};
 EmitCheck(Checks, "type_mismatch", StaticData, Ptr);
   }
 


Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -575,12 +575,12 @@
   }
 
   if (Checks.size() > 0) {
+// Make sure we're not losing information. Alignment needs to be a power of 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
 llvm::Constant *StaticData[] = {
- EmitCheckSourceLocation(Loc),
-  EmitCheckTypeDescriptor(Ty),
-  llvm::ConstantInt::get(SizeTy, AlignVal),
-  llvm::ConstantInt::get(Int8Ty, TCK)
-};
+EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty),
+llvm::ConstantInt::get(Int8Ty, llvm::Log2_64(AlignVal)),
+llvm::ConstantInt::get(Int8Ty, TCK)};
 EmitCheck(Checks, "type_mismatch", StaticData, Ptr);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-04-28 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

http://reviews.llvm.org/D19668 is the compiler-rt side of the patch.


http://reviews.llvm.org/D19667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-04-29 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 55605.
filcab marked 2 inline comments as done.
filcab added a comment.

Addressed Richard's comments.
Waiting on http://reviews.llvm.org/D19724 (operator- on Path's 
reverse_iterator) before landing this.


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+// We can't easily check stripping one or two levels.
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test.CodeGen.ubsan-strip-path-components\.cpp}}\00", align 1
+
+// We have an optional space in the regex in the next line because the }} eagerly closes the regex
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{([^\\/]*)?(.[^\\/]+).}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{.}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/San

Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-04 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56164.
filcab added a comment.

Remove unneeded comments.
Simplify code.


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test.CodeGen.ubsan-strip-path-components\.cpp}}\00", align 1
+
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{([^\\/]*)?(.[^\\/]+).}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{.}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
 
 using namespace clang;
@@ -2367,7 +2368,38 @@
 
   PresumedLoc PLoc = getContext().getSourceManager().getPresumedLoc(Loc);
   if (PLoc.isValid()) {
-auto FilenameGV = CGM.GetAddrOfConstantCString(PLoc.getFilename(), ".src");
+StringRef FilenameString = PLoc.getF

Re: [PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-05-05 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56261.
filcab added a comment.

Update catch-undef-behavior.c


http://reviews.llvm.org/D19667

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/catch-undef-behavior.c

Index: test/CodeGen/catch-undef-behavior.c
===
--- test/CodeGen/catch-undef-behavior.c
+++ test/CodeGen/catch-undef-behavior.c
@@ -6,16 +6,16 @@
 // CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x 
i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 
 // FIXME: When we only emit each type once, use [[INT]] more below.
-// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 
100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
-// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
+// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 
100, i32 5 {{.*}} @[[INT]], i8 2, i8 1
+// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i8 2, i8 0
 // CHECK-UBSAN: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, 
{{.*}} @{{.*}}
 // CHECK-UBSAN: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, 
{{.*}} @{{.*}}
-// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 
4, i8 0 }
-// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 
4, i8 1 }
+// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i8 
2, i8 0 }
+// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i8 
2, i8 1 }
 
 // CHECK-UBSAN: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, 
[11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
 
-// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} 
@[[STRUCT_S]], i64 4, i8 3 }
+// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} 
@[[STRUCT_S]], i8 2, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_1000:.*]] = {{.*}}, i32 1000, i32 10 {{.*}} @{{.*}} }
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -575,12 +575,12 @@
   }
 
   if (Checks.size() > 0) {
+// Make sure we're not losing information. Alignment needs to be a power 
of 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
 llvm::Constant *StaticData[] = {
- EmitCheckSourceLocation(Loc),
-  EmitCheckTypeDescriptor(Ty),
-  llvm::ConstantInt::get(SizeTy, AlignVal),
-  llvm::ConstantInt::get(Int8Ty, TCK)
-};
+EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty),
+llvm::ConstantInt::get(Int8Ty, llvm::Log2_64(AlignVal)),
+llvm::ConstantInt::get(Int8Ty, TCK)};
 EmitCheck(Checks, "type_mismatch", StaticData, Ptr);
   }
 


Index: test/CodeGen/catch-undef-behavior.c
===
--- test/CodeGen/catch-undef-behavior.c
+++ test/CodeGen/catch-undef-behavior.c
@@ -6,16 +6,16 @@
 // CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 
 // FIXME: When we only emit each type once, use [[INT]] more below.
-// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
-// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
+// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]], i8 2, i8 1
+// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i8 2, i8 0
 // CHECK-UBSAN: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
 // CHECK-UBSAN: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
-// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 4, i8 0 }
-// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 4, i8 1 }
+// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i8 2, i8 0 }
+// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i8 2, i8 1 }
 
 // CHECK-UBSAN: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, [11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
 
-// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i64 4, i8 3 }
+// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i8 2, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_1000:.*]] = {{.*}}, i32 1000, i32 10 {{.*}} @{{.*}} }
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -575,12

Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-05 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56262.
filcab added a comment.

Remove .data() call


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test.CodeGen.ubsan-strip-path-components\.cpp}}\00", align 1
+
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{([^\\/]*)?(.[^\\/]+).}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{.}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
 
 using namespace clang;
@@ -2367,7 +2368,36 @@
 
   PresumedLoc PLoc = getContext().getSourceManager().getPresumedLoc(Loc);
   if (PLoc.isValid()) {
-auto FilenameGV = CGM.GetAddrOfConstantCString(PLoc.getFilename(), ".src");
+StringRef FilenameString = PLoc.getFilename();
+
+int

Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-05 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

In http://reviews.llvm.org/D19666#422150, @ygribov wrote:

> Can we have generic option for other sanitizers?


Do other sanitizers emit paths this way?
For ASan, for example, we end up emitting them only when there are global 
constructors involved, where we'd emit an __asan_global.
I don't know much about msan and tsan, but I'd think it wouldn't make as much a 
difference as this does in ubsan, since ubsan basically emits checks in every 
(non-trivial) file you compile.

I'm not opposed to doing it for other sanitizers, but the better option would 
be to measure first to see if it's useful. If it is, then deprecate this flag 
and do a more generic one.
BTW, how would we pass this information along to llvm-land so the other 
sanitizers could use it? Is there a mechanism already in place?


http://reviews.llvm.org/D19666



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-05 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56289.
filcab added a comment.

Improve Windows support


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test(.|\\5C)CodeGen(.|\\5C)ubsan-strip-path-components\.cpp}}\00", align 1
+
+// First path component: "/" or "$drive_letter:", then a name, or '\5C' on Windows
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{(.:|/)([^\\/]*(/|\\5C))}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{/|\\5C}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
 
 using namespace clang;
@@ -2367,7 +2368,36 @@
 
   PresumedLoc PLoc = getContext().getSourceManager().getPresumedLoc(Loc);
   if (PLoc.isValid()) {
-auto FilenameGV = CGM.GetAddr

Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-06 Thread Filipe Cabecinhas via cfe-commits
filcab added inline comments.


Comment at: lib/CodeGen/CGExpr.cpp:2385-2386
@@ +2384,4 @@
+FilenameString = FilenameString.substr(I - E);
+  else
+FilenameString = llvm::sys::path::filename(FilenameString);
+} else if (PathComponentsToStrip > 0) {

rsmith wrote:
> This doesn't look right: if `I == E`, we were asked to keep at least as many 
> components as there were, so we should keep the entire string. I think the 
> `substr(I - E)` codepath is appropriate in either case here.
Ah, right.
My rationale was "if the number of stuff to strip (positive or negative) is 
greater than the number of path components, keep only the filename", which 
doesn't really fit with the negative case.
Will change today.


Comment at: test/CodeGen/ubsan-strip-path-components.cpp:6
@@ +5,3 @@
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - 
-fsanitize-undefined-strip-path-components=-9 | FileCheck %s 
-check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - 
-fsanitize-undefined-strip-path-components=9 | FileCheck %s 
-check-prefix=LAST-ONLY

rsmith wrote:
> I think this test is incorrect too.
Yep, test update coming.


http://reviews.llvm.org/D19666



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-06 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56396.
filcab added a comment.

Address Richard's comments.
Final Windows fixes (force a Linux target so our mangled label matches).


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=REGULAR
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test(.|\\5C)CodeGen(.|\\5C)ubsan-strip-path-components\.cpp}}\00", align 1
+
+// First path component: "/" or "$drive_letter:", then a name, or '\5C' on Windows
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{(.:|/)([^\\/]*(/|\\5C))}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{/|\\5C}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Su

r269309 - [ubsan] Add -fsanitize-undefined-strip-path-components=N

2016-05-12 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Thu May 12 11:51:36 2016
New Revision: 269309

URL: http://llvm.org/viewvc/llvm-project?rev=269309&view=rev
Log:
[ubsan] Add -fsanitize-undefined-strip-path-components=N

Summary:
This option allows the user to control how much of the file name is
emitted by UBSan. Tuning this option allows one to save space in the
resulting binary, which is helpful for restricted execution
environments.

With a positive N, UBSan skips the first N path components.
With a negative N, UBSan only keeps the last N path components.

Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19666

Added:
cfe/trunk/test/CodeGen/ubsan-strip-path-components.cpp
cfe/trunk/test/Driver/fubsan-strip-path-components.cpp
Modified:
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=269309&r1=269308&r2=269309&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu May 12 11:51:36 2016
@@ -228,6 +228,26 @@ UndefinedBehaviorSanitizer is available
 3.3. The test suite is integrated into the CMake build and can be run with
 ``check-ubsan`` command.
 
+Additional Configuration
+
+
+UndefinedBehaviorSanitizer adds static check data for each check unless it is
+in trap mode. This check data includes the full file name. The option
+``-fsanitize-undefined-strip-path-components=N`` can be used to trim this
+information. If ``N`` is positive, file information emitted by
+UndefinedBehaviorSanitizer will drop the first ``N`` components from the file
+path. If ``N`` is negative, the last ``N`` components will be kept.
+
+Example
+---
+
+For a file called ``/code/library/file.cpp``, here is what would be emitted:
+* Default (No flag, or ``-fsanitize-undefined-strip-path-components=0``): 
``/code/library/file.cpp``
+* ``-fsanitize-undefined-strip-path-components=1``: ``code/library/file.cpp``
+* ``-fsanitize-undefined-strip-path-components=2``: ``library/file.cpp``
+* ``-fsanitize-undefined-strip-path-components=-1``: ``file.cpp``
+* ``-fsanitize-undefined-strip-path-components=-2``: ``library/file.cpp``
+
 More Information
 
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=269309&r1=269308&r2=269309&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu May 12 11:51:36 2016
@@ -677,6 +677,10 @@ def fsanitize_stats : Flag<["-"], "fsani
 def fno_sanitize_stats : Flag<["-"], "fno-sanitize-stats">,
  Group, Flags<[CC1Option]>,
  HelpText<"Disable sanitizer statistics 
gathering.">;
+def fsanitize_undefined_strip_path_components_EQ : Joined<["-"], 
"fsanitize-undefined-strip-path-components=">,
+  Group, Flags<[CC1Option]>, MetaVarName<"">,
+  HelpText<"Strip (or keep only, if negative) a given number of path 
components "
+   "when emitting check metadata.">;
 def funsafe_math_optimizations : Flag<["-"], "funsafe-math-optimizations">,
   Group;
 def fno_unsafe_math_optimizations : Flag<["-"], 
"fno-unsafe-math-optimizations">,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=269309&r1=269308&r2=269309&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu May 12 11:51:36 2016
@@ -225,6 +225,10 @@ ENUM_CODEGENOPT(VecLib, VectorLibrary, 1
 /// The default TLS model to use.
 ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)
 
+/// Number of path components to strip when emitting checks. (0 == full
+/// filename)
+VALUE_CODEGENOPT(EmitCheckPathComponentsToStrip, 32, 0)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=269309&r1=269308&r2=269309&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu May 12 11:51:36 2016
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/Conve

Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-12 Thread Filipe Cabecinhas via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269309: [ubsan] Add 
-fsanitize-undefined-strip-path-components=N (authored by filcab).

Changed prior to commit:
  http://reviews.llvm.org/D19666?vs=56396&id=57063#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19666

Files:
  cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/ubsan-strip-path-components.cpp
  cfe/trunk/test/Driver/fubsan-strip-path-components.cpp

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -677,6 +677,10 @@
 def fno_sanitize_stats : Flag<["-"], "fno-sanitize-stats">,
  Group, Flags<[CC1Option]>,
  HelpText<"Disable sanitizer statistics gathering.">;
+def fsanitize_undefined_strip_path_components_EQ : Joined<["-"], "fsanitize-undefined-strip-path-components=">,
+  Group, Flags<[CC1Option]>, MetaVarName<"">,
+  HelpText<"Strip (or keep only, if negative) a given number of path components "
+   "when emitting check metadata.">;
 def funsafe_math_optimizations : Flag<["-"], "funsafe-math-optimizations">,
   Group;
 def fno_unsafe_math_optimizations : Flag<["-"], "fno-unsafe-math-optimizations">,
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -225,6 +225,10 @@
 /// The default TLS model to use.
 ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)
 
+/// Number of path components to strip when emitting checks. (0 == full
+/// filename)
+VALUE_CODEGENOPT(EmitCheckPathComponentsToStrip, 32, 0)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
Index: cfe/trunk/test/Driver/fubsan-strip-path-components.cpp
===
--- cfe/trunk/test/Driver/fubsan-strip-path-components.cpp
+++ cfe/trunk/test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: cfe/trunk/test/CodeGen/ubsan-strip-path-components.cpp
===
--- cfe/trunk/test/CodeGen/ubsan-strip-path-components.cpp
+++ cfe/trunk/test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=REGULAR
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test(.|\\5C)CodeGen(.|\\5C)ubsan-strip-path-components\.cpp}}\00", align 1
+
+// First path component: "/" or "$drive_letter:", then a name, or '\5C' on Windows
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{(.:|/)([^\\/]*(/|\\5C))}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{/|\\5C}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align

Re: r269309 - [ubsan] Add -fsanitize-undefined-strip-path-components=N

2016-05-13 Thread Filipe Cabecinhas via cfe-commits

> On 13 May 2016, at 07:03, Sean Silva  wrote:
> 
> 
> 
> On Thu, May 12, 2016 at 9:51 AM, Filipe Cabecinhas via cfe-commits 
>  wrote:
> Author: filcab
> Date: Thu May 12 11:51:36 2016
> New Revision: 269309
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=269309&view=rev
> Log:
> [ubsan] Add -fsanitize-undefined-strip-path-components=N
> 
> Summary:
> This option allows the user to control how much of the file name is
> emitted by UBSan. Tuning this option allows one to save space in the
> resulting binary, which is helpful for restricted execution
> environments.
> 
> With a positive N, UBSan skips the first N path components.
> With a negative N, UBSan only keeps the last N path components.
> 
> Reviewers: rsmith
> 
> Subscribers: cfe-commits
> 
> Differential Revision: http://reviews.llvm.org/D19666
> 
> Added:
> cfe/trunk/test/CodeGen/ubsan-strip-path-components.cpp
> cfe/trunk/test/Driver/fubsan-strip-path-components.cpp
> Modified:
> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> 
> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=269309&r1=269308&r2=269309&view=diff
> ==
> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu May 12 11:51:36 2016
> @@ -228,6 +228,26 @@ UndefinedBehaviorSanitizer is available
>  3.3. The test suite is integrated into the CMake build and can be run with
>  ``check-ubsan`` command.
> 
> +Additional Configuration
> +
> +
> +UndefinedBehaviorSanitizer adds static check data for each check unless it is
> +in trap mode. This check data includes the full file name. The option
> +``-fsanitize-undefined-strip-path-components=N`` can be used to trim this
> +information. If ``N`` is positive, file information emitted by
> +UndefinedBehaviorSanitizer will drop the first ``N`` components from the file
> +path. If ``N`` is negative, the last ``N`` components will be kept.
> +
> +Example
> +---
> +
> +For a file called ``/code/library/file.cpp``, here is what would be emitted:
> +* Default (No flag, or ``-fsanitize-undefined-strip-path-components=0``): 
> ``/code/library/file.cpp``
> +* ``-fsanitize-undefined-strip-path-components=1``: ``code/library/file.cpp``
> +* ``-fsanitize-undefined-strip-path-components=2``: ``library/file.cpp``
> +* ``-fsanitize-undefined-strip-path-components=-1``: ``file.cpp``
> +* ``-fsanitize-undefined-strip-path-components=-2``: ``library/file.cpp``
> 
> How are drive letters handled?
> 
> -- Sean Silva

Same way as Path iterator:
///   /  => /
///   /foo   => /,foo
///   foo/   => foo,.
///   /foo/bar   => /,foo,bar
///   ../=> ..,.
///   C:\foo\bar => C:,/,foo,bar

  Filipe

>  
> +
>  More Information
>  
> 
> 
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=269309&r1=269308&r2=269309&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Thu May 12 11:51:36 2016
> @@ -677,6 +677,10 @@ def fsanitize_stats : Flag<["-"], "fsani
>  def fno_sanitize_stats : Flag<["-"], "fno-sanitize-stats">,
>   Group, Flags<[CC1Option]>,
>   HelpText<"Disable sanitizer statistics 
> gathering.">;
> +def fsanitize_undefined_strip_path_components_EQ : Joined<["-"], 
> "fsanitize-undefined-strip-path-components=">,
> +  Group, Flags<[CC1Option]>, MetaVarName<"">,
> +  HelpText<"Strip (or keep only, if negative) a given number of path 
> components "
> +   "when emitting check metadata.">;
>  def funsafe_math_optimizations : Flag<["-"], "funsafe-math-optimizations">,
>Group;
>  def fno_unsafe_math_optimizations : Flag<["-"], 
> "fno-unsafe-math-optimizations">,
> 
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL: 
> http://llvm.org/viewvc/llvm-pr

Re: [PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-05-13 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

Hi Richard. Just want to double-check something. If we have no alignment value, 
for this check, can we assume 1?
It seems to me that that shouldn't be a problem, but wanted to double-check.



Comment at: lib/CodeGen/CGExpr.cpp:579
@@ -578,1 +578,3 @@
+// Make sure we're not losing information. Alignment needs to be a power 
of 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
 llvm::Constant *StaticData[] = {

Would it be acceptable to set AlignVal to 1 if it's 0?


http://reviews.llvm.org/D19667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-05-16 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 57342.
filcab added a comment.

Minor update which never sets an AlignVal to 0.


http://reviews.llvm.org/D19667

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/catch-undef-behavior.c

Index: test/CodeGen/catch-undef-behavior.c
===
--- test/CodeGen/catch-undef-behavior.c
+++ test/CodeGen/catch-undef-behavior.c
@@ -6,16 +6,16 @@
 // CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x 
i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 
 // FIXME: When we only emit each type once, use [[INT]] more below.
-// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 
100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
-// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
+// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 
100, i32 5 {{.*}} @[[INT]], i8 2, i8 1
+// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i8 2, i8 0
 // CHECK-UBSAN: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, 
{{.*}} @{{.*}}
 // CHECK-UBSAN: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, 
{{.*}} @{{.*}}
-// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 
4, i8 0 }
-// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 
4, i8 1 }
+// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i8 
2, i8 0 }
+// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i8 
2, i8 1 }
 
 // CHECK-UBSAN: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, 
[11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
 
-// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} 
@[[STRUCT_S]], i64 4, i8 3 }
+// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} 
@[[STRUCT_S]], i8 2, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_1000:.*]] = {{.*}}, i32 1000, i32 10 {{.*}} @{{.*}} }
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -583,12 +583,13 @@
   }
 
   if (Checks.size() > 0) {
+// Make sure we're not losing information. Alignment needs to be a power of
+// 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
 llvm::Constant *StaticData[] = {
- EmitCheckSourceLocation(Loc),
-  EmitCheckTypeDescriptor(Ty),
-  llvm::ConstantInt::get(SizeTy, AlignVal),
-  llvm::ConstantInt::get(Int8Ty, TCK)
-};
+EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty),
+llvm::ConstantInt::get(Int8Ty, AlignVal ? llvm::Log2_64(AlignVal) : 1),
+llvm::ConstantInt::get(Int8Ty, TCK)};
 EmitCheck(Checks, "type_mismatch", StaticData, Ptr);
   }
 


Index: test/CodeGen/catch-undef-behavior.c
===
--- test/CodeGen/catch-undef-behavior.c
+++ test/CodeGen/catch-undef-behavior.c
@@ -6,16 +6,16 @@
 // CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 
 // FIXME: When we only emit each type once, use [[INT]] more below.
-// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
-// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
+// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]], i8 2, i8 1
+// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i8 2, i8 0
 // CHECK-UBSAN: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
 // CHECK-UBSAN: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
-// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 4, i8 0 }
-// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 4, i8 1 }
+// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i8 2, i8 0 }
+// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i8 2, i8 1 }
 
 // CHECK-UBSAN: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, [11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
 
-// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i64 4, i8 3 }
+// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i8 2, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_1000:.*]] = {{.*}}, i32 1000, i32 10 {{.*}} @{{.*}} }
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.c

Re: [PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-05-16 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 57350.
filcab added a comment.

Added a version field.


http://reviews.llvm.org/D19667

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/catch-undef-behavior.c

Index: test/CodeGen/catch-undef-behavior.c
===
--- test/CodeGen/catch-undef-behavior.c
+++ test/CodeGen/catch-undef-behavior.c
@@ -6,16 +6,16 @@
 // CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x 
i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 
 // FIXME: When we only emit each type once, use [[INT]] more below.
-// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 
100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
-// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
+// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 
100, i32 5 {{.*}} @[[INT]], i8 2, i8 2, i8 1
+// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i8 2, i8 2, 
i8 0
 // CHECK-UBSAN: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, 
{{.*}} @{{.*}}
 // CHECK-UBSAN: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, 
{{.*}} @{{.*}}
-// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 
4, i8 0 }
-// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 
4, i8 1 }
+// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i8 
2, i8 2, i8 0 }
+// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i8 
2, i8 2, i8 1 }
 
 // CHECK-UBSAN: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, 
[11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
 
-// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} 
@[[STRUCT_S]], i64 4, i8 3 }
+// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} 
@[[STRUCT_S]], i8 2, i8 2, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_1000:.*]] = {{.*}}, i32 1000, i32 10 {{.*}} @{{.*}} }
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -583,12 +583,15 @@
   }
 
   if (Checks.size() > 0) {
+// Make sure we're not losing information. Alignment needs to be a power of
+// 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
+const unsigned TypeMismatchDataVersion = 2;
 llvm::Constant *StaticData[] = {
- EmitCheckSourceLocation(Loc),
-  EmitCheckTypeDescriptor(Ty),
-  llvm::ConstantInt::get(SizeTy, AlignVal),
-  llvm::ConstantInt::get(Int8Ty, TCK)
-};
+EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty),
+llvm::ConstantInt::get(Int8Ty, TypeMismatchDataVersion),
+llvm::ConstantInt::get(Int8Ty, AlignVal ? llvm::Log2_64(AlignVal) : 1),
+llvm::ConstantInt::get(Int8Ty, TCK)};
 EmitCheck(Checks, "type_mismatch", StaticData, Ptr);
   }
 


Index: test/CodeGen/catch-undef-behavior.c
===
--- test/CodeGen/catch-undef-behavior.c
+++ test/CodeGen/catch-undef-behavior.c
@@ -6,16 +6,16 @@
 // CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 
 // FIXME: When we only emit each type once, use [[INT]] more below.
-// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
-// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
+// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]], i8 2, i8 2, i8 1
+// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i8 2, i8 2, i8 0
 // CHECK-UBSAN: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
 // CHECK-UBSAN: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
-// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 4, i8 0 }
-// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 4, i8 1 }
+// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i8 2, i8 2, i8 0 }
+// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i8 2, i8 2, i8 1 }
 
 // CHECK-UBSAN: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, [11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
 
-// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i64 4, i8 3 }
+// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i8 2, i8 2, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_1000:.*]] = {{.*}}, i32 1

r269765 - Revert "[X86] Add immediate range checks for many of the builtins."

2016-05-17 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue May 17 09:07:43 2016
New Revision: 269765

URL: http://llvm.org/viewvc/llvm-project?rev=269765&view=rev
Log:
Revert "[X86] Add immediate range checks for many of the builtins."

This reverts commit r269619.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=269765&r1=269764&r2=269765&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue May 17 09:07:43 2016
@@ -1323,52 +1323,23 @@ bool Sema::CheckX86BuiltinFunctionCall(u
 return SemaBuiltinCpuSupports(*this, TheCall);
   case X86::BI__builtin_ms_va_start:
 return SemaBuiltinMSVAStart(TheCall);
-  case X86::BI__builtin_ia32_extractf64x4_mask:
-  case X86::BI__builtin_ia32_extracti64x4_mask:
-  case X86::BI__builtin_ia32_extractf32x8_mask:
-  case X86::BI__builtin_ia32_extracti32x8_mask:
-  case X86::BI__builtin_ia32_extractf64x2_256_mask:
-  case X86::BI__builtin_ia32_extracti64x2_256_mask:
-  case X86::BI__builtin_ia32_extractf32x4_256_mask:
-  case X86::BI__builtin_ia32_extracti32x4_256_mask:
-i = 1; l = 0; u = 1;
-break;
   case X86::BI_mm_prefetch:
-  case X86::BI__builtin_ia32_extractf32x4_mask:
-  case X86::BI__builtin_ia32_extracti32x4_mask:
-  case X86::BI__builtin_ia32_vpermilpd_mask:
-  case X86::BI__builtin_ia32_vpermilps_mask:
-  case X86::BI__builtin_ia32_extractf64x2_512_mask:
-  case X86::BI__builtin_ia32_extracti64x2_512_mask:
-i = 1; l = 0; u = 3;
-break;
-  case X86::BI__builtin_ia32_insertf32x8_mask:
-  case X86::BI__builtin_ia32_inserti32x8_mask:
-  case X86::BI__builtin_ia32_insertf64x4_mask:
-  case X86::BI__builtin_ia32_inserti64x4_mask:
-  case X86::BI__builtin_ia32_insertf64x2_256_mask:
-  case X86::BI__builtin_ia32_inserti64x2_256_mask:
-  case X86::BI__builtin_ia32_insertf32x4_256_mask:
-  case X86::BI__builtin_ia32_inserti32x4_256_mask:
-i = 2; l = 0; u = 1;
+i = 1;
+l = 0;
+u = 3;
 break;
   case X86::BI__builtin_ia32_sha1rnds4:
-  case X86::BI__builtin_ia32_shuf_f32x4_256_mask:
-  case X86::BI__builtin_ia32_shuf_f64x2_256_mask:
-  case X86::BI__builtin_ia32_shuf_i32x4_256_mask:
-  case X86::BI__builtin_ia32_shuf_i64x2_256_mask:
-  case X86::BI__builtin_ia32_shufpd128_mask:
-  case X86::BI__builtin_ia32_insertf64x2_512_mask:
-  case X86::BI__builtin_ia32_inserti64x2_512_mask:
-  case X86::BI__builtin_ia32_insertf32x4_mask:
-  case X86::BI__builtin_ia32_inserti32x4_mask:
-i = 2; l = 0; u = 3;
+i = 2;
+l = 0;
+u = 3;
 break;
   case X86::BI__builtin_ia32_vpermil2pd:
   case X86::BI__builtin_ia32_vpermil2pd256:
   case X86::BI__builtin_ia32_vpermil2ps:
   case X86::BI__builtin_ia32_vpermil2ps256:
-i = 3; l = 0; u = 3;
+i = 3;
+l = 0;
+u = 3;
 break;
   case X86::BI__builtin_ia32_cmpb128_mask:
   case X86::BI__builtin_ia32_cmpw128_mask:
@@ -1394,36 +1365,23 @@ bool Sema::CheckX86BuiltinFunctionCall(u
   case X86::BI__builtin_ia32_ucmpw512_mask:
   case X86::BI__builtin_ia32_ucmpd512_mask:
   case X86::BI__builtin_ia32_ucmpq512_mask:
-  case X86::BI__builtin_ia32_vpcomub:
-  case X86::BI__builtin_ia32_vpcomuw:
-  case X86::BI__builtin_ia32_vpcomud:
-  case X86::BI__builtin_ia32_vpcomuq:
-  case X86::BI__builtin_ia32_vpcomb:
-  case X86::BI__builtin_ia32_vpcomw:
-  case X86::BI__builtin_ia32_vpcomd:
-  case X86::BI__builtin_ia32_vpcomq:
-i = 2; l = 0; u = 7;
+i = 2;
+l = 0;
+u = 7;
 break;
   case X86::BI__builtin_ia32_roundps:
   case X86::BI__builtin_ia32_roundpd:
   case X86::BI__builtin_ia32_roundps256:
   case X86::BI__builtin_ia32_roundpd256:
-  case X86::BI__builtin_ia32_vpermilpd256_mask:
-  case X86::BI__builtin_ia32_vpermilps256_mask:
-i = 1; l = 0; u = 15;
+i = 1;
+l = 0;
+u = 15;
 break;
   case X86::BI__builtin_ia32_roundss:
   case X86::BI__builtin_ia32_roundsd:
-  case X86::BI__builtin_ia32_rangepd128_mask:
-  case X86::BI__builtin_ia32_rangepd256_mask:
-  case X86::BI__builtin_ia32_rangepd512_mask:
-  case X86::BI__builtin_ia32_rangeps128_mask:
-  case X86::BI__builtin_ia32_rangeps256_mask:
-  case X86::BI__builtin_ia32_rangeps512_mask:
-  case X86::BI__builtin_ia32_getmantsd_round_mask:
-  case X86::BI__builtin_ia32_getmantss_round_mask:
-  case X86::BI__builtin_ia32_shufpd256_mask:
-i = 2; l = 0; u = 15;
+i = 2;
+l = 0;
+u = 15;
 break;
   case X86::BI__builtin_ia32_cmpps:
   case X86::BI__builtin_ia32_cmpss:
@@ -1431,183 +1389,23 @@ bool Sema::CheckX86BuiltinFunctionCall(u
   case X86::BI__builtin_ia32_cmpsd:
   case X86::BI__builtin_ia32_cmpps256:
   case X86::BI__builtin_ia32_cmppd256:
-  case X86::BI__builtin_ia32_cmpps128_mask:
-  case X86::BI__builtin_ia32_cmppd128_mask:
-  case X86::BI__builtin_ia32_cmpps256_mask:
-  case X86::BI__builtin_ia32_

Re: r269765 - Revert "[X86] Add immediate range checks for many of the builtins."

2016-05-18 Thread Filipe Cabecinhas via cfe-commits
Indeed, my bad on two counts (I'm usually one of the people
complaining about commits like this, *and* I didn't notice the other
email was not sent to the list, so there was no record here).
Thanks Craig, for replying.

 Filipe

On Tue, May 17, 2016 at 11:09 PM, Sean Silva via cfe-commits
 wrote:
>
>
> On Tue, May 17, 2016 at 7:07 AM, Filipe Cabecinhas via cfe-commits
>  wrote:
>>
>> Author: filcab
>> Date: Tue May 17 09:07:43 2016
>> New Revision: 269765
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=269765&view=rev
>> Log:
>> Revert "[X86] Add immediate range checks for many of the builtins."
>>
>> This reverts commit r269619.
>
>
> In the future could you include the reason too?
>
> -- Sean Silva
>
>>
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/CodeGen/avx512vl-builtins.c
>>
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=269765&r1=269764&r2=269765&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue May 17 09:07:43 2016
>> @@ -1323,52 +1323,23 @@ bool Sema::CheckX86BuiltinFunctionCall(u
>>  return SemaBuiltinCpuSupports(*this, TheCall);
>>case X86::BI__builtin_ms_va_start:
>>  return SemaBuiltinMSVAStart(TheCall);
>> -  case X86::BI__builtin_ia32_extractf64x4_mask:
>> -  case X86::BI__builtin_ia32_extracti64x4_mask:
>> -  case X86::BI__builtin_ia32_extractf32x8_mask:
>> -  case X86::BI__builtin_ia32_extracti32x8_mask:
>> -  case X86::BI__builtin_ia32_extractf64x2_256_mask:
>> -  case X86::BI__builtin_ia32_extracti64x2_256_mask:
>> -  case X86::BI__builtin_ia32_extractf32x4_256_mask:
>> -  case X86::BI__builtin_ia32_extracti32x4_256_mask:
>> -i = 1; l = 0; u = 1;
>> -break;
>>case X86::BI_mm_prefetch:
>> -  case X86::BI__builtin_ia32_extractf32x4_mask:
>> -  case X86::BI__builtin_ia32_extracti32x4_mask:
>> -  case X86::BI__builtin_ia32_vpermilpd_mask:
>> -  case X86::BI__builtin_ia32_vpermilps_mask:
>> -  case X86::BI__builtin_ia32_extractf64x2_512_mask:
>> -  case X86::BI__builtin_ia32_extracti64x2_512_mask:
>> -i = 1; l = 0; u = 3;
>> -break;
>> -  case X86::BI__builtin_ia32_insertf32x8_mask:
>> -  case X86::BI__builtin_ia32_inserti32x8_mask:
>> -  case X86::BI__builtin_ia32_insertf64x4_mask:
>> -  case X86::BI__builtin_ia32_inserti64x4_mask:
>> -  case X86::BI__builtin_ia32_insertf64x2_256_mask:
>> -  case X86::BI__builtin_ia32_inserti64x2_256_mask:
>> -  case X86::BI__builtin_ia32_insertf32x4_256_mask:
>> -  case X86::BI__builtin_ia32_inserti32x4_256_mask:
>> -i = 2; l = 0; u = 1;
>> +i = 1;
>> +l = 0;
>> +u = 3;
>>  break;
>>case X86::BI__builtin_ia32_sha1rnds4:
>> -  case X86::BI__builtin_ia32_shuf_f32x4_256_mask:
>> -  case X86::BI__builtin_ia32_shuf_f64x2_256_mask:
>> -  case X86::BI__builtin_ia32_shuf_i32x4_256_mask:
>> -  case X86::BI__builtin_ia32_shuf_i64x2_256_mask:
>> -  case X86::BI__builtin_ia32_shufpd128_mask:
>> -  case X86::BI__builtin_ia32_insertf64x2_512_mask:
>> -  case X86::BI__builtin_ia32_inserti64x2_512_mask:
>> -  case X86::BI__builtin_ia32_insertf32x4_mask:
>> -  case X86::BI__builtin_ia32_inserti32x4_mask:
>> -i = 2; l = 0; u = 3;
>> +i = 2;
>> +l = 0;
>> +u = 3;
>>  break;
>>case X86::BI__builtin_ia32_vpermil2pd:
>>case X86::BI__builtin_ia32_vpermil2pd256:
>>case X86::BI__builtin_ia32_vpermil2ps:
>>case X86::BI__builtin_ia32_vpermil2ps256:
>> -i = 3; l = 0; u = 3;
>> +i = 3;
>> +l = 0;
>> +u = 3;
>>  break;
>>case X86::BI__builtin_ia32_cmpb128_mask:
>>case X86::BI__builtin_ia32_cmpw128_mask:
>> @@ -1394,36 +1365,23 @@ bool Sema::CheckX86BuiltinFunctionCall(u
>>case X86::BI__builtin_ia32_ucmpw512_mask:
>>case X86::BI__builtin_ia32_ucmpd512_mask:
>>case X86::BI__builtin_ia32_ucmpq512_mask:
>> -  case X86::BI__builtin_ia32_vpcomub:
>> -  case X86::BI__builtin_ia32_vpcomuw:
>> -  case X86::BI__builtin_ia32_vpcomud:
>> -  case X86::BI__builtin_ia32_vpcomuq:
>> -  case X86::BI__builtin_ia32_vpcomb:
>> -  case X86::BI__builtin_ia32_vpcomw:
>> -  case X86::BI__builtin_ia32_vpcomd:
>> -  case X86::BI__builtin_ia32_vpcomq:
>>

[PATCH] D18654: In C++11 it is undefined to shift into the sign bit

2016-03-31 Thread Filipe Cabecinhas via cfe-commits
filcab created this revision.
filcab added reviewers: rsmith, samsonov.
filcab added a subscriber: cfe-commits.

Clang was using C++14 rules for shifts into the sign bit with any C++
standard. Now it has the C++ <14 special case (same as C).

Using this C++11 standard draft as reference (before CWG 1457):
https://github.com/cplusplus/draft/blob/672675e01528fba6ca02f5340eee747566ebdca8/papers/N3376.pdf

http://reviews.llvm.org/D18654

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/cxx-signed-shift-overflow.cpp
  test/CodeGenCXX/catch-undef-behavior.cpp

Index: test/CodeGenCXX/catch-undef-behavior.cpp
===
--- test/CodeGenCXX/catch-undef-behavior.cpp
+++ test/CodeGenCXX/catch-undef-behavior.cpp
@@ -137,11 +137,7 @@
   // CHECK-NEXT: %[[SHIFTED_OUT_WIDTH:.*]] = sub nuw nsw i32 31, %[[RHS]]
   // CHECK-NEXT: %[[SHIFTED_OUT:.*]] = lshr i32 %[[LHS:.*]], 
%[[SHIFTED_OUT_WIDTH]]
 
-  // This is present for C++11 but not for C: C++ core issue 1457 allows a '1'
-  // to be shifted into the sign bit, but not out of it.
-  // CHECK-NEXT: %[[SHIFTED_OUT_NOT_SIGN:.*]] = lshr i32 %[[SHIFTED_OUT]], 1
-
-  // CHECK-NEXT: %[[NO_OVERFLOW:.*]] = icmp eq i32 %[[SHIFTED_OUT_NOT_SIGN]], 0
+  // CHECK-NEXT: %[[NO_OVERFLOW:.*]] = icmp eq i32 %[[SHIFTED_OUT]], 0
   // CHECK-NEXT: br label %[[CONT_BB]]
 
   // CHECK:  [[CONT_BB]]:
Index: test/CodeGen/cxx-signed-shift-overflow.cpp
===
--- /dev/null
+++ test/CodeGen/cxx-signed-shift-overflow.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 
-fsanitize=shift-base %s -emit-llvm -o - | FileCheck %s -check-prefix=CXX11 
-check-prefix=BOTH
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-apple-darwin10 
-fsanitize=shift-base %s -emit-llvm -o - | FileCheck %s -check-prefix=CXX14 
-check-prefix=BOTH
+
+int shiftoverflow(int b, int e) {
+  // BOTH-LABEL: shiftoverflow
+  // CXX14-LABEL: check:
+  // CXX14: %shl.check = lshr
+  // CXX14: lshr i{{[^ ]*}} %shl.check, 1
+  // CXX11-LABEL: check:
+  // CXX11: %shl.check = lshr
+  // CXX11-NOT: lshr i{{[^ ]*}} %shl.check, 1
+  return b << e;
+}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2746,11 +2746,12 @@
Builder.CreateSub(WidthMinusOne, RHS, "shl.zeros",
  /*NUW*/true, /*NSW*/true),
"shl.check");
-  if (CGF.getLangOpts().CPlusPlus) {
-// In C99, we are not permitted to shift a 1 bit into the sign bit.
-// Under C++11's rules, shifting a 1 bit into the sign bit is
-// OK, but shifting a 1 bit out of it is not. (C89 and C++03 don't
-// define signed left shifts, so we use the C99 and C++11 rules there).
+  if (CGF.getLangOpts().CPlusPlus && CGF.getLangOpts().CPlusPlus14) {
+// In C99 and C++11, we are not permitted to shift a 1 bit into the 
sign
+// bit.
+// Under C++14's rules, shifting a 1 bit into the sign bit is OK, but
+// shifting a 1 bit out of it is not. (C89 and C++03 don't define 
signed
+// left shifts, so we use the C99 and C++11 rules there).
 llvm::Value *One = llvm::ConstantInt::get(BitsShiftedOff->getType(), 
1);
 BitsShiftedOff = Builder.CreateLShr(BitsShiftedOff, One);
   }


Index: test/CodeGenCXX/catch-undef-behavior.cpp
===
--- test/CodeGenCXX/catch-undef-behavior.cpp
+++ test/CodeGenCXX/catch-undef-behavior.cpp
@@ -137,11 +137,7 @@
   // CHECK-NEXT: %[[SHIFTED_OUT_WIDTH:.*]] = sub nuw nsw i32 31, %[[RHS]]
   // CHECK-NEXT: %[[SHIFTED_OUT:.*]] = lshr i32 %[[LHS:.*]], %[[SHIFTED_OUT_WIDTH]]
 
-  // This is present for C++11 but not for C: C++ core issue 1457 allows a '1'
-  // to be shifted into the sign bit, but not out of it.
-  // CHECK-NEXT: %[[SHIFTED_OUT_NOT_SIGN:.*]] = lshr i32 %[[SHIFTED_OUT]], 1
-
-  // CHECK-NEXT: %[[NO_OVERFLOW:.*]] = icmp eq i32 %[[SHIFTED_OUT_NOT_SIGN]], 0
+  // CHECK-NEXT: %[[NO_OVERFLOW:.*]] = icmp eq i32 %[[SHIFTED_OUT]], 0
   // CHECK-NEXT: br label %[[CONT_BB]]
 
   // CHECK:  [[CONT_BB]]:
Index: test/CodeGen/cxx-signed-shift-overflow.cpp
===
--- /dev/null
+++ test/CodeGen/cxx-signed-shift-overflow.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -fsanitize=shift-base %s -emit-llvm -o - | FileCheck %s -check-prefix=CXX11 -check-prefix=BOTH
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-apple-darwin10 -fsanitize=shift-base %s -emit-llvm -o - | FileCheck %s -check-prefix=CXX14 -check-prefix=BOTH
+
+int shiftoverflow(int b, int e) {
+  // BOTH-LABEL: shiftoverflow
+  // CXX14-LABEL: check:
+  // CXX14: %shl.check = lshr
+  // CXX14: lshr i{{[^ ]*}

Re: [PATCH] D18654: In C++11 it is undefined to shift into the sign bit

2016-03-31 Thread Filipe Cabecinhas via cfe-commits
filcab added a subscriber: filcab.
filcab added a comment.

That means that our C++11 mode will have some fixes, right?
How can we call what out C++11 mode is? Are there updated versions of
the standard? Are there lists of defects that we have fixed and others
we haven't?

Sorry, I'm not too familiar with how the standard+fixes usually work.

Thank you,

  Filipe


http://reviews.llvm.org/D18654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18654: In C++11 it is undefined to shift into the sign bit

2016-03-31 Thread Filipe Cabecinhas via cfe-commits
That means that our C++11 mode will have some fixes, right?
How can we call what out C++11 mode is? Are there updated versions of
the standard? Are there lists of defects that we have fixed and others
we haven't?

Sorry, I'm not too familiar with how the standard+fixes usually work.

Thank you,

  Filipe


On Thu, Mar 31, 2016 at 6:59 PM, Richard Smith via cfe-commits
 wrote:
> rsmith requested changes to this revision.
> rsmith added a comment.
> This revision now requires changes to proceed.
>
> Core issue 1457 is a DR against C++11, so it applies to our C++11 mode.
>
>
> http://reviews.llvm.org/D18654
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18654: In C++11 it is undefined to shift into the sign bit

2016-03-31 Thread Filipe Cabecinhas via cfe-commits
filcab abandoned this revision.
filcab added a comment.

Thanks for clarifying, Richard.
I'll think about getting some fixes/tests in for our DRs.


http://reviews.llvm.org/D18654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19312: Warn about UB at member function calls from base class ctor initializers.

2016-04-20 Thread Filipe Cabecinhas via cfe-commits
filcab added a subscriber: filcab.
filcab added a comment.

You might want to mention that it's 12.6.2p16 in C++14/17 but p13 in C++11.
I wonder if we should have the example in the standard, verbatim. (Plus the 
added tests you made)


http://reviews.llvm.org/D19312



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19312: Warn about UB at member function calls from base class ctor initializers.

2016-04-20 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

I meant changing the diff, but if you prefer to have a smaller comment, I'm ok 
with the different "paths" in the standards being mentioned only in the commit 
message.



Comment at: lib/Sema/SemaDeclCXX.cpp:3941
@@ +3940,3 @@
+  // Calling a member function from a ctor-initializer
+  // before the base class results in undefined behavior [12.6.2 16].
+  // FIXME: We only check for member functions directly called from this

For someone reading the source code, it's probably best to mention the 
different "paths" in the standards here too.
For my usual source browsing, as long as it's in the comment *or* the commit 
message, I'll eventually see it. But it might throw some people off when they 
look at C++11, and there's no p16 in that place :-)


http://reviews.llvm.org/D19312



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19312: Warn about UB at member function calls from base class ctor initializers.

2016-04-21 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

The patch needs to get through clang-format.
Should we deal with typeid and dynamic_cast, since they're mentioned in the 
same paragraph in the standard?



Comment at: lib/Sema/SemaDeclCXX.cpp:3895
@@ +3894,3 @@
+  // Check if member call is actually to the given class.
+  if (E->getRecordDecl() == nullptr
+  || E->getRecordDecl()->getCanonicalDecl() == OnlyForClass

What's the rationale for warning if `getRecordDecl` returns `nullptr`?


Comment at: lib/Sema/SemaDeclCXX.cpp:3897
@@ +3896,3 @@
+  || E->getRecordDecl()->getCanonicalDecl() == OnlyForClass
+ || OnlyForClass->isDerivedFrom(E->getRecordDecl())) {
+FoundMemberCall = E;

Please run clang-format on the patch.


Comment at: lib/Sema/SemaDeclCXX.cpp:3941
@@ +3940,3 @@
+if (Member->isBaseInitializer()) {
+  // Calling a member function from a ctor-initializer
+  // before the base class results in undefined behavior [C++11 12.6.2 
p13].

clang-format


Comment at: lib/Sema/SemaDeclCXX.cpp:3942
@@ +3941,3 @@
+  // Calling a member function from a ctor-initializer
+  // before the base class results in undefined behavior [C++11 12.6.2 
p13].
+  // FIXME: We only check for member functions directly called from this

"before the base class is initialized"?



http://reviews.llvm.org/D19312



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21289: [ubsan] Version names of handlers

2016-06-13 Thread Filipe Cabecinhas via cfe-commits
filcab created this revision.
filcab added reviewers: kcc, samsonov, rsmith.
filcab added a subscriber: cfe-commits.

This patch introduces a simple way to bump of all the handlers in UBSan.
This way, we can easily break backwards compatibility without it being
confusing for users (a bit like the ASan
__asan_version_mismatch_check_vX symbol), since they'll get undefined
references when linking, instead of random checks providing invalid
information.

I chose to version all symbols at once (instead of just changing version
for one or two) since it avoids us needing to do lookups every time we
emit any check.

I haven't measured slowdown in a potential patch where we only rev the
checks we need, though.

This patch includes two commits: Adding an empty version string + bumping it to
_v2.

There's other alternatives of doing versions, but this one is simple,
efficient (enough), and will forcefully break with old object files (which is a
good thing). Bike-shed away anyway :-)

Before I land this diff, I want to redo D19667+D19668 on top of it. Then I can
commit them quickly so we're able to only rev up UBSan once, instead of having
an intermediary v2, and then bump to v3 immediately. If anyone would prefer a
more split up method I don't mind doing them separately, one at a time (they'll
always be different commits with both methods).

http://reviews.llvm.org/D21289

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/catch-undef-behavior.c
  test/CodeGen/cfi-check-fail.c
  test/CodeGen/cfi-check-fail2.c
  test/CodeGen/compound-assign-overflow.c
  test/CodeGen/sanitize-recover.c
  test/CodeGen/sanitize-trap.c
  test/CodeGen/ubsan-strip-path-components.cpp
  test/CodeGen/ubsan-type-blacklist.cpp
  test/CodeGen/unsigned-overflow.c
  test/CodeGen/unsigned-promotion.c
  test/CodeGenCXX/bitsets.cpp
  test/CodeGenCXX/catch-undef-behavior.cpp

Index: test/CodeGenCXX/catch-undef-behavior.cpp
===
--- test/CodeGenCXX/catch-undef-behavior.cpp
+++ test/CodeGenCXX/catch-undef-behavior.cpp
@@ -36,7 +36,7 @@
   int &r = *p;
 
   // A reference is not required to refer to an object within its lifetime.
-  // CHECK-NOT: __ubsan_handle_dynamic_type_cache_miss
+  // CHECK-NOT: __ubsan_handle_dynamic_type_cache_miss_v2
   S &r2 = *q;
 }
 
@@ -86,7 +86,7 @@
   // CHECK-NEXT: icmp eq i64 %[[CACHEVAL]], %[[HASH]]
   // CHECK-NEXT: br i1
 
-  // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss({{.*}}, i64 %{{.*}}, i64 %[[HASH]])
+  // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss_v2({{.*}}, i64 %{{.*}}, i64 %[[HASH]])
   // CHECK-NOT: unreachable
   // CHECK: {{.*}}:
 
@@ -121,7 +121,7 @@
   // [...]
   // CHECK: getelementptr inbounds [128 x i64], [128 x i64]* @__ubsan_vptr_type_cache, i32 0, i64 %
   // CHECK: br i1
-  // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss({{.*}}, i64 %{{.*}}, i64 %{{.*}})
+  // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss_v2({{.*}}, i64 %{{.*}}, i64 %{{.*}})
   // CHECK-NOT: unreachable
   // CHECK: {{.*}}:
 
@@ -149,25 +149,25 @@
   // CHECK-NEXT: %[[VALID:.*]] = and i1 %[[RHS_INBOUNDS]], %[[VALID_BASE]]
   // CHECK-NEXT: br i1 %[[VALID]]
 
-  // CHECK: call void @__ubsan_handle_shift_out_of_bounds
-  // CHECK-NOT: call void @__ubsan_handle_shift_out_of_bounds
+  // CHECK: call void @__ubsan_handle_shift_out_of_bounds_v2
+  // CHECK-NOT: call void @__ubsan_handle_shift_out_of_bounds_v2
 
   // CHECK: %[[RET:.*]] = shl i32 %[[LHS]], %[[RHS]]
   // CHECK-NEXT: ret i32 %[[RET]]
   return a << b;
 }
 
 // CHECK-LABEL: @_Z9no_return
 int no_return() {
-  // CHECK:  call void @__ubsan_handle_missing_return(i8* bitcast ({{.*}}* @{{.*}} to i8*)) [[NR_NUW:#[0-9]+]]
+  // CHECK:  call void @__ubsan_handle_missing_return_v2(i8* bitcast ({{.*}}* @{{.*}} to i8*)) [[NR_NUW:#[0-9]+]]
   // CHECK-NEXT: unreachable
 }
 
 // CHECK-LABEL: @_Z9sour_bool
 bool sour_bool(bool *p) {
   // CHECK: %[[OK:.*]] = icmp ule i8 {{.*}}, 1
   // CHECK: br i1 %[[OK]]
-  // CHECK: call void @__ubsan_handle_load_invalid_value(i8* bitcast ({{.*}}), i64 {{.*}})
+  // CHECK: call void @__ubsan_handle_load_invalid_value_v2(i8* bitcast ({{.*}}), i64 {{.*}})
   return *p;
 }
 
@@ -179,19 +179,19 @@
 int bad_enum_value() {
   // CHECK: %[[E1:.*]] = icmp ule i32 {{.*}}, 127
   // CHECK: br i1 %[[E1]]
-  // CHECK: call void @__ubsan_handle_load_invalid_value(
+  // CHECK: call void @__ubsan_handle_load_invalid_value_v2(
   int a = e1;
 
   // CHECK: %[[E2HI:.*]] = icmp sle i32 {{.*}}, 127
   // CHECK: %[[E2LO:.*]] = icmp sge i32 {{.*}}, -128
   // CHECK: %[[E2:.*]] = and i1 %[[E2HI]], %[[E2LO]]
   // CHECK: br i1 %[[E2]]
-  // CHECK: call void @__ubsan_handle_load_invalid_value(
+  // CHECK: call void @__ubsan_handle_load_invalid_value_v2(
   int b = e2;
 
   // CHECK: %[[E3:.*]] = icmp ule i32 {{.*}}, 2147483647
   // CHECK: br i1 %[[E3]]
-  // CHECK: call void @__ubsan_handle_load_invalid_value(
+  // CHECK: call void @__ubsan_handle_load

[PATCH] D21695: [clang] Version support for UBSan handlers

2016-06-24 Thread Filipe Cabecinhas via cfe-commits
filcab created this revision.
filcab added reviewers: kcc, samsonov, rsmith.
filcab added a subscriber: cfe-commits.

This adds a way for us to version any UBSan handler by itself.
The patch overrides D21289 for a better implementation (we're able to
rev up a single handler).

After this, then we can land a slight modification of D19667+D19668.

We probably don't want to keep all the versions in compiler-rt (maybe we
want to deprecate on one release and remove the old handler on the next
one?), but with this patch we will loudly fail to compile when mixing
incompatible handler calls, instead of silently compiling and then
providing bad error messages.

http://reviews.llvm.org/D21695

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -100,6 +100,32 @@
   TEK_Aggregate
 };
 
+#define LIST_SANITIZER_CHECKS  \
+  SANITIZER_CHECK(AddOverflow, add_overflow, 0)\
+  SANITIZER_CHECK(BuiltinUnreachable, builtin_unreachable, 0)  \
+  SANITIZER_CHECK(CFICheckFail, cfi_check_fail, 0) \
+  SANITIZER_CHECK(DivremOverflow, divrem_overflow, 0)  \
+  SANITIZER_CHECK(DynamicTypeCacheMiss, dynamic_type_cache_miss, 0)\
+  SANITIZER_CHECK(FloatCastOverflow, float_cast_overflow, 0)   \
+  SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 0) \
+  SANITIZER_CHECK(LoadInvalidValue, load_invalid_value, 0) \
+  SANITIZER_CHECK(MissingReturn, missing_return, 0)\
+  SANITIZER_CHECK(MulOverflow, mul_overflow, 0)\
+  SANITIZER_CHECK(NegateOverflow, negate_overflow, 0)  \
+  SANITIZER_CHECK(NonnullArg, nonnull_arg, 0)  \
+  SANITIZER_CHECK(NonnullReturn, nonnull_return, 0)\
+  SANITIZER_CHECK(OutOfBounds, out_of_bounds, 0)   \
+  SANITIZER_CHECK(ShiftOutOfBounds, shift_out_of_bounds, 0)\
+  SANITIZER_CHECK(SubOverflow, sub_overflow, 0)\
+  SANITIZER_CHECK(TypeMismatch, type_mismatch, 0)  \
+  SANITIZER_CHECK(VLABoundNotPositive, vla_bound_not_positive, 0)
+
+enum SanitizerHandler {
+#define SANITIZER_CHECK(Enum, Name, Version) Enum,
+  LIST_SANITIZER_CHECKS
+#undef SANITIZER_CHECK
+};
+
 /// CodeGenFunction - This class organizes the per-function state that is used
 /// while generating LLVM code.
 class CodeGenFunction : public CodeGenTypeCache {
@@ -3083,7 +3109,7 @@
   /// sanitizer runtime with the provided arguments, and create a conditional
   /// branch to it.
   void EmitCheck(ArrayRef> Checked,
- StringRef CheckName, ArrayRef StaticArgs,
+ SanitizerHandler Check, ArrayRef StaticArgs,
  ArrayRef DynamicArgs);
 
   /// \brief Emit a slow path cross-DSO CFI check which calls __cfi_slowpath
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1036,8 +1036,8 @@
   SanitizerScope SanScope(this);
   llvm::Value *IsFalse = Builder.getFalse();
   EmitCheck(std::make_pair(IsFalse, SanitizerKind::Return),
-"missing_return", EmitCheckSourceLocation(FD->getLocation()),
-None);
+SanitizerHandler::MissingReturn,
+EmitCheckSourceLocation(FD->getLocation()), None);
 } else if (CGM.getCodeGenOpts().OptimizationLevel == 0) {
   EmitTrapCall(llvm::Intrinsic::trap);
 }
@@ -1720,7 +1720,7 @@
 };
 EmitCheck(std::make_pair(Builder.CreateICmpSGT(Size, Zero),
  SanitizerKind::VLABound),
-  "vla_bound_not_positive", StaticArgs, Size);
+  SanitizerHandler::VLABoundNotPositive, StaticArgs, Size);
   }
 
   // Always zexting here would be wrong if it weren't
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -724,7 +724,7 @@
   CGF.EmitCheckTypeDescriptor(OrigSrcType),
   CGF.EmitCheckTypeDescriptor(DstType)};
   CGF.EmitCheck(std::make_pair(Check, SanitizerKind::FloatCastOverflow),
-"float_cast_overflow", StaticArgs, OrigSrc);
+SanitizerHandler::FloatCastOverflow, StaticArgs, Or

Re: [PATCH] D21289: [ubsan] Version names of handlers

2016-06-24 Thread Filipe Cabecinhas via cfe-commits
filcab abandoned this revision.
filcab added a comment.

Replaced by http://reviews.llvm.org/D21695


http://reviews.llvm.org/D21289



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21695: [clang] Version support for UBSan handlers

2016-07-12 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

Ping!


http://reviews.llvm.org/D21695



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-18 Thread Filipe Cabecinhas via cfe-commits
filcab added a subscriber: filcab.
filcab added a comment.

What about branches? I'm guessing we should expect the usual release branches. 
But will any person be able to create a branch? Will there be a policy, if this 
is the case? Is the policy enforceable?



Comment at: docs/Proposals/GitHub.rst:122
@@ +121,3 @@
+of understanding the *sequence* in which commits were added by using the
+``git rev-list --count hash`` or ``git describe hash`` commands.
+

How easy will it be to clone the "aggregated" repo, and then get some (but not 
all) of the submodules?


Comment at: docs/Proposals/GitHub.rst:130
@@ +129,3 @@
+* Individual projects' history will be broken (linear, but local), and we need
+  the umbrella project (using submodules) to have the same view as we had in 
SVN.
+

I wouldn't call it broken.
Won't it have the same end result as having a checkout per project and simply 
updating them close to each other?

Basically, it won't be "any more broken" than using this method for updating:

```
#!/bin/bash
for dir in llvm/{,tools/{clang,lld},projects/{libcxx,libcxxabi,compiler-rt}}; do
  # (cd $dir && svn up) # for SVN
  (cd $dir && git checkout master && git pull) # for git
done
```


https://reviews.llvm.org/D22463



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262334 - [cmake] Fallback to LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR if COMPILER_RT_SRC_ROOT doesn't exist.

2016-03-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Mar  1 08:08:13 2016
New Revision: 262334

URL: http://llvm.org/viewvc/llvm-project?rev=262334&view=rev
Log:
[cmake] Fallback to LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR if 
COMPILER_RT_SRC_ROOT doesn't exist.

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=262334&r1=262333&r2=262334&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Tue Mar  1 08:08:13 2016
@@ -23,6 +23,13 @@ function(get_ext_project_build_command o
 endfunction()
 
 set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt)
+# Fallback to the external path, if the other one isn't available.
+# This is the same behavior (try "internal", then check the LLVM_EXTERNAL_...
+# variable) as in add_llvm_external_project
+if(NOT EXISTS ${COMPILER_RT_SRC_ROOT})
+  set(COMPILER_RT_SRC_ROOT ${LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR})
+endif()
+
 if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
   if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
 set(cmake_3_4_USES_TERMINAL_OPTIONS


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262335 - [cmake] Use CMake's USES_TERMINAL for the test targets.

2016-03-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Mar  1 08:08:18 2016
New Revision: 262335

URL: http://llvm.org/viewvc/llvm-project?rev=262335&view=rev
Log:
[cmake] Use CMake's USES_TERMINAL for the test targets.

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=262335&r1=262334&r2=262335&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Tue Mar  1 08:08:18 2016
@@ -129,7 +129,9 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
 COMMAND ${run_test_suite}
 DEPENDS compiler-rt-build ${COMPILER_RT_TEST_DEPENDENCIES}
 WORKING_DIRECTORY ${BINARY_DIR}
-VERBATIM)
+VERBATIM
+${cmake_3_2_USES_TERMINAL}
+)
 endforeach()
 
 # Add special target to run all compiler-rt test suites.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262336 - [cmake] Pass through the cmake_3_2_USES_TERMINAL variable so we get progress bars on an external compiler-rt build

2016-03-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Mar  1 08:10:38 2016
New Revision: 262336

URL: http://llvm.org/viewvc/llvm-project?rev=262336&view=rev
Log:
[cmake] Pass through the cmake_3_2_USES_TERMINAL variable so we get progress 
bars on an external compiler-rt build

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=262336&r1=262335&r2=262336&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Tue Mar  1 08:10:38 2016
@@ -79,6 +79,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E

-DCOMPILER_RT_INSTALL_PATH:STRING=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
+   -Dcmake_3_2_USES_TERMINAL=${cmake_3_2_USES_TERMINAL}
${COMPILER_RT_PASSTHROUGH_VARIABLES}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262340 - [cmake] Try to appease the buildbots.

2016-03-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Mar  1 09:07:19 2016
New Revision: 262340

URL: http://llvm.org/viewvc/llvm-project?rev=262340&view=rev
Log:
[cmake] Try to appease the buildbots.

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=262340&r1=262339&r2=262340&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Tue Mar  1 09:07:19 2016
@@ -27,7 +27,10 @@ set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC
 # This is the same behavior (try "internal", then check the LLVM_EXTERNAL_...
 # variable) as in add_llvm_external_project
 if(NOT EXISTS ${COMPILER_RT_SRC_ROOT})
-  set(COMPILER_RT_SRC_ROOT ${LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR})
+  # We don't want to set it if LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR is ""
+  if(${LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR})
+set(COMPILER_RT_SRC_ROOT ${LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR})
+  endif()
 endif()
 
 if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262341 - [cmake] Add a few more compiler-rt check-* targets for EXTERNAL_COMPILER_RT

2016-03-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Mar  1 09:33:52 2016
New Revision: 262341

URL: http://llvm.org/viewvc/llvm-project?rev=262341&view=rev
Log:
[cmake] Add a few more compiler-rt check-* targets for EXTERNAL_COMPILER_RT

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=262341&r1=262340&r2=262341&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Tue Mar  1 09:33:52 2016
@@ -126,7 +126,8 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
 
 # Add top-level targets for various compiler-rt test suites.
 set(COMPILER_RT_TEST_SUITES check-asan check-asan-dynamic check-dfsan
-  check-lsan check-msan check-sanitizer check-tsan check-ubsan)
+  check-lsan check-msan check-sanitizer check-tsan check-ubsan
+  check-profile check-cfi check-cfi-and-supported check-safestack)
 foreach(test_suite ${COMPILER_RT_TEST_SUITES})
   get_ext_project_build_command(run_test_suite ${test_suite})
   add_custom_target(${test_suite}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r242121 - Add support for -fuse-ld= in the mingw toolchain driver.

2015-11-14 Thread Filipe Cabecinhas via cfe-commits
Handling of values other than lld looked weird.
Can you make it a hard error to use something other than, I guess, ld,
gold, lld?
Or are there other linkers available?

  Filipe

On Friday, 13 November 2015, Yaron Keren via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Sure, r253066.
>
>
> 2015-11-13 19:40 GMT+02:00 Rafael Espíndola  >:
>
>> This needs a testcase. Nothing is checking the linker invocation.
>>
>> On 14 July 2015 at 01:23, Yaron Keren > > wrote:
>> > Author: yrnkrn
>> > Date: Tue Jul 14 00:23:34 2015
>> > New Revision: 242121
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=242121&view=rev
>> > Log:
>> > Add support for -fuse-ld= in the mingw toolchain driver.
>> > We will still default to ld until such a time lld become a
>> > stable release. lld supports arm NT under the machine name "thumb2pe".
>> >
>> > http://reviews.llvm.org/D11088
>> >
>> > Patch by Martell Malone
>> > Reviewed by Reid Kleckner
>> >
>> >
>> > Modified:
>> > cfe/trunk/lib/Driver/Tools.cpp
>> >
>> > Modified: cfe/trunk/lib/Driver/Tools.cpp
>> > URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=242121&r1=242120&r2=242121&view=diff
>> >
>> ==
>> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
>> > +++ cfe/trunk/lib/Driver/Tools.cpp Tue Jul 14 00:23:34 2015
>> > @@ -8947,6 +8947,12 @@ void MinGW::Linker::ConstructJob(Compila
>> >// handled somewhere else.
>> >Args.ClaimAllArgs(options::OPT_w);
>> >
>> > +  StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
>> "ld");
>> > +  if (LinkerName.equals_lower("lld")) {
>> > +CmdArgs.push_back("-flavor");
>> > +CmdArgs.push_back("gnu");
>> > +  }
>> > +
>> >if (!D.SysRoot.empty())
>> >  CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
>> >
>> > @@ -8958,6 +8964,8 @@ void MinGW::Linker::ConstructJob(Compila
>> >  CmdArgs.push_back("i386pe");
>> >if (TC.getArch() == llvm::Triple::x86_64)
>> >  CmdArgs.push_back("i386pep");
>> > +  if (TC.getArch() == llvm::Triple::arm)
>> > +CmdArgs.push_back("thumb2pe");
>> >
>> >if (Args.hasArg(options::OPT_mwindows)) {
>> >  CmdArgs.push_back("--subsystem");
>> > @@ -9067,7 +9075,7 @@ void MinGW::Linker::ConstructJob(Compila
>> >
>> >if (Args.hasArg(options::OPT_static))
>> >  CmdArgs.push_back("--end-group");
>> > -  else
>> > +  else if (!LinkerName.equals_lower("lld"))
>> >  AddLibGCC(Args, CmdArgs);
>> >  }
>> >
>> > @@ -9078,7 +9086,7 @@ void MinGW::Linker::ConstructJob(Compila
>> >
>> CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
>> >  }
>> >}
>> > -  const char *Exec = Args.MakeArgString(TC.GetProgramPath("ld"));
>> > +  const char *Exec =
>> Args.MakeArgString(TC.GetProgramPath(LinkerName.data()));
>> >C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs));
>> >  }
>> >
>> >
>> >
>> > ___
>> > cfe-commits mailing list
>> > cfe-comm...@cs.uiuc.edu
>> 
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>

-- 
  F
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r254723 - [PS4] Add an additional test for ASan+UBSan

2015-12-04 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Fri Dec  4 10:18:03 2015
New Revision: 254723

URL: http://llvm.org/viewvc/llvm-project?rev=254723&view=rev
Log:
[PS4] Add an additional test for ASan+UBSan

Modified:
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=254723&r1=254722&r2=254723&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Fri Dec  4 10:18:03 2015
@@ -311,3 +311,7 @@
 // CHECK-MSAN-PS4: unsupported option '-fsanitize=memory' for target 
'x86_64-scei-ps4'
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-PS4
 // CHECK-TSAN-PS4: unsupported option '-fsanitize=thread' for target 
'x86_64-scei-ps4'
+// RUN: %clang -target x86_64-scei-ps4 -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-PS4
+// Make sure there are no *.{o,bc} or -l passed before the ASan library.
+// CHECK-ASAN-PS4-NOT: {{(\.(o|bc)"? |-l).*-lSceDbgAddressSanitizer_stub_weak}}
+// CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits