[clang] 424e850 - [clang][ARM] Re-word PACBTI warning.

2022-02-08 Thread Amilendra Kodithuwakku via cfe-commits

Author: Amilendra Kodithuwakku
Date: 2022-02-08T19:13:02Z
New Revision: 424e850f1ebc3e7011cb4af44cb2d62c02a58fbe

URL: 
https://github.com/llvm/llvm-project/commit/424e850f1ebc3e7011cb4af44cb2d62c02a58fbe
DIFF: 
https://github.com/llvm/llvm-project/commit/424e850f1ebc3e7011cb4af44cb2d62c02a58fbe.diff

LOG: [clang][ARM] Re-word PACBTI warning.

The original warning added in D115501 when pacbti is used with an
incompatible architecture was not exactly correct because it was
not really ignored and can affect codegen.

Therefore reword to say that the pacbti option is incompatible with
the given architecture.

Reviewed By: chill

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/arm-security-options.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 5ea55b0fd31ba..421527827a4bd 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -145,8 +145,8 @@ def 
warn_conflicting_nullability_attr_overriding_param_types : Warning<
 def err_nullability_conflicting : Error<
   "nullability specifier %0 conflicts with existing specifier %1">;
 
-def warn_target_unsupported_branch_protection_option: Warning <
-  "ignoring '-mbranch-protection=' option because the '%0' architecture does 
not support it">,
+def warn_incompatible_branch_protection_option: Warning <
+  "'-mbranch-protection=' option is incompatible with the '%0' architecture">,
   InGroup;
 
 def warn_target_unsupported_branch_protection_attribute: Warning <

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index cfeb965f99e2f..ddc9926aef87a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1639,7 +1639,7 @@ static void CollectARMPACBTIOptions(const ToolChain &TC, 
const ArgList &Args,
   const Driver &D = TC.getDriver();
   const llvm::Triple &Triple = TC.getEffectiveTriple();
   if (!(isAArch64 || (Triple.isArmT32() && Triple.isArmMClass(
-D.Diag(diag::warn_target_unsupported_branch_protection_option)
+D.Diag(diag::warn_incompatible_branch_protection_option)
 << Triple.getArchName();
 
   StringRef Scope, Key;

diff  --git a/clang/test/Driver/arm-security-options.c 
b/clang/test/Driver/arm-security-options.c
index 79367d7bbb965..fc1b5da78d2cf 100644
--- a/clang/test/Driver/arm-security-options.c
+++ b/clang/test/Driver/arm-security-options.c
@@ -90,4 +90,4 @@
 // BAD-B-KEY-COMBINATION: invalid branch protection option 'b-key' in 
'-mbranch-protection={{.*}}'
 // BAD-LEAF-COMBINATION: invalid branch protection option 'leaf' in 
'-mbranch-protection={{.*}}'
 
-// INCOMPATIBLE-ARCH: ignoring '-mbranch-protection=' option because the 
'{{.*}}' architecture does not support it
+// INCOMPATIBLE-ARCH: '-mbranch-protection=' option is incompatible with the 
'{{.*}}' architecture



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


[libunwind] 5636402 - [libcxx] Fix exception raised during downstream bare-metal libunwind tests

2021-06-16 Thread Amilendra Kodithuwakku via cfe-commits

Author: Amilendra Kodithuwakku
Date: 2021-06-16T13:35:36+01:00
New Revision: 5636402bc0c92eec2faf46edb0fb733d78fa259e

URL: 
https://github.com/llvm/llvm-project/commit/5636402bc0c92eec2faf46edb0fb733d78fa259e
DIFF: 
https://github.com/llvm/llvm-project/commit/5636402bc0c92eec2faf46edb0fb733d78fa259e.diff

LOG: [libcxx] Fix exception raised during downstream bare-metal libunwind tests

Fix for the following exception.

AttributeError: 'TestingConfig' object has no attribute 'target_triple'

Related revision: https://reviews.llvm.org/D102012

'TestingConfig' object has no attribute 'target_triple'

Reviewed By: #libunwind, miyuki, danielkiss, mstorsjo

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

Added: 


Modified: 
libunwind/test/libunwind/test/config.py

Removed: 




diff  --git a/libunwind/test/libunwind/test/config.py 
b/libunwind/test/libunwind/test/config.py
index e3e1dfcaed88a..b3f12bfe403c4 100644
--- a/libunwind/test/libunwind/test/config.py
+++ b/libunwind/test/libunwind/test/config.py
@@ -44,7 +44,8 @@ def configure_compile_flags(self):
 # generated by default on all Targets.
 self.cxx.compile_flags += ['-funwind-tables']
 # Make symbols available in the tests.
-if 'linux' in self.config.target_triple:
+triple = self.get_lit_conf('target_triple', None)
+if 'linux' in triple:
 self.cxx.link_flags += ['-Wl,--export-dynamic']
 if not self.get_lit_bool('enable_threads', True):
 self.cxx.compile_flags += ['-D_LIBUNWIND_HAS_NO_THREADS']



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


[clang] 1f08b08 - [clang][ARM] Emit warnings when PACBTI-M is used with unsupported architectures

2022-01-28 Thread Amilendra Kodithuwakku via cfe-commits

Author: Amilendra Kodithuwakku
Date: 2022-01-28T09:59:58Z
New Revision: 1f08b0867412d5696ed624a2da78bdba2cc672c3

URL: 
https://github.com/llvm/llvm-project/commit/1f08b0867412d5696ed624a2da78bdba2cc672c3
DIFF: 
https://github.com/llvm/llvm-project/commit/1f08b0867412d5696ed624a2da78bdba2cc672c3.diff

LOG: [clang][ARM] Emit warnings when PACBTI-M is used with unsupported 
architectures

Branch protection in M-class is supported by
 - Armv8.1-M.Main
 - Armv8-M.Main
 - Armv7-M

Attempting to enable this for other architectures, either by
command-line (e.g -mbranch-protection=bti) or by target attribute
in source code (e.g.  __attribute__((target("branch-protection=..."))) )
will generate a warning.

In both cases function attributes related to branch protection will not
be emitted. Regardless of the warning, module level attributes related to
branch protection will be emitted when it is enabled via the command-line.

The following people also contributed to this patch:
- Victor Campos

Reviewed By: chill

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

Added: 
clang/test/Frontend/arm-branch-protection-default-arch.c
clang/test/Frontend/arm-ignore-branch-protection-option.c
clang/test/Sema/arm-branch-protection-attr-warn.c
clang/test/Sema/arm-branch-protection.c

Modified: 
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Basic/Targets/ARM.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGen/arm-branch-protection-attr-2.c
clang/test/CodeGen/arm_acle.c
clang/test/Driver/aarch64-security-options.c
clang/test/Driver/arm-security-options.c
clang/test/Frontend/arm-invalid-branch-protection.c
llvm/include/llvm/ADT/Triple.h
llvm/unittests/ADT/TripleTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index fe4ac5ed6cb03..5ea55b0fd31ba 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -145,6 +145,13 @@ def 
warn_conflicting_nullability_attr_overriding_param_types : Warning<
 def err_nullability_conflicting : Error<
   "nullability specifier %0 conflicts with existing specifier %1">;
 
+def warn_target_unsupported_branch_protection_option: Warning <
+  "ignoring '-mbranch-protection=' option because the '%0' architecture does 
not support it">,
+  InGroup;
+
+def warn_target_unsupported_branch_protection_attribute: Warning <
+  "ignoring the 'branch-protection' attribute because the '%0' architecture 
does not support it">,
+  InGroup;
 }
 
 // OpenCL Section 6.8.g

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 686a365b8c12d..642c8500364bb 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1289,9 +1289,15 @@ class TargetInfo : public virtual 
TransferrableTargetInfo,
 bool BranchTargetEnforcement = false;
   };
 
+  /// Determine if the Architecture in this TargetInfo supports branch
+  /// protection
+  virtual bool isBranchProtectionSupportedArch(StringRef Arch) const {
+return false;
+  }
+
   /// Determine if this TargetInfo supports the given branch protection
   /// specification
-  virtual bool validateBranchProtection(StringRef Spec,
+  virtual bool validateBranchProtection(StringRef Spec, StringRef Arch,
 BranchProtectionInfo &BPI,
 StringRef &Err) const {
 Err = "";

diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 8e23cc4c421a5..34bdb58dffc1c 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -138,7 +138,7 @@ bool AArch64TargetInfo::setABI(const std::string &Name) {
   return true;
 }
 
-bool AArch64TargetInfo::validateBranchProtection(StringRef Spec,
+bool AArch64TargetInfo::validateBranchProtection(StringRef Spec, StringRef,
  BranchProtectionInfo &BPI,
  StringRef &Err) const {
   llvm::ARM::ParsedBranchProtection PBP;

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index ebddce0c1c73e..9e22aeaff251f 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -70,8 +70,9 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   StringRef getABI() const override;
   bool setABI(const std::string &Name) override;
 
-  bool validateBranchProtection(StringRe