[PATCH] D73020: [Sema] Perform call checking when building CXXNewExpr
lebedev.ri marked an inline comment as done. lebedev.ri added a comment. Bump @rsmith thanks Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73020/new/ https://reviews.llvm.org/D73020 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D73996: [Sema] Demote call-site-based 'alignment is a power of two' check for AllocAlignAttr into a warning
lebedev.ri added a comment. Bump @rsmith / @erichkeane thanks Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73996/new/ https://reviews.llvm.org/D73996 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a067891 - [clang][codegen] Fix another lifetime emission on alloca on non-default address space.
Author: Michael Liao Date: 2020-02-10T00:15:56-05:00 New Revision: a06789138987d1f64bb2f97d3a5c0f39eaf94715 URL: https://github.com/llvm/llvm-project/commit/a06789138987d1f64bb2f97d3a5c0f39eaf94715 DIFF: https://github.com/llvm/llvm-project/commit/a06789138987d1f64bb2f97d3a5c0f39eaf94715.diff LOG: [clang][codegen] Fix another lifetime emission on alloca on non-default address space. - Lifetime intrinsics expect the pointer directly from alloca. Need extra handling for targets with alloca on non-default (or non-zero) address space. Added: clang/test/CodeGenCXX/amdgcn-call-with-aggarg.cpp Modified: clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CodeGenFunction.h Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 3edcfb21ef34..9ef2a3b3d099 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -3690,8 +3690,9 @@ void CodeGenFunction::EmitCallArg(CallArgList , const Expr *E, } AggValueSlot ArgSlot = AggValueSlot::ignored(); + Address ArgSlotAlloca = Address::invalid(); if (hasAggregateEvaluationKind(E->getType())) { -ArgSlot = CreateAggTemp(E->getType(), "agg.tmp"); +ArgSlot = CreateAggTemp(E->getType(), "agg.tmp", ); // Emit a lifetime start/end for this temporary. If the type has a // destructor, then we need to keep it alive. FIXME: We should still be able @@ -3699,8 +3700,9 @@ void CodeGenFunction::EmitCallArg(CallArgList , const Expr *E, if (!E->getType().isDestructedType()) { uint64_t size = CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(E->getType())); - if (auto *lifetimeSize = EmitLifetimeStart(size, ArgSlot.getPointer())) -args.addLifetimeCleanup({ArgSlot.getPointer(), lifetimeSize}); + if (auto *lifetimeSize = + EmitLifetimeStart(size, ArgSlotAlloca.getPointer())) +args.addLifetimeCleanup({ArgSlotAlloca.getPointer(), lifetimeSize}); } } diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index f48d8a4cc366..7ddd38c7b262 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -2264,8 +2264,9 @@ class CodeGenFunction : public CodeGenTypeCache { /// CreateAggTemp - Create a temporary memory object for the given /// aggregate type. - AggValueSlot CreateAggTemp(QualType T, const Twine = "tmp") { -return AggValueSlot::forAddr(CreateMemTemp(T, Name), + AggValueSlot CreateAggTemp(QualType T, const Twine = "tmp", + Address *Alloca = nullptr) { +return AggValueSlot::forAddr(CreateMemTemp(T, Name, Alloca), T.getQualifiers(), AggValueSlot::IsNotDestructed, AggValueSlot::DoesNotNeedGCBarriers, diff --git a/clang/test/CodeGenCXX/amdgcn-call-with-aggarg.cpp b/clang/test/CodeGenCXX/amdgcn-call-with-aggarg.cpp new file mode 100644 index ..e9d3683cfaa2 --- /dev/null +++ b/clang/test/CodeGenCXX/amdgcn-call-with-aggarg.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -O3 -disable-llvm-passes -o - %s | FileCheck %s + +struct A { + float x, y, z, w; +}; + +void foo(A a); + +// CHECK-LABEL: @_Z4testv +// CHECK: %[[lvar:.*]] = alloca %struct.A, align 4, addrspace(5) +// CHECK: %[[atmp:.*]] = alloca %struct.A, align 4, addrspace(5) +// CHECK: %[[lcst:.*]] = bitcast %struct.A addrspace(5)* %[[lvar]] to i8 addrspace(5)* +// CHECK: call void @llvm.lifetime.start.p5i8(i64 16, i8 addrspace(5)* %[[lcst]] +// CHECK: %[[acst:.*]] = bitcast %struct.A addrspace(5)* %[[atmp]] to i8 addrspace(5)* +// CHECK: call void @llvm.lifetime.start.p5i8(i64 16, i8 addrspace(5)* %[[acst]] +void test() { + A a; + foo(a); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D74298: Honor -finline-functions and -finline-hint-functions at -O0
davezarzycki added a comment. Hi @MaskRay – I was just looking at the source history. I didn't test the old way. As it turns out there isn't a regression, but just some unexplained code in the current clang option parsing. And the `-disable-O0-optnone` is a useful hint. Thanks! I've been hacking on clang and trying to get the normal inliner pass to run at -O0, but with no luck so far. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74298/new/ https://reviews.llvm.org/D74298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] 4b23a2e - libclc: Move rsqrt implementation to a .cl file
Author: Jan Vesely Date: 2020-02-09T14:42:09-05:00 New Revision: 4b23a2e8e971876d075d3ae322754dbc0495413d URL: https://github.com/llvm/llvm-project/commit/4b23a2e8e971876d075d3ae322754dbc0495413d DIFF: https://github.com/llvm/llvm-project/commit/4b23a2e8e971876d075d3ae322754dbc0495413d.diff LOG: libclc: Move rsqrt implementation to a .cl file Reviewer: awatry Differential Revision: https://reviews.llvm.org/D74013 Added: libclc/generic/lib/math/rsqrt.cl Modified: libclc/generic/include/clc/math/rsqrt.h libclc/generic/lib/SOURCES Removed: diff --git a/libclc/generic/include/clc/math/rsqrt.h b/libclc/generic/include/clc/math/rsqrt.h index 9d49ee652262..41b9fd7572b9 100644 --- a/libclc/generic/include/clc/math/rsqrt.h +++ b/libclc/generic/include/clc/math/rsqrt.h @@ -1 +1,7 @@ -#define rsqrt(x) (1.f/sqrt(x)) +#define __CLC_BODY +#define __CLC_FUNCTION rsqrt + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES index df7f68f040f3..ee2736b5fbc5 100644 --- a/libclc/generic/lib/SOURCES +++ b/libclc/generic/lib/SOURCES @@ -176,6 +176,7 @@ math/rint.cl math/clc_rootn.cl math/rootn.cl math/round.cl +math/rsqrt.cl math/sin.cl math/sincos.cl math/sincos_helpers.cl diff --git a/libclc/generic/lib/math/rsqrt.cl b/libclc/generic/lib/math/rsqrt.cl new file mode 100644 index ..131ffc194a90 --- /dev/null +++ b/libclc/generic/lib/math/rsqrt.cl @@ -0,0 +1,23 @@ +#include + +#include "../clcmacro.h" + +_CLC_OVERLOAD _CLC_DEF float rsqrt(float x) +{ +return 1.0f / sqrt(x); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, rsqrt, float); + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF double rsqrt(double x) +{ +return 1.0 / sqrt(x); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, rsqrt, double); + +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] 85e2fa4 - libclc/r600: Use target specific builtins to implement rsqrt and native_rsqrt
Author: Jan Vesely Date: 2020-02-09T14:42:15-05:00 New Revision: 85e2fa44c64e1edd2f675c990ecc60f5fadb4686 URL: https://github.com/llvm/llvm-project/commit/85e2fa44c64e1edd2f675c990ecc60f5fadb4686 DIFF: https://github.com/llvm/llvm-project/commit/85e2fa44c64e1edd2f675c990ecc60f5fadb4686.diff LOG: libclc/r600: Use target specific builtins to implement rsqrt and native_rsqrt Fixes OCL CTS rsqrt and half_rsqrt (1 thread, scalaer) tests on AMD Turks. Reviewer: awatry Differential Revision: https://reviews.llvm.org/D74016 Added: libclc/r600/lib/math/native_rsqrt.cl libclc/r600/lib/math/rsqrt.cl Modified: libclc/r600/lib/SOURCES Removed: diff --git a/libclc/r600/lib/SOURCES b/libclc/r600/lib/SOURCES index 4342ac38201c..6e01bbb2b8b9 100644 --- a/libclc/r600/lib/SOURCES +++ b/libclc/r600/lib/SOURCES @@ -1,5 +1,7 @@ math/fmax.cl math/fmin.cl +math/native_rsqrt.cl +math/rsqrt.cl synchronization/barrier.cl workitem/get_global_offset.cl workitem/get_group_id.cl diff --git a/libclc/r600/lib/math/native_rsqrt.cl b/libclc/r600/lib/math/native_rsqrt.cl new file mode 100644 index ..edf473e8409c --- /dev/null +++ b/libclc/r600/lib/math/native_rsqrt.cl @@ -0,0 +1,10 @@ +#include + +#include "../../../generic/lib/clcmacro.h" + +_CLC_OVERLOAD _CLC_DEF float native_rsqrt(float x) +{ +return __builtin_r600_recipsqrt_ieeef(x); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, native_rsqrt, float); diff --git a/libclc/r600/lib/math/rsqrt.cl b/libclc/r600/lib/math/rsqrt.cl new file mode 100644 index ..37a8037902c2 --- /dev/null +++ b/libclc/r600/lib/math/rsqrt.cl @@ -0,0 +1,23 @@ +#include + +#include "../../../generic/lib/clcmacro.h" + +_CLC_OVERLOAD _CLC_DEF float rsqrt(float x) +{ +return __builtin_r600_recipsqrt_ieeef(x); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, rsqrt, float); + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF double rsqrt(double x) +{ +return __builtin_r600_recipsqrt_ieee(x); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, rsqrt, double); + +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang] 0e3a487 - PR12350: Handle remaining cases permitted by CWG DR 244.
On Sun, 9 Feb 2020, 01:09 Nico Weber via cfe-commits, < cfe-commits@lists.llvm.org> wrote: > Our code fails to build with "destructor cannot be declared using a type > alias" after this, without us changing language mode or anything. > > Is that intended? > Can you provide a sketch of what you were doing? There are certainly cases where I'd expect that now -- where you find a typedef through in "bad" (extension) place and find a non-typedef elsewhere. Can this be a default-error-mapped warning so that projects have some > incremental transition path for this? > That seems reasonable, yes. On Fri, Feb 7, 2020 at 9:41 PM Richard Smith via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> >> Author: Richard Smith >> Date: 2020-02-07T18:40:41-08:00 >> New Revision: 0e3a48778408b505946e465abf5c77a2ddd4918c >> >> URL: >> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c >> DIFF: >> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c.diff >> >> LOG: PR12350: Handle remaining cases permitted by CWG DR 244. >> >> Also add extension warnings for the cases that are disallowed by the >> current rules for destructor name lookup, refactor and simplify the >> lookup code, and improve the diagnostic quality when lookup fails. >> >> The special case we previously supported for converting >> p->N::S::~S() from naming a class template into naming a >> specialization thereof is subsumed by a more general rule here (which is >> also consistent with Clang's historical behavior and that of other >> compilers): if we can't find a suitable S in N, also look in N::S. >> >> The extension warnings are off by default, except for a warning when >> lookup for p->N::S::~T() looks for T in scope instead of in N (or N::S). >> That seems sufficiently heinous to warn on by default, especially since >> we can't support it for a dependent nested-name-specifier. >> >> Added: >> >> >> Modified: >> clang/include/clang/Basic/DiagnosticGroups.td >> clang/include/clang/Basic/DiagnosticSemaKinds.td >> clang/lib/AST/NestedNameSpecifier.cpp >> clang/lib/Sema/DeclSpec.cpp >> clang/lib/Sema/SemaExprCXX.cpp >> clang/test/CXX/class/class.mem/p13.cpp >> clang/test/CXX/drs/dr2xx.cpp >> clang/test/CXX/drs/dr3xx.cpp >> clang/test/FixIt/fixit.cpp >> clang/test/Parser/cxx-decl.cpp >> clang/test/SemaCXX/constructor.cpp >> clang/test/SemaCXX/destructor.cpp >> clang/test/SemaCXX/pseudo-destructors.cpp >> >> Removed: >> >> >> >> >> >> diff --git a/clang/include/clang/Basic/DiagnosticGroups.td >> b/clang/include/clang/Basic/DiagnosticGroups.td >> index a2bc29986a07..8c54723cdbab 100644 >> --- a/clang/include/clang/Basic/DiagnosticGroups.td >> +++ b/clang/include/clang/Basic/DiagnosticGroups.td >> @@ -192,6 +192,7 @@ def CXX2aDesignator : DiagGroup<"c++2a-designator">; >> // designators (including the warning controlled by -Wc++2a-designator). >> def C99Designator : DiagGroup<"c99-designator", [CXX2aDesignator]>; >> def GNUDesignator : DiagGroup<"gnu-designator">; >> +def DtorName : DiagGroup<"dtor-name">; >> >> def DynamicExceptionSpec >> : DiagGroup<"dynamic-exception-spec", >> [DeprecatedDynamicExceptionSpec]>; >> >> diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td >> b/clang/include/clang/Basic/DiagnosticSemaKinds.td >> index 9de60d3a8d27..82861f0d5d72 100644 >> --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td >> +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td >> @@ -1911,17 +1911,33 @@ def err_destructor_with_params : >> Error<"destructor cannot have any parameters">; >> def err_destructor_variadic : Error<"destructor cannot be variadic">; >> def err_destructor_typedef_name : Error< >>"destructor cannot be declared using a %select{typedef|type alias}1 %0 >> of the class name">; >> +def err_undeclared_destructor_name : Error< >> + "undeclared identifier %0 in destructor name">; >> def err_destructor_name : Error< >>"expected the class name after '~' to name the enclosing class">; >> -def err_destructor_class_name : Error< >> - "expected the class name after '~' to name a destructor">; >> -def err_ident_in_dtor_not_a_type : Error< >> +def err_destructor_name_nontype : Error< >> + "identifier %0 after '~' in destructor name does not name a type">; >> +def err_destructor_expr_mismatch : Error< >> + "identifier %0 in object destruction expression does not name the type >> " >> + "%1 of the object being destroyed">; >> +def err_destructor_expr_nontype : Error< >>"identifier %0 in object destruction expression does not name a type">; >> def err_destructor_expr_type_mismatch : Error< >>"destructor type %0 in object destruction expression does not match >> the " >>"type %1 of the object being destroyed">; >> def note_destructor_type_here : Note< >> - "type %0 is declared here">; >> + "type %0
[PATCH] D74298: Honor -finline-functions and -finline-hint-functions at -O0
MaskRay added a comment. Why you say regression, do you have a case where fcd33149b48885ab8e4ca4ffb6977bce5be2e623 actually regressed things? -O0 implies optnone. For `-Xclang -disable-O0-optnone -O0 -finline-functions`, the patch can indeed make a difference. `-disable-O0-optnone` is currently a debug aid AFAICT. `GCC -O0 -finline-functions` does not seem to have a difference. Comment at: clang/lib/Frontend/CompilerInvocation.cpp:702 +const Option = InlineArg->getOption(); +if (InlineOpt.matches(options::OPT_fno_inline)) { + Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining); The old order looks good. The new ordering does not seen to be needed? The assert is also unnecessary. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74298/new/ https://reviews.llvm.org/D74298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D74298: Honor -finline-functions and -finline-hint-functions at -O0
davezarzycki added a comment. Hi @lebedev.ri – Before I add a small new test file, is there an existing one that you know of that would be good to extend? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74298/new/ https://reviews.llvm.org/D74298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D74298: Honor -finline-functions and -finline-hint-functions at -O0
lebedev.ri added a comment. This clearly needs tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74298/new/ https://reviews.llvm.org/D74298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D74298: Honor -finline-functions and -finline-hint-functions at -O0
davezarzycki created this revision. davezarzycki added a reviewer: chandlerc. davezarzycki added a project: clang. This fixes a regression introduced (over three years ago!) by fcd33149b48885ab8e4ca4ffb6977bce5be2e623. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D74298 Files: clang/lib/Frontend/CompilerInvocation.cpp Index: clang/lib/Frontend/CompilerInvocation.cpp === --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -694,19 +694,23 @@ Opts.setInlining((Opts.OptimizationLevel == 0) ? CodeGenOptions::OnlyAlwaysInlining : CodeGenOptions::NormalInlining); - // Explicit inlining flags can disable some or all inlining even at - // optimization levels above zero. + // Handle inlining overrides if (Arg *InlineArg = Args.getLastArg( options::OPT_finline_functions, options::OPT_finline_hint_functions, options::OPT_fno_inline_functions, options::OPT_fno_inline)) { -if (Opts.OptimizationLevel > 0) { - const Option = InlineArg->getOption(); - if (InlineOpt.matches(options::OPT_finline_functions)) -Opts.setInlining(CodeGenOptions::NormalInlining); - else if (InlineOpt.matches(options::OPT_finline_hint_functions)) -Opts.setInlining(CodeGenOptions::OnlyHintInlining); - else -Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining); +const Option = InlineArg->getOption(); +if (InlineOpt.matches(options::OPT_fno_inline)) { + Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining); +} else if (InlineOpt.matches(options::OPT_fno_inline_functions)) { + Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining); +} else if (InlineOpt.matches(options::OPT_finline_functions)) { + Opts.setInlining(CodeGenOptions::NormalInlining); +} else { + assert(InlineOpt.matches(options::OPT_finline_hint_functions) && + "Option parsing bug"); + Opts.setInlining(Args.hasArg(OPT_finline_functions) + ? CodeGenOptions::NormalInlining + : CodeGenOptions::OnlyHintInlining); } } Index: clang/lib/Frontend/CompilerInvocation.cpp === --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -694,19 +694,23 @@ Opts.setInlining((Opts.OptimizationLevel == 0) ? CodeGenOptions::OnlyAlwaysInlining : CodeGenOptions::NormalInlining); - // Explicit inlining flags can disable some or all inlining even at - // optimization levels above zero. + // Handle inlining overrides if (Arg *InlineArg = Args.getLastArg( options::OPT_finline_functions, options::OPT_finline_hint_functions, options::OPT_fno_inline_functions, options::OPT_fno_inline)) { -if (Opts.OptimizationLevel > 0) { - const Option = InlineArg->getOption(); - if (InlineOpt.matches(options::OPT_finline_functions)) -Opts.setInlining(CodeGenOptions::NormalInlining); - else if (InlineOpt.matches(options::OPT_finline_hint_functions)) -Opts.setInlining(CodeGenOptions::OnlyHintInlining); - else -Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining); +const Option = InlineArg->getOption(); +if (InlineOpt.matches(options::OPT_fno_inline)) { + Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining); +} else if (InlineOpt.matches(options::OPT_fno_inline_functions)) { + Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining); +} else if (InlineOpt.matches(options::OPT_finline_functions)) { + Opts.setInlining(CodeGenOptions::NormalInlining); +} else { + assert(InlineOpt.matches(options::OPT_finline_hint_functions) && + "Option parsing bug"); + Opts.setInlining(Args.hasArg(OPT_finline_functions) + ? CodeGenOptions::NormalInlining + : CodeGenOptions::OnlyHintInlining); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D69585: PerformPendingInstatiations() already in the PCH
llunak added a comment. Ping again. Is there still something more to do here? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69585/new/ https://reviews.llvm.org/D69585 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e67cbac - Support -fstack-clash-protection for x86
Author: serge_sans_paille Date: 2020-02-09T10:42:45+01:00 New Revision: e67cbac81211d40332a79d98c9d5953624cc1202 URL: https://github.com/llvm/llvm-project/commit/e67cbac81211d40332a79d98c9d5953624cc1202 DIFF: https://github.com/llvm/llvm-project/commit/e67cbac81211d40332a79d98c9d5953624cc1202.diff LOG: Support -fstack-clash-protection for x86 Implement protection against the stack clash attack [0] through inline stack probing. Probe stack allocation every PAGE_SIZE during frame lowering or dynamic allocation to make sure the page guard, if any, is touched when touching the stack, in a similar manner to GCC[1]. This extends the existing `probe-stack' mechanism with a special value `inline-asm'. Technically the former uses function call before stack allocation while this patch provides inlined stack probes and chunk allocation. Only implemented for x86. [0] https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt [1] https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00556.html This a recommit of 39f50da2a357a8f685b3540246c5d762734e035f with proper LiveIn declaration, better option handling and more portable testing. Differential Revision: https://reviews.llvm.org/D68720 Added: clang/test/CodeGen/stack-clash-protection.c clang/test/Driver/stack-clash-protection.c llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll llvm/test/CodeGen/X86/stack-clash-large.ll llvm/test/CodeGen/X86/stack-clash-medium-natural-probes-mutliple-objects.ll llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll llvm/test/CodeGen/X86/stack-clash-medium.ll llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll llvm/test/CodeGen/X86/stack-clash-small.ll llvm/test/CodeGen/X86/stack-clash-unknown-call.ll Modified: clang/docs/ClangCommandLineReference.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Basic/DiagnosticCommonKinds.td clang/include/clang/Basic/TargetInfo.h clang/include/clang/Driver/Options.td clang/lib/Basic/Targets/X86.h clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/docs/ReleaseNotes.rst llvm/include/llvm/CodeGen/TargetLowering.h llvm/lib/Target/X86/X86CallFrameOptimization.cpp llvm/lib/Target/X86/X86FrameLowering.cpp llvm/lib/Target/X86/X86FrameLowering.h llvm/lib/Target/X86/X86ISelLowering.cpp llvm/lib/Target/X86/X86ISelLowering.h llvm/lib/Target/X86/X86InstrCompiler.td llvm/lib/Target/X86/X86InstrInfo.td Removed: diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index 24c8ee2bc9ef..609e7fa66c00 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -1917,6 +1917,10 @@ Use a strong heuristic to apply stack protectors to functions Emit section containing metadata on function stack sizes +.. option:: -fstack-clash-protection, -fno-stack-clash-protection + +Instrument stack allocation to prevent stack clash attacks (x86, non-Windows only). + .. option:: -fstandalone-debug, -fno-limit-debug-info, -fno-standalone-debug Emit full debug info for all types used by the program diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index e957550a93cc..d24cd85673c6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -61,6 +61,10 @@ New Compiler Flags -- +- -fstack-clash-protection will provide a protection against the stack clash + attack for x86 architecture through automatic probing of each page of + allocated stack. + Deprecated Compiler Flags - diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 21e391912584..48c0df49e32d 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -150,6 +150,7 @@ CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled. CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled. CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain ///< inline line tables. +CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection is enabled. CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled. CODEGENOPT(NoInfsFPMath , 1, 0) ///< Assume FP arguments, results not +-Inf. CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP zero diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td index 20b49605eb6f..95cb81f09922 100644 --- a/clang/include/clang/Basic/DiagnosticCommonKinds.td +++
[clang] 4546211 - Revert "Support -fstack-clash-protection for x86"
Author: serge-sans-paille Date: 2020-02-09T10:06:31+01:00 New Revision: 454621160066c067c97edb0a094553d8d0339c9b URL: https://github.com/llvm/llvm-project/commit/454621160066c067c97edb0a094553d8d0339c9b DIFF: https://github.com/llvm/llvm-project/commit/454621160066c067c97edb0a094553d8d0339c9b.diff LOG: Revert "Support -fstack-clash-protection for x86" This reverts commit 0fd51a4554f5f4f90342f40afd35b077f6d88213. Failures: http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/4354 Added: Modified: clang/docs/ClangCommandLineReference.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Basic/DiagnosticCommonKinds.td clang/include/clang/Basic/TargetInfo.h clang/include/clang/Driver/Options.td clang/lib/Basic/Targets/X86.h clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/docs/ReleaseNotes.rst llvm/include/llvm/CodeGen/TargetLowering.h llvm/lib/Target/X86/X86CallFrameOptimization.cpp llvm/lib/Target/X86/X86FrameLowering.cpp llvm/lib/Target/X86/X86FrameLowering.h llvm/lib/Target/X86/X86ISelLowering.cpp llvm/lib/Target/X86/X86ISelLowering.h llvm/lib/Target/X86/X86InstrCompiler.td llvm/lib/Target/X86/X86InstrInfo.td Removed: clang/test/CodeGen/stack-clash-protection.c clang/test/Driver/stack-clash-protection.c llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll llvm/test/CodeGen/X86/stack-clash-large.ll llvm/test/CodeGen/X86/stack-clash-medium-natural-probes-mutliple-objects.ll llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll llvm/test/CodeGen/X86/stack-clash-medium.ll llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll llvm/test/CodeGen/X86/stack-clash-small.ll llvm/test/CodeGen/X86/stack-clash-unknown-call.ll diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index 609e7fa66c00..24c8ee2bc9ef 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -1917,10 +1917,6 @@ Use a strong heuristic to apply stack protectors to functions Emit section containing metadata on function stack sizes -.. option:: -fstack-clash-protection, -fno-stack-clash-protection - -Instrument stack allocation to prevent stack clash attacks (x86, non-Windows only). - .. option:: -fstandalone-debug, -fno-limit-debug-info, -fno-standalone-debug Emit full debug info for all types used by the program diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index d24cd85673c6..e957550a93cc 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -61,10 +61,6 @@ New Compiler Flags -- -- -fstack-clash-protection will provide a protection against the stack clash - attack for x86 architecture through automatic probing of each page of - allocated stack. - Deprecated Compiler Flags - diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 48c0df49e32d..21e391912584 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -150,7 +150,6 @@ CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled. CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled. CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain ///< inline line tables. -CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection is enabled. CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled. CODEGENOPT(NoInfsFPMath , 1, 0) ///< Assume FP arguments, results not +-Inf. CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP zero diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td index 95cb81f09922..20b49605eb6f 100644 --- a/clang/include/clang/Basic/DiagnosticCommonKinds.td +++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td @@ -239,10 +239,6 @@ def note_invalid_subexpr_in_const_expr : Note< let CategoryName = "Inline Assembly Issue" in { def err_asm_invalid_type_in_input : Error< "invalid type %0 in asm input for constraint '%1'">; - - def warn_stack_clash_protection_inline_asm : Warning< -"Unable to protect inline asm that clobbers stack pointer against stack clash">, -InGroup>; } // Sema && Serialization diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index cb5aabdc468f..3a8e35524695 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@
[PATCH] D72730: [clang-tidy] run-clang-tidy -export-fixes exports only fixes, not all warnings
AlexanderLanin added a comment. On second thought maybe this should be fixed in clang-tidy and not here? Maybe besides `-export-fixes` there should be an `-export-warnings` or just `-yaml-export`? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D72730/new/ https://reviews.llvm.org/D72730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0fd51a4 - Support -fstack-clash-protection for x86
Author: serge_sans_paille Date: 2020-02-09T09:35:42+01:00 New Revision: 0fd51a4554f5f4f90342f40afd35b077f6d88213 URL: https://github.com/llvm/llvm-project/commit/0fd51a4554f5f4f90342f40afd35b077f6d88213 DIFF: https://github.com/llvm/llvm-project/commit/0fd51a4554f5f4f90342f40afd35b077f6d88213.diff LOG: Support -fstack-clash-protection for x86 Implement protection against the stack clash attack [0] through inline stack probing. Probe stack allocation every PAGE_SIZE during frame lowering or dynamic allocation to make sure the page guard, if any, is touched when touching the stack, in a similar manner to GCC[1]. This extends the existing `probe-stack' mechanism with a special value `inline-asm'. Technically the former uses function call before stack allocation while this patch provides inlined stack probes and chunk allocation. Only implemented for x86. [0] https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt [1] https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00556.html This a recommit of 39f50da2a357a8f685b3540246c5d762734e035f with proper LiveIn declaration, better option handling and more portable testing. Differential Revision: https://reviews.llvm.org/D68720 Added: clang/test/CodeGen/stack-clash-protection.c clang/test/Driver/stack-clash-protection.c llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll llvm/test/CodeGen/X86/stack-clash-large.ll llvm/test/CodeGen/X86/stack-clash-medium-natural-probes-mutliple-objects.ll llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll llvm/test/CodeGen/X86/stack-clash-medium.ll llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll llvm/test/CodeGen/X86/stack-clash-small.ll llvm/test/CodeGen/X86/stack-clash-unknown-call.ll Modified: clang/docs/ClangCommandLineReference.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Basic/DiagnosticCommonKinds.td clang/include/clang/Basic/TargetInfo.h clang/include/clang/Driver/Options.td clang/lib/Basic/Targets/X86.h clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/docs/ReleaseNotes.rst llvm/include/llvm/CodeGen/TargetLowering.h llvm/lib/Target/X86/X86CallFrameOptimization.cpp llvm/lib/Target/X86/X86FrameLowering.cpp llvm/lib/Target/X86/X86FrameLowering.h llvm/lib/Target/X86/X86ISelLowering.cpp llvm/lib/Target/X86/X86ISelLowering.h llvm/lib/Target/X86/X86InstrCompiler.td llvm/lib/Target/X86/X86InstrInfo.td Removed: diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index 24c8ee2bc9ef..609e7fa66c00 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -1917,6 +1917,10 @@ Use a strong heuristic to apply stack protectors to functions Emit section containing metadata on function stack sizes +.. option:: -fstack-clash-protection, -fno-stack-clash-protection + +Instrument stack allocation to prevent stack clash attacks (x86, non-Windows only). + .. option:: -fstandalone-debug, -fno-limit-debug-info, -fno-standalone-debug Emit full debug info for all types used by the program diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index e957550a93cc..d24cd85673c6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -61,6 +61,10 @@ New Compiler Flags -- +- -fstack-clash-protection will provide a protection against the stack clash + attack for x86 architecture through automatic probing of each page of + allocated stack. + Deprecated Compiler Flags - diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 21e391912584..48c0df49e32d 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -150,6 +150,7 @@ CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled. CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled. CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain ///< inline line tables. +CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection is enabled. CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled. CODEGENOPT(NoInfsFPMath , 1, 0) ///< Assume FP arguments, results not +-Inf. CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP zero diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td index 20b49605eb6f..95cb81f09922 100644 --- a/clang/include/clang/Basic/DiagnosticCommonKinds.td +++