1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/test/CodeGen/PowerPC/ppc32-i1-stack-arguments-abi-bug.ll
Lion Yang 370b1ac7f7 [PowerPC] Fix the calling convention for i1 arguments on PPC32
Summary:
Integer types smaller than i32 must be extended to i32 by default.
The feature "crbits" introduced at r202451 handles i1 as a special case,
but it did not extend properly.
The caller was, therefore, passing i1 stack arguments by writing 0/1 to
the first byte of the 4-byte stack object and callee was
reading the first byte for the value.

"crbits" is enabled if the optimization level is greater than 1,
which is very common in "release builds".
Such discrepancies with ABI specification also introduces
potential incompatibility with programs or libraries
built with other compilers e.g. GCC.

Fixes PR38661

Reviewers: hfinkel, cuviper

Subscribers: sylvestre.ledru, glaubitz, nagisa, nemanjai, kbarton, llvm-commits

Differential Revision: https://reviews.llvm.org/D51108

llvm-svn: 342288
2018-09-14 21:26:05 +00:00

25 lines
520 B
LLVM

; RUN: llc -verify-machineinstrs < %s -mcpu=ppc32 -mattr=+crbits | FileCheck %s
target triple = "powerpc-unknown-linux-gnu"
define void @check_callee(
i32, i32, i32, i32,
i32, i32, i32, i32,
i1 zeroext %s1
) {
call void @check_caller(
i32 9, i32 9, i32 9, i32 9,
i32 9, i32 9, i32 9, i32 9,
i1 zeroext %s1)
ret void
}
; CHECK-LABEL: @check_callee
; CHECK: lbz {{[0-9]+}}, 27(1)
; CHECK: stw {{[0-9]+}}, 8(1)
declare void @check_caller(
i32, i32, i32, i32,
i32, i32, i32, i32,
i1 zeroext
)