Index: include/clang/Basic/Attr.td =================================================================== --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -1769,10 +1769,16 @@ // overall feature validity for the function with the rest of the // attributes on the function. if (Feature.startswith("fpmath=") || Feature.startswith("tune=")) - continue; - + continue; + + // Convert GNU target names for arm and thumb to thumb-mode target + // feature. + if (Feature.compare("arm") == 0) + Ret.first.push_back("-thumb-mode"); + else if (Feature.compare("thumb") == 0) + Ret.first.push_back("+thumb-mode"); // While we're here iterating check for a different target cpu. - if (Feature.startswith("arch=")) + else if (Feature.startswith("arch=")) Ret.second = Feature.split("=").second.trim(); else if (Feature.startswith("no-")) Ret.first.push_back("-" + Feature.split("-").second.str()); Index: test/CodeGen/arm-target-attr.c =================================================================== --- /dev/null +++ test/CodeGen/arm-target-attr.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck %s + +__attribute__((target("arm"))) void test_target_arm() { + // CHECK: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]] +} + +__attribute__((target("thumb"))) void test_target_thumb() { + // CHECK: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]] +} + +// CHECK: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}" +// CHECK: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}"