1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Reapply r284571 (with the new tests fixed).

llvm-svn: 284588
This commit is contained in:
Sjoerd Meijer 2016-10-19 13:43:02 +00:00
parent 679c8175bd
commit 3d94a0d81d
8 changed files with 130 additions and 14 deletions

View File

@ -633,17 +633,15 @@ static ARMBuildAttrs::CPUArch getArchForCPU(StringRef CPU,
return ARMBuildAttrs::v4;
}
// Returns true if all functions have the same function attribute value
static bool haveAllFunctionsAttribute(const Module &M, StringRef Attr,
StringRef Value) {
for (auto &F : M)
if (F.getFnAttribute(Attr).getValueAsString() != Value)
return false;
return true;
// Returns true if all functions have the same function attribute value.
// It also returns true when the module has no functions.
static bool checkFunctionsAttributeConsistency(const Module &M, StringRef Attr,
StringRef Value) {
return !any_of(M, [&](const Function &F) {
return F.getFnAttribute(Attr).getValueAsString() != Value;
});
}
void ARMAsmPrinter::emitAttributes() {
MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
@ -781,13 +779,15 @@ void ARMAsmPrinter::emitAttributes() {
}
// Set FP Denormals.
if (haveAllFunctionsAttribute(*MMI->getModule(), "denormal-fp-math",
"preserve-sign") ||
if (checkFunctionsAttributeConsistency(*MMI->getModule(),
"denormal-fp-math",
"preserve-sign") ||
TM.Options.FPDenormalMode == FPDenormal::PreserveSign)
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal,
ARMBuildAttrs::PreserveFPSign);
else if (haveAllFunctionsAttribute(*MMI->getModule(), "denormal-fp-math",
"positive-zero") ||
else if (checkFunctionsAttributeConsistency(*MMI->getModule(),
"denormal-fp-math",
"positive-zero") ||
TM.Options.FPDenormalMode == FPDenormal::PositiveZero)
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal,
ARMBuildAttrs::PositiveZero);
@ -821,7 +821,8 @@ void ARMAsmPrinter::emitAttributes() {
}
// Set FP exceptions and rounding
if (haveAllFunctionsAttribute(*MMI->getModule(), "no-trapping-math", "true") ||
if (checkFunctionsAttributeConsistency(*MMI->getModule(),
"no-trapping-math", "true") ||
TM.Options.NoTrappingFPMath)
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_exceptions,
ARMBuildAttrs::Not_Allowed);

View File

@ -0,0 +1,11 @@
; Check FP options -fno-trapping-math and -fdenormal-fp-math. They are passed
; as function attributes, which map on to build attributes ABI_FP_exceptions
; ABI_FP_denormal. In the backend we therefore have a check to see if all
; functions have consistent function attributes values. This check also returns
; true when the compilation unit does not have any functions (i.e. the
; attributes are consistent), which is what we check with this regression test.
; RUN: llc < %s -mtriple=armv7-linux-gnueabi -mcpu=cortex-a15 | FileCheck %s --check-prefix=CHECK
; CHECK: .eabi_attribute 20, 2
; CHECK: .eabi_attribute 21, 0

View File

@ -0,0 +1,17 @@
; Check FP options -fno-trapping-math and -fdenormal-fp-math. They are passed as
; function attributes, which map on to build attributes ABI_FP_exceptions ABI_FP_denormal.
; In the backend we have a check to see if all functions have consistent function
; attributes values. This checks the "default" behaviour when these FP function
; attributes are not set at all.
; RUN: llc < %s -mtriple=armv7-linux-gnueabi -mcpu=cortex-a15 | FileCheck %s --check-prefix=CHECK
; CHECK: .eabi_attribute 20, 1
; CHECK: .eabi_attribute 21, 1
define i32 @foo_no_fn_attr() local_unnamed_addr #0 {
entry:
ret i32 42
}
attributes #0 = { minsize norecurse nounwind optsize readnone }

View File

@ -0,0 +1,16 @@
; Check FP options -fno-trapping-math and -fdenormal-fp-math. They are passed
; as function attributes, which map on to build attributes ABI_FP_exceptions
; ABI_FP_denormal. In the backend we therefore have a check to see if all
; functions have consistent function attributes values.
; Here we test correct output for no-trapping-math=false
; RUN: llc < %s -mtriple=armv7-linux-gnueabi -mcpu=cortex-a15 | FileCheck %s --check-prefix=CHECK
; CHECK: .eabi_attribute 21, 1
define i32 @foo() local_unnamed_addr #0 {
entry:
ret i32 42
}
attributes #0 = { minsize norecurse nounwind optsize readnone "no-trapping-math"="false" }

View File

@ -0,0 +1,17 @@
; Check FP options -fno-trapping-math and -fdenormal-fp-math. They are passed
; as function attributes, which map on to build attributes ABI_FP_exceptions
; ABI_FP_denormal. In the backend we therefore have a check to see if all
; functions have consistent function attributes values.
; Here we check values no-trapping-math=true and denormal-fp-math=ieee.
; RUN: llc < %s -mtriple=armv7-linux-gnueabi -mcpu=cortex-a15 | FileCheck %s --check-prefix=CHECK
; CHECK: .eabi_attribute 20, 1
; CHECK: .eabi_attribute 21, 0
define i32 @foo() local_unnamed_addr #0 {
entry:
ret i32 42
}
attributes #0 = { minsize norecurse nounwind optsize readnone "no-trapping-math"="true" "denormal-fp-math"="ieee"}

View File

@ -0,0 +1,16 @@
; Check FP option -fdenormal-fp-math. This passed as function attribute,
; which map on to build attributes ABI_FP_denormal. In the backend we
; therefore have a check to see if all functions have consistent function
; attributes values.
; Here we check the denormal-fp-math=positive-zero value.
; RUN: llc < %s -mtriple=armv7-linux-gnueabi -mcpu=cortex-a15 | FileCheck %s --check-prefix=CHECK
; CHECK: .eabi_attribute 20, 0
define i32 @foo1() local_unnamed_addr #0 {
entry:
ret i32 42
}
attributes #0 = { minsize norecurse nounwind optsize readnone "denormal-fp-math"="positive-zero"}

View File

@ -0,0 +1,16 @@
; Check FP option -fdenormal-fp-math. This passed as function attribute,
; which map on to build attributes ABI_FP_denormal. In the backend we
; therefore have a check to see if all functions have consistent function
; attributes values.
; Here we check the denormal-fp-math=preserve-sign value.
; RUN: llc < %s -mtriple=armv7-linux-gnueabi -mcpu=cortex-a15 | FileCheck %s --check-prefix=CHECK
; CHECK: .eabi_attribute 20, 2
define i32 @foo1() local_unnamed_addr #0 {
entry:
ret i32 42
}
attributes #0 = { minsize norecurse nounwind optsize readnone "denormal-fp-math"="preserve-sign"}

View File

@ -0,0 +1,22 @@
; Check FP options -fno-trapping-math and -fdenormal-fp-math. They are passed
; as function attributes, which map on to build attributes ABI_FP_exceptions
; ABI_FP_denormal. In the backend we therefore have a check to see if all
; functions have consistent function attributes values. Here we check two
; functions have inconsistent values, and that a default is returned.
; RUN: llc < %s -mtriple=armv7-linux-gnueabi -mcpu=cortex-a15 | FileCheck %s --check-prefix=CHECK
; CHECK: .eabi_attribute 20, 1
define i32 @foo1() local_unnamed_addr #0 {
entry:
ret i32 42
}
define i32 @foo2() local_unnamed_addr #1 {
entry:
ret i32 42
}
attributes #0 = { minsize norecurse nounwind optsize readnone "denormal-fp-math"="preserve-sign"}
attributes #0 = { minsize norecurse nounwind optsize readnone "denormal-fp-math"="positive-zero"}