Skip to content

Commit 324511b

Browse files
[PowerPC] fix float ABI selection on ppcle (#154773)
soft float ABI selection was not taking effect on little-endian powerPC with embedded vectors (e.g. e500v2) leading to errors. (embedded vectors use "extended" GPRs to store floating-point values, and this caused issues with variadic arguments assuming dedicated floating-point registers with hard-float ABI)
1 parent 04c4e9d commit 324511b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
188188
return createPPC32TargetCodeGenInfo(CGM, IsSoftFloat);
189189
}
190190
case llvm::Triple::ppcle: {
191-
bool IsSoftFloat = CodeGenOpts.FloatABI == "soft";
191+
bool IsSoftFloat =
192+
CodeGenOpts.FloatABI == "soft" || Target.hasFeature("spe");
192193
return createPPC32TargetCodeGenInfo(CGM, IsSoftFloat);
193194
}
194195
case llvm::Triple::ppc64:

clang/test/CodeGen/PowerPC/ppc-sfvarargs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// RUN: %clang -O0 --target=powerpc-unknown-linux-gnu -EB -msoft-float -S -emit-llvm %s -o - | FileCheck %s
2+
// RUN: %clang -O0 --target=powerpcle-unknown-linux-gnu -EL -msoft-float -S -emit-llvm %s -o - | FileCheck %s
3+
// RUN: %clang -O0 --target=powerpcle-unknown-unknown -mcpu=e500 -mhard-float -S -emit-llvm %s -o - | FileCheck %s
4+
// RUN: %clang -O0 --target=powerpc-unknown-unknown -mcpu=e500 -mhard-float -S -emit-llvm %s -o - | FileCheck %s
25

36
#include <stdarg.h>
47
void test(char *fmt, ...) {

0 commit comments

Comments
 (0)