forked from OSchip/llvm-project
llc: Change behavior of -mcpu with existing attribute
Don't overwrite existing target-cpu attributes. I've often found the replacement behavior annoying, and this is inconsistent with how the fast math command line flags interact with the function attributes. Does not yet change target-features, since I think that should behave as a concatenation.
This commit is contained in:
parent
a428386d4a
commit
f26ed6e47c
llvm
include/llvm/CodeGen
test
CodeGen
AMDGPU
MIR/AMDGPU
X86
DebugInfo/COFF
Other
Transforms/LoopVectorize/X86
tools/llvm-objdump/AMDGPU
|
@ -380,7 +380,7 @@ setFunctionAttributes(StringRef CPU, StringRef Features, Function &F) {
|
||||||
AttributeList Attrs = F.getAttributes();
|
AttributeList Attrs = F.getAttributes();
|
||||||
AttrBuilder NewAttrs;
|
AttrBuilder NewAttrs;
|
||||||
|
|
||||||
if (!CPU.empty())
|
if (!CPU.empty() && !F.hasFnAttribute("target-cpu"))
|
||||||
NewAttrs.addAttribute("target-cpu", CPU);
|
NewAttrs.addAttribute("target-cpu", CPU);
|
||||||
if (!Features.empty())
|
if (!Features.empty())
|
||||||
NewAttrs.addAttribute("target-features", Features);
|
NewAttrs.addAttribute("target-features", Features);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# RUN: llc -march=amdgcn -mcpu=gfx803 -run-pass si-memory-legalizer %s -o - | FileCheck %s
|
# RUN: llc -march=amdgcn -run-pass=si-memory-legalizer %s -o - | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
declare i32 @llvm.amdgcn.workitem.id.x() #0
|
declare i32 @llvm.amdgcn.workitem.id.x() #0
|
||||||
|
@ -33,13 +33,8 @@
|
||||||
|
|
||||||
declare void @llvm.amdgcn.end.cf(i64)
|
declare void @llvm.amdgcn.end.cf(i64)
|
||||||
|
|
||||||
; Function Attrs: nounwind
|
attributes #0 = { nounwind readnone }
|
||||||
declare void @llvm.stackprotector(i8*, i8**) #3
|
attributes #1 = { nounwind "target-cpu"="gfx803" }
|
||||||
|
|
||||||
attributes #0 = { nounwind readnone "target-cpu"="tahiti" }
|
|
||||||
attributes #1 = { nounwind "target-cpu"="tahiti" }
|
|
||||||
attributes #2 = { readnone }
|
|
||||||
attributes #3 = { nounwind }
|
|
||||||
|
|
||||||
...
|
...
|
||||||
---
|
---
|
||||||
|
|
|
@ -4,8 +4,11 @@
|
||||||
# FIXME: This overrides attributes that already are present. It should probably
|
# FIXME: This overrides attributes that already are present. It should probably
|
||||||
# only touch functions without an existing attribute.
|
# only touch functions without an existing attribute.
|
||||||
|
|
||||||
# MCPU: attributes #0 = { "target-cpu"="hawaii" }
|
# MCPU: @with_cpu_attr() #0 {
|
||||||
# MCPU-NOT: attributes #1
|
# MCPU: @no_cpu_attr() #1 {
|
||||||
|
|
||||||
|
# MCPU: attributes #0 = { "target-cpu"="fiji" }
|
||||||
|
# MCPU: attributes #1 = { "target-cpu"="hawaii" }
|
||||||
|
|
||||||
# MATTR: attributes #0 = { "target-cpu"="fiji" "target-features"="+unaligned-buffer-access" }
|
# MATTR: attributes #0 = { "target-cpu"="fiji" "target-features"="+unaligned-buffer-access" }
|
||||||
# MATTR: attributes #1 = { "target-features"="+unaligned-buffer-access" }
|
# MATTR: attributes #1 = { "target-features"="+unaligned-buffer-access" }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
||||||
; RUN: llc < %s -mtriple=x86_64-linux -verify-machineinstrs | FileCheck %s -check-prefix=CHECK
|
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=x86-64 -verify-machineinstrs | FileCheck %s -check-prefix=CHECK
|
||||||
; RUN: llc < %s -mtriple=x86_64-linux --x86-disable-avoid-SFB -verify-machineinstrs | FileCheck %s --check-prefix=DISABLED
|
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=x86-64 --x86-disable-avoid-SFB -verify-machineinstrs | FileCheck %s --check-prefix=DISABLED
|
||||||
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=core-avx2 -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-AVX2
|
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=core-avx2 -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-AVX2
|
||||||
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=skx -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-AVX512
|
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=skx -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-AVX512
|
||||||
|
|
||||||
|
@ -515,7 +515,6 @@ entry:
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||||
|
|
||||||
attributes #1 = { argmemonly nounwind }
|
attributes #1 = { argmemonly nounwind }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
||||||
; RUN: llc < %s -mtriple=x86_64-linux -verify-machineinstrs | FileCheck %s -check-prefix=CHECK
|
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=x86-64 -verify-machineinstrs | FileCheck %s -check-prefix=CHECK
|
||||||
; RUN: llc < %s -mtriple=x86_64-linux --x86-disable-avoid-SFB -verify-machineinstrs | FileCheck %s --check-prefix=DISABLED
|
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=x86-64 --x86-disable-avoid-SFB -verify-machineinstrs | FileCheck %s --check-prefix=DISABLED
|
||||||
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=core-avx2 -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-AVX2
|
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=core-avx2 -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-AVX2
|
||||||
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=skx -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-AVX512
|
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=skx -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-AVX512
|
||||||
|
|
||||||
|
@ -1243,11 +1243,6 @@ if.end: ; preds = %if.then, %entry
|
||||||
declare void @bar(%struct.S*) local_unnamed_addr #1
|
declare void @bar(%struct.S*) local_unnamed_addr #1
|
||||||
|
|
||||||
|
|
||||||
; Function Attrs: argmemonly nounwind
|
|
||||||
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #1
|
|
||||||
|
|
||||||
attributes #0 = { nounwind uwtable "target-cpu"="x86-64" }
|
|
||||||
|
|
||||||
%struct.S7 = type { float, float, float , float, float, float, float, float }
|
%struct.S7 = type { float, float, float , float, float, float, float, float }
|
||||||
|
|
||||||
; Function Attrs: nounwind uwtable
|
; Function Attrs: nounwind uwtable
|
||||||
|
@ -1527,5 +1522,7 @@ entry:
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; Function Attrs: argmemonly nounwind
|
||||||
|
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #1
|
||||||
|
|
||||||
|
attributes #0 = { nounwind uwtable }
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
; RUN: llc < %s -mtriple=x86_64-- -mcpu=broadwell | FileCheck %s
|
; RUN: llc < %s -mtriple=x86_64-- -mcpu=broadwell | FileCheck %s
|
||||||
; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx2 | FileCheck %s
|
; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx2 | FileCheck %s
|
||||||
|
|
||||||
; Check that llc can overide function attributes target-cpu and target-features
|
; Check that llc can set function attributes target-cpu and target-features
|
||||||
; using command line options -mcpu and -mattr.
|
; using command line options -mcpu and -mattr.
|
||||||
|
|
||||||
; CHECK: vpsadbw (%r{{si|dx}}), %ymm{{[0-9]+}}, %ymm{{[0-9]+}}
|
; CHECK: vpsadbw (%r{{si|dx}}), %ymm{{[0-9]+}}, %ymm{{[0-9]+}}
|
||||||
|
|
||||||
define <4 x i64> @foo1(<4 x i64>* %s1, <4 x i64>* %s2) #0 {
|
define <4 x i64> @foo1(<4 x i64>* %s1, <4 x i64>* %s2) {
|
||||||
entry:
|
entry:
|
||||||
%ps1 = load <4 x i64>, <4 x i64>* %s1
|
%ps1 = load <4 x i64>, <4 x i64>* %s1
|
||||||
%ps2 = load <4 x i64>, <4 x i64>* %s2
|
%ps2 = load <4 x i64>, <4 x i64>* %s2
|
||||||
|
@ -17,5 +17,3 @@ entry:
|
||||||
}
|
}
|
||||||
|
|
||||||
declare <4 x i64> @llvm.x86.avx2.psad.bw(<32 x i8>, <32 x i8>)
|
declare <4 x i64> @llvm.x86.avx2.psad.bw(<32 x i8>, <32 x i8>)
|
||||||
|
|
||||||
attributes #0 = { "target-cpu"="core2" "target-features"="+ssse3,+cx16,+sse4.2,+sse4.1,+sse,+sse2,+sse3,+avx,+popcnt" }
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ entry:
|
||||||
ret void, !dbg !30
|
ret void, !dbg !30
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes #0 = { norecurse nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
attributes #0 = { norecurse nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||||
|
|
||||||
!llvm.dbg.cu = !{!2}
|
!llvm.dbg.cu = !{!2}
|
||||||
!llvm.module.flags = !{!8, !9, !10}
|
!llvm.module.flags = !{!8, !9, !10}
|
||||||
|
|
|
@ -129,7 +129,7 @@ entry:
|
||||||
ret i32 %5, !dbg !32
|
ret i32 %5, !dbg !32
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes #0 = { norecurse nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
attributes #0 = { norecurse nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||||
|
|
||||||
!llvm.dbg.cu = !{!2}
|
!llvm.dbg.cu = !{!2}
|
||||||
!llvm.module.flags = !{!8, !9, !10}
|
!llvm.module.flags = !{!8, !9, !10}
|
||||||
|
|
|
@ -1,13 +1,21 @@
|
||||||
; RUN: opt < %s -mtriple=x86_64-apple-darwin -mcpu=broadwell -mattr=+avx2 -S | FileCheck %s
|
; RUN: opt < %s -mtriple=x86_64-apple-darwin -mcpu=broadwell -mattr=+avx2 -S | FileCheck %s
|
||||||
|
|
||||||
; Check that opt can rewrite function attributes target-cpu and target-features
|
; Check that opt can add but not rewrite function attributes
|
||||||
; using command line options -mcpu and -mattr.
|
; target-cpu and target-features using command line options -mcpu and
|
||||||
|
; -mattr.
|
||||||
|
|
||||||
; CHECK: attributes #0 = { nounwind readnone ssp uwtable "target-cpu"="broadwell" "target-features"="+avx2" "use-soft-float"="false" }
|
; CHECK: attributes #0 = { nounwind readnone ssp uwtable "target-cpu"="broadwell" "target-features"="+avx2" "use-soft-float"="false" }
|
||||||
|
; CHECK: attributes #1 = { nounwind readnone ssp uwtable "target-cpu"="core2" "target-features"="+avx2" "use-soft-float"="false" }
|
||||||
|
|
||||||
define i32 @foo1() #0 {
|
define i32 @no_target_cpu() #0 {
|
||||||
entry:
|
entry:
|
||||||
ret i32 0
|
ret i32 0
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes #0 = { nounwind readnone ssp uwtable "target-cpu"="core2" "target-features"="+ssse3,+cx16,+sse,+sse2,+sse3" "use-soft-float"="false" }
|
define i32 @has_targe_cpu() #1 {
|
||||||
|
entry:
|
||||||
|
ret i32 0
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes #0 = { nounwind readnone ssp uwtable "target-features"="+ssse3,+cx16,+sse,+sse2,+sse3" "use-soft-float"="false" }
|
||||||
|
attributes #1 = { nounwind readnone ssp uwtable "target-cpu"="core2" "target-features"="+ssse3,+cx16,+sse,+sse2,+sse3" "use-soft-float"="false" }
|
||||||
|
|
|
@ -143,7 +143,7 @@ for.inc:
|
||||||
br i1 %exitcond, label %for.cond.cleanup, label %for.body, !llvm.loop !11
|
br i1 %exitcond, label %for.cond.cleanup, label %for.body, !llvm.loop !11
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes #0 = { norecurse nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
attributes #0 = { norecurse nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||||
|
|
||||||
!llvm.module.flags = !{!0}
|
!llvm.module.flags = !{!0}
|
||||||
!llvm.ident = !{!1}
|
!llvm.ident = !{!1}
|
||||||
|
|
|
@ -67,7 +67,7 @@ entry:
|
||||||
; Function Attrs: nounwind readnone
|
; Function Attrs: nounwind readnone
|
||||||
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
||||||
|
|
||||||
attributes #0 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="gfx700" "target-features"="+fp64-fp16-denormals,-fp32-denormals" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
attributes #0 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+fp64-fp16-denormals,-fp32-denormals" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||||
attributes #1 = { nounwind readnone }
|
attributes #1 = { nounwind readnone }
|
||||||
|
|
||||||
!llvm.dbg.cu = !{!0}
|
!llvm.dbg.cu = !{!0}
|
||||||
|
|
Loading…
Reference in New Issue