[clang] 7406eb4 - [Hexagon] Avoid creating an empty target feature

Krzysztof Parzyszek via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 10 08:37:42 PDT 2020


Author: Krzysztof Parzyszek
Date: 2020-08-10T10:37:24-05:00
New Revision: 7406eb4f6afd8df9bd4dbb918f5e7005ba71d58c

URL: https://github.com/llvm/llvm-project/commit/7406eb4f6afd8df9bd4dbb918f5e7005ba71d58c
DIFF: https://github.com/llvm/llvm-project/commit/7406eb4f6afd8df9bd4dbb918f5e7005ba71d58c.diff

LOG: [Hexagon] Avoid creating an empty target feature

If the CPU string is empty, the target feature map may end up having
an empty string inserted to it. The symptom of the problem is a warning
message:
  '+' is not a recognized feature for this target (ignoring feature)
Also, the target-features attribute in the module will have an empty
string in it.

Added: 
    clang/test/CodeGen/hexagon-empty-cpu-feature.c

Modified: 
    clang/lib/Basic/Targets/Hexagon.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/Hexagon.cpp b/clang/lib/Basic/Targets/Hexagon.cpp
index 205601c359d0..a8b4380b6a87 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -98,7 +98,8 @@ bool HexagonTargetInfo::initFeatureMap(
   StringRef CPUFeature = CPU;
   CPUFeature.consume_front("hexagon");
   CPUFeature.consume_back("t");
-  Features[CPUFeature] = true;
+  if (!CPUFeature.empty())
+    Features[CPUFeature] = true;
 
   Features["long-calls"] = false;
 

diff  --git a/clang/test/CodeGen/hexagon-empty-cpu-feature.c b/clang/test/CodeGen/hexagon-empty-cpu-feature.c
new file mode 100644
index 000000000000..3a9e5a80118f
--- /dev/null
+++ b/clang/test/CodeGen/hexagon-empty-cpu-feature.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -triple hexagon-unknown-elf -emit-llvm -o - 2>&1 | FileCheck %s
+// CHECK-NOT: '+' is not a recognized feature for this target
+
+// Empty


        


More information about the cfe-commits mailing list