lkail created this revision. lkail added reviewers: PowerPC, hfinkel, jonpa, serge-sans-paille. Herald added subscribers: cfe-commits, shchenz, kbarton, nemanjai. Herald added a project: clang.
Open `-fstack-clash-protection` option in clang for ppc64 arch. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D81355 Files: clang/docs/ReleaseNotes.rst clang/lib/Basic/Targets/PPC.h clang/lib/Driver/ToolChains/Clang.cpp clang/test/CodeGen/stack-clash-protection.c Index: clang/test/CodeGen/stack-clash-protection.c =================================================================== --- clang/test/CodeGen/stack-clash-protection.c +++ clang/test/CodeGen/stack-clash-protection.c @@ -1,6 +1,8 @@ // Check the correct function attributes are generated // RUN: %clang_cc1 -triple x86_64-linux -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s // RUN: %clang_cc1 -triple s390x-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s +// RUN: %clang_cc1 -triple powerpc64le-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s +// RUN: %clang_cc1 -triple powerpc64-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s // CHECK: define void @large_stack() #[[A:.*]] { void large_stack() { Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -2999,7 +2999,8 @@ if (!EffectiveTriple.isOSLinux()) return; - if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ()) + if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() && + !EffectiveTriple.isPPC64()) return; if (Args.hasFlag(options::OPT_fstack_clash_protection, Index: clang/lib/Basic/Targets/PPC.h =================================================================== --- clang/lib/Basic/Targets/PPC.h +++ clang/lib/Basic/Targets/PPC.h @@ -342,6 +342,10 @@ const char *getFloat128Mangling() const override { return "u9__ieee128"; } bool hasExtIntType() const override { return true; } + + bool isSPRegName(StringRef RegName) const override { + return RegName.equals("r1") || RegName.equals("x1"); + } }; class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public PPCTargetInfo { Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -94,8 +94,8 @@ ------------------ - -fstack-clash-protection will provide a protection against the stack clash - attack for x86 and s390x architectures through automatic probing of each page - of allocated stack. + attack for x86, s390x and ppc64 architectures through automatic + probing of each page of allocated stack. - -ffp-exception-behavior={ignore,maytrap,strict} allows the user to specify the floating-point exception behavior. The default setting is ``ignore``.
Index: clang/test/CodeGen/stack-clash-protection.c =================================================================== --- clang/test/CodeGen/stack-clash-protection.c +++ clang/test/CodeGen/stack-clash-protection.c @@ -1,6 +1,8 @@ // Check the correct function attributes are generated // RUN: %clang_cc1 -triple x86_64-linux -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s // RUN: %clang_cc1 -triple s390x-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s +// RUN: %clang_cc1 -triple powerpc64le-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s +// RUN: %clang_cc1 -triple powerpc64-linux-gnu -O0 -S -emit-llvm -o- %s -fstack-clash-protection | FileCheck %s // CHECK: define void @large_stack() #[[A:.*]] { void large_stack() { Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -2999,7 +2999,8 @@ if (!EffectiveTriple.isOSLinux()) return; - if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ()) + if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() && + !EffectiveTriple.isPPC64()) return; if (Args.hasFlag(options::OPT_fstack_clash_protection, Index: clang/lib/Basic/Targets/PPC.h =================================================================== --- clang/lib/Basic/Targets/PPC.h +++ clang/lib/Basic/Targets/PPC.h @@ -342,6 +342,10 @@ const char *getFloat128Mangling() const override { return "u9__ieee128"; } bool hasExtIntType() const override { return true; } + + bool isSPRegName(StringRef RegName) const override { + return RegName.equals("r1") || RegName.equals("x1"); + } }; class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public PPCTargetInfo { Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -94,8 +94,8 @@ ------------------ - -fstack-clash-protection will provide a protection against the stack clash - attack for x86 and s390x architectures through automatic probing of each page - of allocated stack. + attack for x86, s390x and ppc64 architectures through automatic + probing of each page of allocated stack. - -ffp-exception-behavior={ignore,maytrap,strict} allows the user to specify the floating-point exception behavior. The default setting is ``ignore``.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits