[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp
This revision was automatically updated to reflect the committed changes. Closed by commit rL309257: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp (authored by psmith). Changed prior to commit: https://reviews.llvm.org/D35538?vs=108245=108436#toc Repository: rL LLVM https://reviews.llvm.org/D35538 Files: cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGen/arm-float-helpers.c cfe/trunk/test/CodeGen/complex-math.c Index: cfe/trunk/test/CodeGen/arm-float-helpers.c === --- cfe/trunk/test/CodeGen/arm-float-helpers.c +++ cfe/trunk/test/CodeGen/arm-float-helpers.c @@ -0,0 +1,233 @@ +// REQUIRES: arm-registered-target +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabihf %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" -target-feature "+soft-float-abi" %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -meabi gnu %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -target-feature "+soft-float-abi" -meabi gnu %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -meabi gnu %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf -meabi gnu %s | FileCheck %s + +// The Runtime ABI for the ARM Architecture IHI0043 section 4.1.2 The +// floating-point helper functions to always use the base AAPCS (soft-float) +// calling convention. +// +// These helper functions such as __aeabi_fadd are not explicitly called by +// clang, instead they are generated by the ARMISelLowering when they are +// needed; clang relies on llvm to use the base AAPCS. +// +// In this test we check that clang is not directly calling the __aeabi_ +// functions. We rely on llvm to test that the base AAPCS is used for any +// __aeabi_ function from 4.1.2 that is used. +// +// When compiled to an object file with -mfloat-abi=soft each function F +// below should result in a call to __aeabi_F. If clang is changed to call any +// of these functions directly the test will need to be altered to check that +// arm_aapcscc is used. +// +// Note that it is only the functions in 4.1.2 that must use the base AAPCS, +// other runtime functions such as the _Complex helper routines are not covered. + +float fadd(float a, float b) { return a + b; } +// CHECK-LABEL: define float @fadd(float %a, float %b) +// CHECK-NOT: __aeabi_fadd +// CHECK: %add = fadd float %0, %1 + +float fdiv(float a, float b) { return a / b; } +// CHECK-LABEL: define float @fdiv(float %a, float %b) +// CHECK-NOT: __aeabi_fdiv +// CHECK: %div = fdiv float %0, %1 + +float fmul(float a, float b) { return a * b; } +// CHECK-LABEL: define float @fmul(float %a, float %b) +// CHECK-NOT: __aeabi_fmul +// CHECK: %mul = fmul float %0, %1 + +float fsub(float a, float b) { return a - b; } +// CHECK-LABEL: define float @fsub(float %a, float %b) +// CHECK-NOT: __aeabi_fsub +// CHECK: %sub = fsub float %0, %1 + +int fcmpeq(float a, float b) { return a == b; } +// CHECK-LABEL: define i32 @fcmpeq(float %a, float %b) +// CHECK-NOT: __aeabi_fcmpeq +// CHECK: %cmp = fcmp oeq float %0, %1 + +int fcmplt(float a, float b) { return a < b; } +// CHECK-LABEL: define i32 @fcmplt(float %a, float %b) +// CHECK-NOT: __aeabi_fcmplt +// CHECK: %cmp = fcmp olt float %0, %1 + +int fcmple(float a, float b) { return a <= b; } +// CHECK-LABEL: define i32 @fcmple(float %a, float %b) +// CHECK-NOT: __aeabi_fcmple +// CHECK: %cmp = fcmp ole float %0, %1 + +int fcmpge(float a, float b) { return a >= b; } +// CHECK-LABEL: define i32 @fcmpge(float %a, float %b) +// CHECK-NOT: __aeabi_fcmpge +// CHECK: %cmp = fcmp oge float %0, %1 + +int fcmpgt(float a, float b) { return a > b; } +// CHECK-LABEL: define i32 @fcmpgt(float %a, float %b) +// CHECK-NOT: __aeabi_fcmpgt +// CHECK: %cmp = fcmp ogt float %0, %1 + +int fcmpun(float a, float b) { return __builtin_isunordered(a, b); } +// CHECK-LABEL: define i32 @fcmpun(float %a, float %b) +// CHECK-NOT: __aeabi_fcmpun +// CHECK: %cmp = fcmp uno double %conv, %conv1 + +double dadd(double a, double b) { return a + b; } +// CHECK-LABEL: define double @dadd(double %a, double %b) +// CHECK-NOT: __aeabi_dadd +// CHECK: %add = fadd double %0, %1 + +double ddiv(double a, double b) { return a / b; } +// CHECK-LABEL: define double @ddiv(double %a, double %b) +// CHECK-NOT: __aeabi_ddiv +// CHECK: %div = fdiv double %0, %1 + +double dmul(double a,
[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp
peter.smith added a comment. I've created https://reviews.llvm.org/D35904 to cover adding a test for LLVMs use of the runtime helper functions. https://reviews.llvm.org/D35538 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp
peter.smith updated this revision to Diff 108245. peter.smith added a comment. Thanks both for the comments, I've added the missing punctuation and have expanded the tests so that we anchor the check to the function and check for the operation that will be lowered by the back-end. https://reviews.llvm.org/D35538 Files: lib/CodeGen/TargetInfo.cpp test/CodeGen/arm-float-helpers.c test/CodeGen/complex-math.c Index: test/CodeGen/complex-math.c === --- test/CodeGen/complex-math.c +++ test/CodeGen/complex-math.c @@ -2,7 +2,8 @@ // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC -// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARM +// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM +// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K float _Complex add_float_rr(float a, float b) { @@ -476,8 +477,15 @@ // Check that the libcall will obtain proper calling convention on ARM _Complex double foo(_Complex double a, _Complex double b) { + // These functions are not defined as floating point helper functions in + // Run-time ABI for the ARM architecture document so they must not always + // use the base AAPCS. + // ARM-LABEL: @foo( - // ARM: call arm_aapcscc { double, double } @__muldc3 + // ARM: call void { double, double } @__muldc3 + + // ARMHF-LABEL: @foo( + // ARMHF: call { double, double } @__muldc3 // ARM7K-LABEL: @foo( // ARM7K: call { double, double } @__muldc3 Index: test/CodeGen/arm-float-helpers.c === --- /dev/null +++ test/CodeGen/arm-float-helpers.c @@ -0,0 +1,233 @@ +// REQUIRES: arm-registered-target +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabihf %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" -target-feature "+soft-float-abi" %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -meabi gnu %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -target-feature "+soft-float-abi" -meabi gnu %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -meabi gnu %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf -meabi gnu %s | FileCheck %s + +// The Runtime ABI for the ARM Architecture IHI0043 section 4.1.2 The +// floating-point helper functions to always use the base AAPCS (soft-float) +// calling convention. +// +// These helper functions such as __aeabi_fadd are not explicitly called by +// clang, instead they are generated by the ARMISelLowering when they are +// needed; clang relies on llvm to use the base AAPCS. +// +// In this test we check that clang is not directly calling the __aeabi_ +// functions. We rely on llvm to test that the base AAPCS is used for any +// __aeabi_ function from 4.1.2 that is used. +// +// When compiled to an object file with -mfloat-abi=soft each function F +// below should result in a call to __aeabi_F. If clang is changed to call any +// of these functions directly the test will need to be altered to check that +// arm_aapcscc is used. +// +// Note that it is only the functions in 4.1.2 that must use the base AAPCS, +// other runtime functions such as the _Complex helper routines are not covered. + +float fadd(float a, float b) { return a + b; } +// CHECK-LABEL: define float @fadd(float %a, float %b) +// CHECK-NOT: __aeabi_fadd +// CHECK: %add = fadd float %0, %1 + +float fdiv(float a, float b) { return a / b; } +// CHECK-LABEL: define float @fdiv(float %a, float %b) +// CHECK-NOT: __aeabi_fdiv +// CHECK: %div = fdiv float %0, %1 + +float fmul(float a, float b) { return a * b; } +// CHECK-LABEL: define float @fmul(float %a, float %b) +// CHECK-NOT: __aeabi_fmul +// CHECK: %mul = fmul float %0, %1 + +float fsub(float a, float b) { return a - b; } +// CHECK-LABEL: define float @fsub(float %a,
[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp
majnemer added inline comments. Comment at: lib/CodeGen/TargetInfo.cpp:5625 + // The Run-time ABI for the ARM Architecture section 4.1.2 requires + // AEABI-complying FP helper functions to use the base AAPCS + // These AEABI functions are expanded in the ARM llvm backend, all the builtin Period at the end of a sentence. Comment at: test/CodeGen/arm-float-helpers.c:32 +// Note that it is only the functions in 4.1.2 that must use the base AAPCS, +// other runtime functions such as the _Complex helper routines are not covered + Ditto. Comment at: test/CodeGen/complex-math.c:482 + // Run-time ABI for the ARM architecture document so they must not always + // use the base AAPCS + Ditto. https://reviews.llvm.org/D35538 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp
compnerd added a comment. I think that the approach is reasonable. However, the test needs tweaking. The function and the call both are ambiguous in the match. Can you match the call sequence? Or explicitly the local label and then the call. https://reviews.llvm.org/D35538 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp
peter.smith updated this revision to Diff 108092. peter.smith added a comment. Herald added a subscriber: javed.absar. I've added a clang test that will check that none of the floating point helper functions defined in the Runtime ABI for the ARM Architecture are directly called by clang. Given that the calling convention decisions for these helpers are made in llvm I think the best place for a test that the correct calling convention is in llvm. I'll start working on that and post in a separate review. Please let me know if I'm not on the right lines. https://reviews.llvm.org/D35538 Files: lib/CodeGen/TargetInfo.cpp test/CodeGen/arm-float-helpers.c test/CodeGen/complex-math.c Index: test/CodeGen/complex-math.c === --- test/CodeGen/complex-math.c +++ test/CodeGen/complex-math.c @@ -2,7 +2,8 @@ // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC -// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARM +// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM +// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K float _Complex add_float_rr(float a, float b) { @@ -476,8 +477,15 @@ // Check that the libcall will obtain proper calling convention on ARM _Complex double foo(_Complex double a, _Complex double b) { + // These functions are not defined as floating point helper functions in + // Run-time ABI for the ARM architecture document so they must not always + // use the base AAPCS + // ARM-LABEL: @foo( - // ARM: call arm_aapcscc { double, double } @__muldc3 + // ARM: call void { double, double } @__muldc3 + + // ARMHF-LABEL: @foo( + // ARMHF: call { double, double } @__muldc3 // ARM7K-LABEL: @foo( // ARM7K: call { double, double } @__muldc3 Index: test/CodeGen/arm-float-helpers.c === --- /dev/null +++ test/CodeGen/arm-float-helpers.c @@ -0,0 +1,195 @@ +// REQUIRES: arm-registered-target +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabihf %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" -target-feature "+soft-float-abi" %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -meabi gnu %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -target-feature "+soft-float-abi" -meabi gnu %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -meabi gnu %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf -meabi gnu %s | FileCheck %s + +// The Runtime ABI for the ARM Architecture IHI0043 section 4.1.2 The +// floating-point helper functions to always use the base AAPCS (soft-float) +// calling convention. +// +// These helper functions such as __aeabi_fadd are not explicitly called by +// clang, instead they are generated by the ARMISelLowering when they are +// needed; clang relies on llvm to use the base AAPCS. +// +// In this test we check that clang is not directly calling the __aeabi_ +// functions. We rely on llvm to test that the base AAPCS is used for any +// __aeabi_ function from 4.1.2 that is used. +// +// When compiled to an object file with -mfloat-abi=soft each function F +// below should result in a call to __aeabi_F. If clang is changed to call any +// of these functions directly the test will need to be altered to check that +// arm_aapcscc is used. +// +// Note that it is only the functions in 4.1.2 that must use the base AAPCS, +// other runtime functions such as the _Complex helper routines are not covered + +float fadd(float a, float b) { return a + b; } +// CHECK: @fadd +// CHECK-NOT: __aeabi_fadd + +float fdiv(float a, float b) { return a / b; } +// CHECK: @fdiv +// CHECK-NOT: __aeabi_fdiv + +float fmul(float a, float b) { return a * b; } +// CHECK: @fmul +// CHECK-NOT: __aeabi_fmul + +float fsub(float a, float b) { return a -
[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp
peter.smith added a comment. In https://reviews.llvm.org/D35538#814008, @compnerd wrote: > Can you please add a test that shows that the AEABI functions are not given > the wrong CC? Also, can you show that if someone also passes `-meabi=gnu` > with a VFP target, that we still annotate the functions with the differing CC > (since that should prefer the GNU functions over the AEABI functions). Thanks for the comment. Can I just check my understanding before I proceed? In particular I think I need a bit more information about what -meabi=gnu is supposed to do. I think tests to make sure the the floating point helper functions always use AAPCS is a good idea and I'll start working on that. At the moment I'm trying to work out the best way of doing this as this is all done in the ARM backend in llvm. My current favorite options are to compile and check the assembly in the clang test suite, or just check that the calls to the floating point helper functions are not emitted by clang and add a test to llvm to make sure that they have the correct calling convention. I'm currently tending towards the second option. With respect to -meabi=gnu, this was added in clang under r252463 and llvm r252462. From tracing through the flag through ARMTargetMachine.cpp and ARMISelLowering.cpp it seems like all this flag does in llvm is to use memcpy, memmove and memset instead of __aeabi_memcpy, __aeabi_memmove and __aeabi_memset respectively. These functions always use AAPCS calling convention, but as they do not take any floating point parameters it doesn't matter either way. As it stands the option won't have any effect on the use of other library functions for example doing a double precision divide with -meabi=gnu results in a call to __aeabi_ddiv. Does this match your expectation of what -meabi=gnu is supposed to do? If it doesn't can you point me at a description? All that I could find externally was the -meabi option in the GNU assembler (there is no equivalent gcc option), the value of -meabi=gnu maps to EF_ARM_ABI_UNKNOWN which is intended for generation of pre ARM ABI objects. I'll be on vacation for the next 3 days, I'll pick this back up next week. https://reviews.llvm.org/D35538 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp
compnerd requested changes to this revision. compnerd added a comment. This revision now requires changes to proceed. Can you please add a test that shows that the AEABI functions are not given the wrong CC? Also, can you show that if someone also passes `-meabi=gnu` with a VFP target, that we still annotate the functions with the differing CC (since that should prefer the GNU functions over the AEABI functions). https://reviews.llvm.org/D35538 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp
peter.smith created this revision. Herald added subscribers: kristof.beyls, aemerson. The ARM Runtime ABI document (IHI0043) defines the AEABI floating point helper functions in section 4.1 Floating-point library. These functions always use the base PCS (soft-fp). However helper functions defined outside of this document such as the complex-number multiply and divide helpers are not covered by this requirement and should use hard-float PCS if the target is hard-float. All of the floating point helper functions that are explicitly soft float are expanded in the llvm ARM backend. This change makes clang not force the BuiltinCC to AAPCS for AAPCS_VFP. With this change clang matches the behavior of gcc and the expected calling convention of the hard-float compiled compiler-rt and libgcc.a libraries as these functions do not have the __attribute__((__pcs__("aapcs"))). fixes https://bugs.llvm.org/show_bug.cgi?id=28164 fixes test failures in compiler-rt for a hard-float target "divtc3_test.c, divdc3_test.c, divxc3_test.c" I'm very new to clang so the way this has been fixed maybe a bit too simplistic. At present none of the builtins that produce calls in clang must use the base PCS. If clang ever needs to make a call to one of the AEABI defined functions that need base AAPCS then we'll need to identify the function when choosing a calling convention. References: - GCC list of functions that must be base AAPCS https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/config/arm/arm.c?view=co=text%2Fplain - Runtime ABI for the ARM Architecture http://infocenter.arm.com/help/topic/com.arm.doc.ihi0043d/IHI0043D_rtabi.pdf https://reviews.llvm.org/D35538 Files: lib/CodeGen/TargetInfo.cpp test/CodeGen/complex-math.c Index: test/CodeGen/complex-math.c === --- test/CodeGen/complex-math.c +++ test/CodeGen/complex-math.c @@ -2,7 +2,8 @@ // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC -// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARM +// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM +// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K float _Complex add_float_rr(float a, float b) { @@ -476,8 +477,15 @@ // Check that the libcall will obtain proper calling convention on ARM _Complex double foo(_Complex double a, _Complex double b) { + // These functions are not defined as floating point helper functions in + // Run-time ABI for the ARM architecture document so they must not always + // use the base AAPCS + // ARM-LABEL: @foo( - // ARM: call arm_aapcscc { double, double } @__muldc3 + // ARM: call void { double, double } @__muldc3 + + // ARMHF-LABEL: @foo( + // ARMHF: call { double, double } @__muldc3 // ARM7K-LABEL: @foo( // ARM7K: call { double, double } @__muldc3 Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -5573,17 +5573,14 @@ // AAPCS apparently requires runtime support functions to be soft-float, but // that's almost certainly for historic reasons (Thumb1 not supporting VFP // most likely). It's more convenient for AAPCS16_VFP to be hard-float. - switch (getABIKind()) { - case APCS: - case AAPCS16_VFP: -if (abiCC != getLLVMDefaultCC()) + + // The Run-time ABI for the ARM Architecture section 4.1.2 requires + // AEABI-complying FP helper functions to use the base AAPCS + // These AEABI functions are expanded in the ARM llvm backend, all the builtin + // support functions emitted by clang such as the _Complex helpers follow the + // abiCC. + if (abiCC != getLLVMDefaultCC()) BuiltinCC = abiCC; -break; - case AAPCS: - case AAPCS_VFP: -BuiltinCC = llvm::CallingConv::ARM_AAPCS; -break; - } } ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, Index: test/CodeGen/complex-math.c === --- test/CodeGen/complex-math.c +++ test/CodeGen/complex-math.c @@ -2,7 +2,8 @@ // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC -// RUN: %clang_cc1 %s -O1 -emit-llvm