From: Vitaly Buka Date: Mon, 26 Aug 2019 22:16:05 +0000 (+0000) Subject: hwasan, codegen: Keep more lifetime markers used for hwasan X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ea481ed968c192a0df8a58dc02b9ec6eb591f07;p=clang hwasan, codegen: Keep more lifetime markers used for hwasan Reviewers: eugenis Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66697 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369980 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 0e04a51456..86ef0b8cdb 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -521,6 +521,7 @@ EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *M) { ConditionalEvaluation *OldConditional = nullptr; CGBuilderTy::InsertPoint OldIP; if (isInConditionalBranch() && !E->getType().isDestructedType() && + !SanOpts.has(SanitizerKind::HWAddress) && !SanOpts.has(SanitizerKind::Memory) && !CGM.getCodeGenOpts().SanitizeAddressUseAfterScope) { OldConditional = OutermostConditional; diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 228093044e..4b7986f716 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -49,6 +49,7 @@ static bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts, // Sanitizers may use markers. if (CGOpts.SanitizeAddressUseAfterScope || + LangOpts.Sanitize.has(SanitizerKind::HWAddress) || LangOpts.Sanitize.has(SanitizerKind::Memory)) return true; diff --git a/test/CodeGen/lifetime-sanitizer.c b/test/CodeGen/lifetime-sanitizer.c index 04714d7a19..95fa970c72 100644 --- a/test/CodeGen/lifetime-sanitizer.c +++ b/test/CodeGen/lifetime-sanitizer.c @@ -5,6 +5,9 @@ // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \ // RUN: -fsanitize=memory %s | \ // RUN: FileCheck %s -check-prefix=LIFETIME +// RUN: %clang -target aarch64-linux-gnu -S -emit-llvm -o - -O0 \ +// RUN: -fsanitize=hwaddress %s | \ +// RUN: FileCheck %s -check-prefix=LIFETIME extern int bar(char *A, int n); diff --git a/test/CodeGenCXX/lifetime-sanitizer.cpp b/test/CodeGenCXX/lifetime-sanitizer.cpp index 7921483eee..5b52e6e6aa 100644 --- a/test/CodeGenCXX/lifetime-sanitizer.cpp +++ b/test/CodeGenCXX/lifetime-sanitizer.cpp @@ -6,6 +6,9 @@ // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \ // RUN: -fsanitize=memory %s | \ // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME +// RUN: %clang -w -target aarch64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \ +// RUN: -fsanitize=hwaddress %s | \ +// RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME extern int bar(char *A, int n);