[PATCH] Do not store "+soft-float" and "+soft-float-abi" target features in function attributes

Oliver Stannard oliver.stannard at arm.com
Wed Apr 1 07:47:06 PDT 2015


Hi echristo,

These target features are used by the clang driver when targeting ARM and MIPS, but cc1 strips them out and they are not valid backend features. Therefore, we should not store them in the function attributes.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8771

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGen/function-target-features.c

Index: lib/CodeGen/CGCall.cpp
===================================================================
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1490,11 +1490,16 @@
         getTarget().getTargetOpts().FeaturesAsWritten;
     if (!Features.empty()) {
       std::stringstream S;
-      std::copy(Features.begin(), Features.end(),
-                std::ostream_iterator<std::string>(S, ","));
+      // The "+soft-float" and "+soft-float-abi" features are not real target
+      // features, and should not be passed to the backend.
+      std::copy_if(Features.begin(), Features.end(),
+                   std::ostream_iterator<std::string>(S, ","),
+                   [](const std::string& name) {
+                     return (name != "+soft-float") && (name != "+soft-float-abi");
+                   });
       // The drop_back gets rid of the trailing space.
-      FuncAttrs.addAttribute("target-features",
-                             StringRef(S.str()).drop_back(1));
+      if (!S.str().empty())
+        FuncAttrs.addAttribute("target-features", StringRef(S.str()).drop_back(1));
     }
   }
 
Index: test/CodeGen/function-target-features.c
===================================================================
--- test/CodeGen/function-target-features.c
+++ test/CodeGen/function-target-features.c
@@ -9,6 +9,8 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7 -target-feature +avx | FileCheck %s -check-prefix=CORE-CPU-AND-FEATURES
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu x86-64 | FileCheck %s -check-prefix=X86-64-CPU-NOT
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7-avx -target-feature -avx | FileCheck %s -check-prefix=AVX-MINUS-FEATURE
+// RUN: %clang_cc1 -triple armv7-none-eabi -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=ARM-SOFT-FLOAT
+// RUN: %clang_cc1 -triple armv7-none-eabi -emit-llvm -o - %s -target-feature +soft-float-abi | FileCheck %s -check-prefix=ARM-SOFT-FLOAT-ABI
 
 void foo() {}
 
@@ -19,3 +21,5 @@
 // CORE-CPU-AND-FEATURES: "target-cpu"="corei7" "target-features"="+avx"
 // X86-64-CPU-NOT: "target-cpu"
 // AVX-MINUS-FEATURE: "target-features"="-avx"
+// ARM-SOFT-FLOAT-NOT: "target-features"
+// ARM-SOFT-FLOAT-ABI-NOT: "target-features"

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8771.23051.patch
Type: text/x-patch
Size: 2349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150401/4f2d8ffc/attachment.bin>


More information about the cfe-commits mailing list