[clang] [clang] Define SwiftInfo for RISCVTargetCodeGenInfo (PR #82152)

2024-03-13 Thread Kuba Mracek via cfe-commits

https://github.com/kubamracek closed 
https://github.com/llvm/llvm-project/pull/82152
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Define SwiftInfo for RISCVTargetCodeGenInfo (PR #82152)

2024-02-26 Thread Kuba Mracek via cfe-commits

https://github.com/kubamracek updated 
https://github.com/llvm/llvm-project/pull/82152

>From 97e2f9c1c635310da19f89f44a8085c16c3feb94 Mon Sep 17 00:00:00 2001
From: Kuba Mracek 
Date: Sat, 17 Feb 2024 22:26:21 -0800
Subject: [PATCH] [clang] Define SwiftInfo for RISCVTargetCodeGenInfo

---
 clang/lib/CodeGen/Targets/RISCV.cpp | 5 -
 clang/test/CodeGenCXX/arm-swiftcall.cpp | 4 
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp 
b/clang/lib/CodeGen/Targets/RISCV.cpp
index dec6540230a60f..9a79424c4612ce 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -529,7 +529,10 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
   RISCVTargetCodeGenInfo(CodeGen::CodeGenTypes , unsigned XLen,
  unsigned FLen, bool EABI)
   : TargetCodeGenInfo(
-std::make_unique(CGT, XLen, FLen, EABI)) {}
+std::make_unique(CGT, XLen, FLen, EABI)) {
+SwiftInfo =
+std::make_unique(CGT, /*SwiftErrorInRegister=*/false);
+  }
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override {
diff --git a/clang/test/CodeGenCXX/arm-swiftcall.cpp 
b/clang/test/CodeGenCXX/arm-swiftcall.cpp
index e60c1482700a4b..45eea7bfd853b9 100644
--- a/clang/test/CodeGenCXX/arm-swiftcall.cpp
+++ b/clang/test/CodeGenCXX/arm-swiftcall.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK
 
+// For now just check that the RISC-V triples are accepted, but don't check 
the IR, as swiftcall is not yet supported.
+// RUN: %clang_cc1 -triple riscv32-unknown-linux-gnu -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++03
+// RUN: %clang_cc1 -triple riscv64-unknown-linux-gnu -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++03
+
 // This isn't really testing anything ARM-specific; it's just a convenient
 // 32-bit platform.
 

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


[clang] [clang] Define SwiftInfo for RISCVTargetCodeGenInfo (PR #82152)

2024-02-17 Thread Kuba Mracek via cfe-commits

https://github.com/kubamracek created 
https://github.com/llvm/llvm-project/pull/82152

For Embedded Swift, let's unblock building for RISC-V boards (e.g. ESP32-C6). 
This isn't trying to add full RISC-V support to Swift / Embedded Swift, it's 
just fixing the immediate blocker (not having SwiftInfo defined blocks all 
compilations).

>From b8e8c6e2531db93fb2a4cd08149c9204cb997d53 Mon Sep 17 00:00:00 2001
From: Kuba Mracek 
Date: Sat, 17 Feb 2024 22:26:21 -0800
Subject: [PATCH] [clang] Define SwiftInfo for RISCVTargetCodeGenInfo

---
 clang/lib/CodeGen/Targets/RISCV.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp 
b/clang/lib/CodeGen/Targets/RISCV.cpp
index dec6540230a60f..9a79424c4612ce 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -529,7 +529,10 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
   RISCVTargetCodeGenInfo(CodeGen::CodeGenTypes , unsigned XLen,
  unsigned FLen, bool EABI)
   : TargetCodeGenInfo(
-std::make_unique(CGT, XLen, FLen, EABI)) {}
+std::make_unique(CGT, XLen, FLen, EABI)) {
+SwiftInfo =
+std::make_unique(CGT, /*SwiftErrorInRegister=*/false);
+  }
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override {

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


[clang] Frontend: sink vendor definitions from Basic to Frontend (PR #80364)

2024-02-03 Thread Kuba Mracek via cfe-commits


@@ -804,6 +804,11 @@ static void InitializePredefinedMacros(const TargetInfo 
,
 }
   }
 
+  if (TI.getTriple().getVendor() == Triple::AMD)
+Builder.defineMacro("__AMD__");
+  if (TI.getTriple().getVendor() == Triple::Apple)
+Builder.defineMacro("__APPLE__");

kubamracek wrote:

 

https://github.com/llvm/llvm-project/pull/80364
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add __has_feature(swiftcc) that checks whether the target supports the Swift calling convention (PR #72159)

2023-11-13 Thread Kuba Mracek via cfe-commits

https://github.com/kubamracek created 
https://github.com/llvm/llvm-project/pull/72159

None

>From 09f8ba20b5f17ed65c1c0ebf8264effce7130b9a Mon Sep 17 00:00:00 2001
From: Kuba Mracek 
Date: Mon, 13 Nov 2023 13:07:49 -0800
Subject: [PATCH] [clang] Add __has_feature(swiftcc) that checks whether the
 target supports the Swift calling convention

---
 clang/include/clang/Basic/Features.def | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index da77aee8de36990..f69d52a0c24f88e 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -99,6 +99,9 @@ FEATURE(memory_sanitizer,
 FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread))
 FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow))
 FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo))
+FEATURE(swiftcc,
+  PP.getTargetInfo().checkCallingConvention(CC_Swift) ==
+  clang::TargetInfo::CCCR_OK)
 FEATURE(swiftasynccc,
   PP.getTargetInfo().checkCallingConvention(CC_SwiftAsync) ==
   clang::TargetInfo::CCCR_OK)

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


[clang] [clang] Allow __attribute__((swiftcall)) on all targets (PR #71986)

2023-11-10 Thread Kuba Mracek via cfe-commits

https://github.com/kubamracek created 
https://github.com/llvm/llvm-project/pull/71986

With Embedded Swift, , it 
becomes possible and useful to produce Swift code for a whole range of CPU 
targets. This change allows using the 'swiftcall' and 'swiftasynccall)' 
attributes on any Clang supported target. This isn't in any way adding complete 
support for those calling conventions for all targets, it's merely removing one 
obstacle from adding new targets to Swift.

>From d2df2830b4417c0ecc9690c4092053bf465a5d44 Mon Sep 17 00:00:00 2001
From: Kuba Mracek 
Date: Fri, 10 Nov 2023 13:25:13 -0800
Subject: [PATCH] [clang] Allow __attribute__((swiftcall)) on all targets

With Embedded Swift, , it
becomes possible and useful to produce Swift code for a whole range of CPU
targets. This change allows using the 'swiftcall' and 'swiftasynccall)'
attributes on any Clang supported target. This isn't in any way adding complete
support for those calling conventions for all targets, it's merely removing one
obstacle from adding new targets to Swift.
---
 clang/include/clang/Basic/TargetInfo.h | 2 ++
 clang/lib/CodeGen/ABIInfo.cpp  | 4 
 clang/lib/CodeGen/ABIInfo.h| 1 +
 clang/lib/CodeGen/TargetInfo.cpp   | 4 +++-
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 41f3c2e403cbef6..308d2ae830bf263 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1606,6 +1606,8 @@ class TargetInfo : public TransferrableTargetInfo,
   default:
 return CCCR_Warning;
   case CC_C:
+  case CC_Swift:
+  case CC_SwiftAsync:
 return CCCR_OK;
 }
   }
diff --git a/clang/lib/CodeGen/ABIInfo.cpp b/clang/lib/CodeGen/ABIInfo.cpp
index 1b56cf7c596d067..86897504b0ad267 100644
--- a/clang/lib/CodeGen/ABIInfo.cpp
+++ b/clang/lib/CodeGen/ABIInfo.cpp
@@ -33,6 +33,10 @@ const CodeGenOptions ::getCodeGenOpts() const {
   return CGT.getCodeGenOpts();
 }
 
+CodeGen::CodeGenTypes ::getCodeGenTypes() const {
+  return CGT;
+}
+
 bool ABIInfo::isAndroid() const { return getTarget().getTriple().isAndroid(); }
 
 bool ABIInfo::isOHOSFamily() const {
diff --git a/clang/lib/CodeGen/ABIInfo.h b/clang/lib/CodeGen/ABIInfo.h
index b9a5ef6e4366936..99b262bdb529684 100644
--- a/clang/lib/CodeGen/ABIInfo.h
+++ b/clang/lib/CodeGen/ABIInfo.h
@@ -60,6 +60,7 @@ class ABIInfo {
   const llvm::DataLayout () const;
   const TargetInfo () const;
   const CodeGenOptions () const;
+  CodeGen::CodeGenTypes () const;
 
   /// Return the calling convention to use for system runtime
   /// functions.
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 3d79f92137abc79..fdcf77ef9ce547c 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -67,7 +67,9 @@ LLVM_DUMP_METHOD void ABIArgInfo::dump() const {
 }
 
 TargetCodeGenInfo::TargetCodeGenInfo(std::unique_ptr Info)
-: Info(std::move(Info)) {}
+: Info(std::move(Info)),
+  SwiftInfo(std::make_unique(
+  this->Info->getCodeGenTypes(), /*SwiftErrorInRegister*/ false)) {}
 
 TargetCodeGenInfo::~TargetCodeGenInfo() = default;
 

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


[clang] 33d9c41 - [tsan] Allow TSan in the Clang driver for Apple Silicon Macs

2020-07-24 Thread Kuba Mracek via cfe-commits

Author: Kuba Mracek
Date: 2020-07-24T20:14:00-07:00
New Revision: 33d9c4109ac234bcf17501ba16880ce80622cc9c

URL: 
https://github.com/llvm/llvm-project/commit/33d9c4109ac234bcf17501ba16880ce80622cc9c
DIFF: 
https://github.com/llvm/llvm-project/commit/33d9c4109ac234bcf17501ba16880ce80622cc9c.diff

LOG: [tsan] Allow TSan in the Clang driver for Apple Silicon Macs

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index f910c88fa967..325dcb7df545 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2714,6 +2714,7 @@ void Darwin::CheckObjCARC() const {
 
 SanitizerMask Darwin::getSupportedSanitizers() const {
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
+  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::PointerCompare;
@@ -2731,9 +2732,8 @@ SanitizerMask Darwin::getSupportedSanitizers() const {
   && !(isTargetIPhoneOS() && isIPhoneOSVersionLT(5, 0)))
 Res |= SanitizerKind::Vptr;
 
-  if (isTargetMacOS()) {
-if (IsX86_64)
-  Res |= SanitizerKind::Thread;
+  if ((IsX86_64 || IsAArch64) && isTargetMacOS()) {
+Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
 if (IsX86_64)
   Res |= SanitizerKind::Thread;

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 7340bfb35e40..cfefd3fb632c 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -458,6 +458,10 @@
 
 // RUN: %clang -target x86_64-apple-darwin -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-X86-64-DARWIN
 // CHECK-TSAN-X86-64-DARWIN-NOT: unsupported option
+// RUN: %clang -target x86_64-apple-macos -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-X86-64-MACOS
+// CHECK-TSAN-X86-64-MACOS-NOT: unsupported option
+// RUN: %clang -target arm64-apple-macos -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-ARM64-MACOS
+// CHECK-TSAN-ARM64-MACOS-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-iossimulator -fsanitize=thread %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-IOSSIMULATOR
 // CHECK-TSAN-X86-64-IOSSIMULATOR-NOT: unsupported option



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


r310952 - Fixup for r310950: Also remove the new instance of %T from html-diags.c

2017-08-15 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Tue Aug 15 12:54:04 2017
New Revision: 310952

URL: http://llvm.org/viewvc/llvm-project?rev=310952=rev
Log:
Fixup for r310950: Also remove the new instance of %T from html-diags.c


Modified:
cfe/trunk/test/Analysis/html-diags.c

Modified: cfe/trunk/test/Analysis/html-diags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/html-diags.c?rev=310952=310951=310952=diff
==
--- cfe/trunk/test/Analysis/html-diags.c (original)
+++ cfe/trunk/test/Analysis/html-diags.c Tue Aug 15 12:54:04 2017
@@ -4,10 +4,10 @@
 // RUN: ls %t | grep report
 
 // D30406: Test new html-single-file output
-// RUN: rm -fR %T/dir
-// RUN: mkdir %T/dir
-// RUN: %clang_analyze_cc1 -analyzer-output=html-single-file 
-analyzer-checker=core -o %T/dir %s
-// RUN: ls %T/dir | grep report
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 -analyzer-output=html-single-file 
-analyzer-checker=core -o %t %s
+// RUN: ls %t | grep report
 
 // PR16547: Test relative paths
 // RUN: cd %t


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


r310950 - [clang] Get rid of "%T" expansions

2017-08-15 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Tue Aug 15 12:47:06 2017
New Revision: 310950

URL: http://llvm.org/viewvc/llvm-project?rev=310950=rev
Log:
[clang] Get rid of "%T" expansions

The %T lit expansion expands to a common directory shared between all the tests 
in the same directory, which is unexpected and unintuitive, and more 
importantly, it's been a source of subtle race conditions and flaky tests. In 
https://reviews.llvm.org/D35396, it was agreed that it would be best to simply 
ban %T and only keep %t, which is unique to each test. When a test needs a 
temporary directory, it can just create one using mkdir %t.

This patch removes %T in clang.

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


Modified:
cfe/trunk/test/Analysis/html-diags.c
cfe/trunk/test/CoverageMapping/abspath.cpp
cfe/trunk/test/Driver/compilation_database.c
cfe/trunk/test/Driver/cpath.c
cfe/trunk/test/Driver/darwin-ld-lto.c
cfe/trunk/test/Driver/linker-opts.c
cfe/trunk/test/Driver/output-file-cleanup.c
cfe/trunk/test/Driver/parse-progname.c
cfe/trunk/test/Driver/ps4-linker-non-win.c
cfe/trunk/test/Driver/ps4-linker-win.c
cfe/trunk/test/Driver/warning-options.cpp
cfe/trunk/test/FixIt/fixit-include.c
cfe/trunk/test/Format/style-on-command-line.cpp
cfe/trunk/test/Lexer/case-insensitive-include-ms.c
cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
cfe/trunk/test/Lexer/case-insensitive-include.c
cfe/trunk/test/Lexer/case-insensitive-system-include.c
cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
cfe/trunk/test/Modules/modules-cache-path-canonicalization.m
cfe/trunk/test/PCH/case-insensitive-include.c
cfe/trunk/test/PCH/include-timestamp.cpp
cfe/trunk/test/Preprocessor/cuda-types.cu
cfe/trunk/test/Tooling/clang-diff-basic.cpp

Modified: cfe/trunk/test/Analysis/html-diags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/html-diags.c?rev=310950=310949=310950=diff
==
--- cfe/trunk/test/Analysis/html-diags.c (original)
+++ cfe/trunk/test/Analysis/html-diags.c Tue Aug 15 12:47:06 2017
@@ -1,7 +1,7 @@
-// RUN: rm -fR %T/dir
-// RUN: mkdir %T/dir
-// RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o 
%T/dir %s
-// RUN: ls %T/dir | grep report
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o %t 
%s
+// RUN: ls %t | grep report
 
 // D30406: Test new html-single-file output
 // RUN: rm -fR %T/dir
@@ -10,9 +10,9 @@
 // RUN: ls %T/dir | grep report
 
 // PR16547: Test relative paths
-// RUN: cd %T/dir
+// RUN: cd %t
 // RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o 
testrelative %s
-// RUN: ls %T/dir/testrelative | grep report
+// RUN: ls %t/testrelative | grep report
 
 // Currently this test mainly checks that the HTML diagnostics doesn't crash
 // when handling macros will calls with macros.  We should actually validate

Modified: cfe/trunk/test/CoverageMapping/abspath.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/abspath.cpp?rev=310950=310949=310950=diff
==
--- cfe/trunk/test/CoverageMapping/abspath.cpp (original)
+++ cfe/trunk/test/CoverageMapping/abspath.cpp Tue Aug 15 12:47:06 2017
@@ -4,7 +4,7 @@
 // RMDOTS-NOT: Inputs
 // RMDOTS: "
 
-// RUN: cd %T && mkdir -p test && cd test
+// RUN: mkdir -p %t/test && cd %t/test
 // RUN: echo "void f1() {}" > f1.c
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-main-file-name abspath.cpp ../test/f1.c -o - | FileCheck -check-prefix=RELPATH 
%s
 

Modified: cfe/trunk/test/Driver/compilation_database.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/compilation_database.c?rev=310950=310949=310950=diff
==
--- cfe/trunk/test/Driver/compilation_database.c (original)
+++ cfe/trunk/test/Driver/compilation_database.c Tue Aug 15 12:47:06 2017
@@ -1,4 +1,4 @@
-// RUN: cd "%T"
+// RUN: mkdir -p %t && cd %t
 // RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 
-no-canonical-prefixes 2>&1 | FileCheck %s
 // RUN: not %clang -c -x c %s -MJ %s/non-existant -no-canonical-prefixes 2>&1 
| FileCheck --check-prefix=ERROR %s
 

Modified: cfe/trunk/test/Driver/cpath.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cpath.c?rev=310950=310949=310950=diff
==
--- cfe/trunk/test/Driver/cpath.c (original)
+++ cfe/trunk/test/Driver/cpath.c Tue Aug 15 12:47:06 2017
@@ -1,20 +1,20 @@
-// RUN: mkdir -p %T/test1 %T/test2 %T/test3
+// RUN: mkdir -p %t/test1 %t/test2 %t/test3
 
-// RUN: env "CPATH=%T/test1%{pathsep}%T/test2" %clang -x c -E -v %s 2>&1 | 
FileCheck %s -check-prefix=CPATH

r306837 - [objc] Don't require null-check and don't emit memset when result is ignored for struct-returning method calls [clang part]

2017-06-30 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Fri Jun 30 09:28:15 2017
New Revision: 306837

URL: http://llvm.org/viewvc/llvm-project?rev=306837=rev
Log:
[objc] Don't require null-check and don't emit memset when result is ignored 
for struct-returning method calls [clang part]

This fixes an issue with the emission of lifetime markers for struct-returning 
Obj-C msgSend calls. When the result of a struct-returning call is ignored, the 
temporary storage is only marked with lifetime markers in one of the two 
branches of the nil-receiver-check. The check is, however, not required when 
the result is unused. If we still need to emit the check (due to consumer 
arguments), let's not emit the memset to zero out the result if it's unused. 
This fixes a use-after-scope false positive with AddressSanitizer.

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


Added:
cfe/trunk/test/CodeGenObjC/stret-lifetime.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/stret-1.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=306837=306836=306837=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Jun 30 09:28:15 2017
@@ -1678,7 +1678,10 @@ struct NullReturnState {
 
   /// Complete the null-return operation.  It is valid to call this
   /// regardless of whether 'init' has been called.
-  RValue complete(CodeGenFunction , RValue result, QualType resultType,
+  RValue complete(CodeGenFunction ,
+  ReturnValueSlot returnSlot,
+  RValue result,
+  QualType resultType,
   const CallArgList ,
   const ObjCMethodDecl *Method) {
 // If we never had to do a null-check, just use the raw result.
@@ -1745,7 +1748,8 @@ struct NullReturnState {
 // memory or (2) agg values in registers.
 if (result.isAggregate()) {
   assert(result.isAggregate() && "null init of non-aggregate result?");
-  CGF.EmitNullInitialization(result.getAggregateAddress(), resultType);
+  if (!returnSlot.isUnused())
+CGF.EmitNullInitialization(result.getAggregateAddress(), resultType);
   if (contBB) CGF.EmitBlock(contBB);
   return result;
 }
@@ -2117,11 +2121,11 @@ CGObjCCommonMac::EmitMessageSend(CodeGen
 }
   }
 
-  NullReturnState nullReturn;
+  bool RequiresNullCheck = false;
 
   llvm::Constant *Fn = nullptr;
   if (CGM.ReturnSlotInterferesWithArgs(MSI.CallInfo)) {
-if (ReceiverCanBeNull) nullReturn.init(CGF, Arg0);
+if (ReceiverCanBeNull) RequiresNullCheck = true;
 Fn = (ObjCABI == 2) ?  ObjCTypes.getSendStretFn2(IsSuper)
   : ObjCTypes.getSendStretFn(IsSuper);
   } else if (CGM.ReturnTypeUsesFPRet(ResultType)) {
@@ -2134,23 +2138,30 @@ CGObjCCommonMac::EmitMessageSend(CodeGen
 // arm64 uses objc_msgSend for stret methods and yet null receiver check
 // must be made for it.
 if (ReceiverCanBeNull && CGM.ReturnTypeUsesSRet(MSI.CallInfo))
-  nullReturn.init(CGF, Arg0);
+  RequiresNullCheck = true;
 Fn = (ObjCABI == 2) ? ObjCTypes.getSendFn2(IsSuper)
   : ObjCTypes.getSendFn(IsSuper);
   }
 
+  // We don't need to emit a null check to zero out an indirect result if the
+  // result is ignored.
+  if (Return.isUnused())
+RequiresNullCheck = false;
+
   // Emit a null-check if there's a consumed argument other than the receiver.
-  bool RequiresNullCheck = false;
-  if (ReceiverCanBeNull && CGM.getLangOpts().ObjCAutoRefCount && Method) {
+  if (!RequiresNullCheck && CGM.getLangOpts().ObjCAutoRefCount && Method) {
 for (const auto *ParamDecl : Method->parameters()) {
   if (ParamDecl->hasAttr()) {
-if (!nullReturn.NullBB)
-  nullReturn.init(CGF, Arg0);
 RequiresNullCheck = true;
 break;
   }
 }
   }
+
+  NullReturnState nullReturn;
+  if (RequiresNullCheck) {
+nullReturn.init(CGF, Arg0);
+  }
   
   llvm::Instruction *CallSite;
   Fn = llvm::ConstantExpr::getBitCast(Fn, MSI.MessengerType);
@@ -2164,7 +2175,7 @@ CGObjCCommonMac::EmitMessageSend(CodeGen
 llvm::CallSite(CallSite).setDoesNotReturn();
   }
 
-  return nullReturn.complete(CGF, rvalue, ResultType, CallArgs,
+  return nullReturn.complete(CGF, Return, rvalue, ResultType, CallArgs,
  RequiresNullCheck ? Method : nullptr);
 }
 
@@ -7073,7 +7084,7 @@ CGObjCNonFragileABIMac::EmitVTableMessag
   CGCallee callee(CGCalleeInfo(), calleePtr);
 
   RValue result = CGF.EmitCall(MSI.CallInfo, callee, returnSlot, args);
-  return nullReturn.complete(CGF, result, resultType, formalArgs,
+  return nullReturn.complete(CGF, returnSlot, result, resultType, formalArgs,
  requiresnullCheck ? method : nullptr);
 }
 

Modified: cfe/trunk/test/CodeGenObjC/stret-1.m
URL: 

Re: r300295 - [docs] UBSan: Mention that print_stacktrace=1 is unsupported on Darwin

2017-04-14 Thread Kuba Mracek via cfe-commits
What exactly is wrong with the fast unwinder?  It's used in ASan and TSan and 
besides not knowing about inlined frames, it works great.  But we're almost 
always dealing with code that has frame pointers (and the sanitizer runtimes 
themselves are built with frame pointers).

Kuba

> On 13 Apr 2017, at 19:18, Vedant Kumar via cfe-commits 
>  wrote:
> 
> Does anyone know what it would take to get the slow unwinder to work on 
> Darwin?
> 
> thanks,
> vedant
> 
>> On Apr 13, 2017, at 6:59 PM, Vedant Kumar via cfe-commits 
>>  wrote:
>> 
>> Author: vedantk
>> Date: Thu Apr 13 20:59:44 2017
>> New Revision: 300295
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=300295=rev
>> Log:
>> [docs] UBSan: Mention that print_stacktrace=1 is unsupported on Darwin
>> 
>> Printing out stack traces along with UBSan diagnostics is unsupported on
>> Darwin. That's because it isn't possible to use the fast unwinder or the
>> slow unwinder.
>> 
>> Apparently, it's inappropriate to use the fast unwinder for UBSan
>> issues. I'm not exactly sure why (see the comment in ubsan_diag.cc).
>> Forcing use of the fast unwinder produces decent results, AFAICT.
>> 
>> Darwin also does not appear to have a slow unwinder suitable for use
>> with the sanitizers. Apparently that's because of PR20800 [1][2]. But
>> that bug has been fixed. I'm not sure if there is anything preventing
>> use of the slow unwinder now.
>> 
>> Currently, passing UBSAN_OPTIONS=print_stacktrace=1 does nothing on
>> Darwin. This isn't good, but it might be a while before we can fix the
>> situation, so we should at least document it.
>> 
>> [1] https://github.com/google/sanitizers/issues/137
>> "We can't use the slow unwinder on OSX now, because Clang produces
>> incorrect unwind info for the ASan runtime functions on OSX
>> (http://llvm.org/PR20800)."
>> 
>> [2] https://bugs.llvm.org/show_bug.cgi?id=20800
>> Bug 20800 - Invalid compact unwind info generated for a function without
>> frame pointers on OSX
>> 
>> Modified:
>>   cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> 
>> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=300295=300294=300295=diff
>> ==
>> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
>> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Apr 13 20:59:44 2017
>> @@ -157,6 +157,8 @@ will need to:
>>   ``UBSAN_OPTIONS=print_stacktrace=1``.
>> #. Make sure ``llvm-symbolizer`` binary is in ``PATH``.
>> 
>> +Stacktrace printing for UBSan issues is currently not supported on Darwin.
>> +
>> Issue Suppression
>> =
>> 
>> 
>> 
>> ___
>> 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

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


r300340 - [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt [take 2]

2017-04-14 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Fri Apr 14 11:53:25 2017
New Revision: 300340

URL: http://llvm.org/viewvc/llvm-project?rev=300340=rev
Log:
[ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt [take 
2]

CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for 
the loop variable in an inconsistent way:  lifetime.start is emitted before the 
loop is entered, but lifetime.end is emitted inside the loop. AddressSanitizer 
uses these markers to track out-of-scope accesses to local variables, and we 
get false positives in Obj-C foreach loops (in the 2nd iteration of the loop). 
This patch keeps the loop variable alive for the whole loop by extending 
ForScope and registering the cleanup function inside EmitAutoVarAlloca.

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


Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/arc-blocks.m
cfe/trunk/test/CodeGenObjCXX/arc-references.mm

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=300340=300339=300340=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Apr 14 11:53:25 2017
@@ -1118,6 +1118,12 @@ CodeGenFunction::EmitAutoVarAlloca(const
   if (D.hasAttr())
 EmitVarAnnotations(, address.getPointer());
 
+  // Make sure we call @llvm.lifetime.end.
+  if (emission.useLifetimeMarkers())
+EHStack.pushCleanup(NormalEHLifetimeMarker,
+ emission.getAllocatedAddress(),
+ emission.getSizeForLifetimeMarkers());
+
   return emission;
 }
 
@@ -1408,13 +1414,6 @@ void CodeGenFunction::EmitAutoVarCleanup
 
   const VarDecl  = *emission.Variable;
 
-  // Make sure we call @llvm.lifetime.end.  This needs to happen
-  // *last*, so the cleanup needs to be pushed *first*.
-  if (emission.useLifetimeMarkers())
-EHStack.pushCleanup(NormalEHLifetimeMarker,
- emission.getAllocatedAddress(),
- emission.getSizeForLifetimeMarkers());
-
   // Check the type for a cleanup.
   if (QualType::DestructionKind dtorKind = D.getType().isDestructedType())
 emitAutoVarTypeCleanup(emission, dtorKind);

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=300340=300339=300340=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Fri Apr 14 11:53:25 2017
@@ -1469,6 +1469,8 @@ void CodeGenFunction::EmitObjCForCollect
   if (DI)
 DI->EmitLexicalBlockStart(Builder, S.getSourceRange().getBegin());
 
+  RunCleanupsScope ForScope(*this);
+
   // The local variable comes into scope immediately.
   AutoVarEmission variable = AutoVarEmission::invalid();
   if (const DeclStmt *SD = dyn_cast(S.getElement()))
@@ -1499,8 +1501,6 @@ void CodeGenFunction::EmitObjCForCollect
   ArrayType::Normal, 0);
   Address ItemsPtr = CreateMemTemp(ItemsTy, "items.ptr");
 
-  RunCleanupsScope ForScope(*this);
-
   // Emit the collection pointer.  In ARC, we do a retain.
   llvm::Value *Collection;
   if (getLangOpts().ObjCAutoRefCount) {

Modified: cfe/trunk/test/CodeGenObjC/arc-blocks.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-blocks.m?rev=300340=300339=300340=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-blocks.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-blocks.m Fri Apr 14 11:53:25 2017
@@ -532,8 +532,6 @@ void test13(id x) {
   // CHECK-NEXT: [[T0:%.*]] = load void ()*, void ()** [[B]]
   // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
   // CHECK-NEXT: call void @objc_release(i8* [[T1]])
-  // CHECK-NEXT: [[BPTR2:%.*]] = bitcast void ()** [[B]] to i8*
-  // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[BPTR2]])
 
   // CHECK-NEXT: [[T0:%.*]] = load i1, i1* [[CLEANUP_ACTIVE]]
   // CHECK-NEXT: br i1 [[T0]]
@@ -541,7 +539,9 @@ void test13(id x) {
   // CHECK-NEXT: call void @objc_release(i8* [[T0]])
   // CHECK-NEXT: br label
 
-  // CHECK:  [[T0:%.*]] = load i8*, i8** [[X]]
+  // CHECK:  [[BPTR2:%.*]] = bitcast void ()** [[B]] to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[BPTR2]])
+  // CHECK-NEXT:  [[T0:%.*]] = load i8*, i8** [[X]]
   // CHECK-NEXT: call void @objc_release(i8* [[T0]])
   // CHECK-NEXT: ret void
 }

Modified: cfe/trunk/test/CodeGenObjCXX/arc-references.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc-references.mm?rev=300340=300339=300340=diff

r300290 - Revert r300287.

2017-04-13 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Thu Apr 13 20:00:03 2017
New Revision: 300290

URL: http://llvm.org/viewvc/llvm-project?rev=300290=rev
Log:
Revert r300287.


Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/arc-foreach.m
cfe/trunk/test/CodeGenObjC/arc-ternary-op.m

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=300290=300289=300290=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu Apr 13 20:00:03 2017
@@ -1469,6 +1469,11 @@ void CodeGenFunction::EmitObjCForCollect
   if (DI)
 DI->EmitLexicalBlockStart(Builder, S.getSourceRange().getBegin());
 
+  // The local variable comes into scope immediately.
+  AutoVarEmission variable = AutoVarEmission::invalid();
+  if (const DeclStmt *SD = dyn_cast(S.getElement()))
+variable = EmitAutoVarAlloca(*cast(SD->getSingleDecl()));
+
   JumpDest LoopEnd = getJumpDestInCurrentScope("forcoll.end");
 
   // Fast enumeration state.
@@ -1620,10 +1625,8 @@ void CodeGenFunction::EmitObjCForCollect
   bool elementIsVariable;
   LValue elementLValue;
   QualType elementType;
-  AutoVarEmission variable = AutoVarEmission::invalid();
   if (const DeclStmt *SD = dyn_cast(S.getElement())) {
 // Initialize the variable, in case it's a __block variable or something.
-variable = EmitAutoVarAlloca(*cast(SD->getSingleDecl()));
 EmitAutoVarInit(variable);
 
 const VarDecl* D = cast(SD->getSingleDecl());

Modified: cfe/trunk/test/CodeGenObjC/arc-foreach.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-foreach.m?rev=300290=300289=300290=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-foreach.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-foreach.m Thu Apr 13 20:00:03 2017
@@ -24,9 +24,9 @@ void test0(NSArray *array) {
 
 // CHECK-LP64-LABEL:define void @test0(
 // CHECK-LP64:  [[ARRAY:%.*]] = alloca [[ARRAY_T:%.*]]*,
+// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[STATE:%.*]] = alloca [[STATE_T:%.*]],
 // CHECK-LP64-NEXT: [[BUFFER:%.*]] = alloca [16 x i8*], align 8
-// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
 
 // Initialize 'array'.
@@ -97,9 +97,9 @@ void test1(NSArray *array) {
 
 // CHECK-LP64-LABEL:define void @test1(
 // CHECK-LP64:  alloca [[ARRAY_T:%.*]]*,
+// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[STATE:%.*]] = alloca [[STATE_T:%.*]],
 // CHECK-LP64-NEXT: alloca [16 x i8*], align 8
-// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], 
[[STATE_T]]* [[STATE]], i32 0, i32 1
@@ -160,7 +160,7 @@ void test3(NSArray *array) {
 
   // CHECK-LP64-LABEL:define void @test3(
   // CHECK-LP64:  [[ARRAY:%.*]] = alloca [[ARRAY_T]]*, align 8
-  // CHECK-LP64:  [[X:%.*]] = alloca i8*, align 8
+  // CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*, align 8
   // CHECK-LP64:  [[T0:%.*]] = load i8*, i8** [[X]], align 8
   // CHECK-LP64-NEXT: [[T1:%.*]] = icmp ne i8* [[T0]], null
   // CHECK-LP64-NEXT: br i1 [[T1]],

Modified: cfe/trunk/test/CodeGenObjC/arc-ternary-op.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-ternary-op.m?rev=300290=300289=300290=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-ternary-op.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-ternary-op.m Thu Apr 13 20:00:03 2017
@@ -120,9 +120,9 @@ void test2(int cond) {
 
   // CHECK-LABEL:define void @test2(
   // CHECK:  [[COND:%.*]] = alloca i32,
+  // CHECK:  alloca i8*
   // CHECK:  [[CLEANUP_SAVE:%.*]] = alloca i8*
   // CHECK:  [[RUN_CLEANUP:%.*]] = alloca i1
-  // CHECK:  alloca i8*
   //   Evaluate condition; cleanup disabled by default.
   // CHECK:  [[T0:%.*]] = load i32, i32* [[COND]],
   // CHECK-NEXT: icmp ne i32 [[T0]], 0


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


r300287 - [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt

2017-04-13 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Thu Apr 13 19:32:43 2017
New Revision: 300287

URL: http://llvm.org/viewvc/llvm-project?rev=300287=rev
Log:
[ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt

CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for 
the loop variable in an inconsistent way:  lifetime.start is emitted before the 
loop is entered, but lifetime.end is emitted inside the loop.  AddressSanitizer 
uses these markers to track out-of-scope accesses to local variables, and we 
get false positives in Obj-C foreach loops (in the 2nd iteration of the loop). 
The markers of the loop variable need to be either both inside the loop (so 
that we poison and unpoison the variable in each iteration), or both outside. 
This patch implements the "both inside" approach.

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


Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/arc-foreach.m
cfe/trunk/test/CodeGenObjC/arc-ternary-op.m

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=300287=300286=300287=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu Apr 13 19:32:43 2017
@@ -1469,11 +1469,6 @@ void CodeGenFunction::EmitObjCForCollect
   if (DI)
 DI->EmitLexicalBlockStart(Builder, S.getSourceRange().getBegin());
 
-  // The local variable comes into scope immediately.
-  AutoVarEmission variable = AutoVarEmission::invalid();
-  if (const DeclStmt *SD = dyn_cast(S.getElement()))
-variable = EmitAutoVarAlloca(*cast(SD->getSingleDecl()));
-
   JumpDest LoopEnd = getJumpDestInCurrentScope("forcoll.end");
 
   // Fast enumeration state.
@@ -1625,8 +1620,10 @@ void CodeGenFunction::EmitObjCForCollect
   bool elementIsVariable;
   LValue elementLValue;
   QualType elementType;
+  AutoVarEmission variable = AutoVarEmission::invalid();
   if (const DeclStmt *SD = dyn_cast(S.getElement())) {
 // Initialize the variable, in case it's a __block variable or something.
+variable = EmitAutoVarAlloca(*cast(SD->getSingleDecl()));
 EmitAutoVarInit(variable);
 
 const VarDecl* D = cast(SD->getSingleDecl());

Modified: cfe/trunk/test/CodeGenObjC/arc-foreach.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-foreach.m?rev=300287=300286=300287=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-foreach.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-foreach.m Thu Apr 13 19:32:43 2017
@@ -24,9 +24,9 @@ void test0(NSArray *array) {
 
 // CHECK-LP64-LABEL:define void @test0(
 // CHECK-LP64:  [[ARRAY:%.*]] = alloca [[ARRAY_T:%.*]]*,
-// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[STATE:%.*]] = alloca [[STATE_T:%.*]],
 // CHECK-LP64-NEXT: [[BUFFER:%.*]] = alloca [16 x i8*], align 8
+// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
 
 // Initialize 'array'.
@@ -97,9 +97,9 @@ void test1(NSArray *array) {
 
 // CHECK-LP64-LABEL:define void @test1(
 // CHECK-LP64:  alloca [[ARRAY_T:%.*]]*,
-// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[STATE:%.*]] = alloca [[STATE_T:%.*]],
 // CHECK-LP64-NEXT: alloca [16 x i8*], align 8
+// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], 
[[STATE_T]]* [[STATE]], i32 0, i32 1
@@ -160,7 +160,7 @@ void test3(NSArray *array) {
 
   // CHECK-LP64-LABEL:define void @test3(
   // CHECK-LP64:  [[ARRAY:%.*]] = alloca [[ARRAY_T]]*, align 8
-  // CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*, align 8
+  // CHECK-LP64:  [[X:%.*]] = alloca i8*, align 8
   // CHECK-LP64:  [[T0:%.*]] = load i8*, i8** [[X]], align 8
   // CHECK-LP64-NEXT: [[T1:%.*]] = icmp ne i8* [[T0]], null
   // CHECK-LP64-NEXT: br i1 [[T1]],

Modified: cfe/trunk/test/CodeGenObjC/arc-ternary-op.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-ternary-op.m?rev=300287=300286=300287=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-ternary-op.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-ternary-op.m Thu Apr 13 19:32:43 2017
@@ -120,9 +120,9 @@ void test2(int cond) {
 
   // CHECK-LABEL:define void @test2(
   // CHECK:  [[COND:%.*]] = alloca i32,
-  // CHECK:  alloca i8*
   // CHECK:  [[CLEANUP_SAVE:%.*]] = alloca i8*
   // CHECK:  [[RUN_CLEANUP:%.*]] = alloca i1
+  // CHECK:  alloca i8*
   //   Evaluate condition; cleanup disabled by default.
   // CHECK:  [[T0:%.*]] = load i32, i32* [[COND]],
   // CHECK-NEXT: icmp ne i32 [[T0]], 0


___
cfe-commits mailing list

r299174 - [asan] Turn -fsanitize-address-use-after-scope on by default [clang part]

2017-03-30 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Thu Mar 30 22:00:09 2017
New Revision: 299174

URL: http://llvm.org/viewvc/llvm-project?rev=299174=rev
Log:
[asan] Turn -fsanitize-address-use-after-scope on by default [clang part]

AddressSanitizer has an optional compile-time flag, 
-fsanitize-address-use-after-scope, which enables detection of use-after-scope 
bugs. We'd like to have this feature on by default, because it is already very 
well tested, it's used in several projects already (LLVM automatically enables 
it when using -DLLVM_USE_SANITIZER=Address), it's low overhead and there are no 
known issues or incompatibilities.

This patch enables use-after-scope by default via the Clang driver, where we 
set true as the default value for AsanUseAfterScope. This also causes the 
lifetime markers to be generated whenever fsanitize=address is used. This has 
some nice consequences, e.g. we now have line numbers for all local variables.

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


Modified:
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=299174=299173=299174=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Thu Mar 30 22:00:09 2017
@@ -34,7 +34,7 @@ class SanitizerArgs {
   bool CfiCrossDso = false;
   int AsanFieldPadding = 0;
   bool AsanSharedRuntime = false;
-  bool AsanUseAfterScope = false;
+  bool AsanUseAfterScope = true;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
   bool Stats = false;

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=299174=299173=299174=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Thu Mar 30 22:00:09 2017
@@ -121,7 +121,7 @@
 // CHECK-USE-AFTER-SCOPE-BOTH-OFF-NOT: -cc1{{.*}}address-use-after-scope
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
-// CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE-NOT: -cc1{{.*}}address-use-after-scope
+// CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE: -cc1{{.*}}address-use-after-scope
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: 
'-fsanitize-memory-track-origins'


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


r289890 - [sanitizer] Passthrough CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT when building compiler-rt from clang/runtime/CMakeLists.txt

2016-12-15 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Thu Dec 15 17:20:54 2016
New Revision: 289890

URL: http://llvm.org/viewvc/llvm-project?rev=289890=rev
Log:
[sanitizer] Passthrough CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT when 
building compiler-rt from clang/runtime/CMakeLists.txt

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


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=289890=289889=289890=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Thu Dec 15 17:20:54 2016
@@ -78,6 +78,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
+   -DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT}
${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