mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[Hexagon] Do not rely on callee-saved info in hasFP
llvm-svn: 307675
This commit is contained in:
parent
7b2e05b496
commit
2d1dff50e7
@ -979,18 +979,6 @@ bool HexagonFrameLowering::hasFP(const MachineFunction &MF) const {
|
||||
if (MFI.hasCalls() || HMFI.hasClobberLR())
|
||||
return true;
|
||||
|
||||
// Frame pointer elimination is a possiblility at this point, but
|
||||
// to know if FP is necessary we need to know if spill/restore
|
||||
// functions will be used (they require FP to be valid).
|
||||
// This means that hasFP shouldn't really be called before CSI is
|
||||
// calculated, and some measures are taken to make sure of that
|
||||
// (e.g. default implementations of virtual functions that call it
|
||||
// are overridden apropriately).
|
||||
assert(MFI.isCalleeSavedInfoValid() && "Need to know CSI");
|
||||
const std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo();
|
||||
if (useSpillFunction(MF, CSI) || useRestoreFunction(MF, CSI))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2437,6 +2425,8 @@ bool HexagonFrameLowering::shouldInlineCSR(const MachineFunction &MF,
|
||||
const CSIVect &CSI) const {
|
||||
if (MF.getInfo<HexagonMachineFunctionInfo>()->hasEHReturn())
|
||||
return true;
|
||||
if (!hasFP(MF))
|
||||
return true;
|
||||
if (!isOptSize(MF) && !isMinSize(MF))
|
||||
if (MF.getTarget().getOptLevel() > CodeGenOpt::Default)
|
||||
return true;
|
||||
|
@ -716,6 +716,7 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
||||
|
||||
bool IsStructRet = (Outs.empty()) ? false : Outs[0].Flags.isSRet();
|
||||
MachineFunction &MF = DAG.getMachineFunction();
|
||||
MachineFrameInfo &MFI = MF.getFrameInfo();
|
||||
auto PtrVT = getPointerTy(MF.getDataLayout());
|
||||
|
||||
// Check for varargs.
|
||||
@ -832,7 +833,6 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
||||
|
||||
if (NeedsArgAlign && Subtarget.hasV60TOps()) {
|
||||
DEBUG(dbgs() << "Function needs byte stack align due to call args\n");
|
||||
MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo();
|
||||
// V6 vectors passed by value have 64 or 128 byte alignment depending
|
||||
// on whether we are 64 byte vector mode or 128 byte.
|
||||
bool UseHVXDbl = Subtarget.useHVXDblOps();
|
||||
@ -916,10 +916,15 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
||||
Ops.push_back(Glue);
|
||||
|
||||
if (IsTailCall) {
|
||||
MF.getFrameInfo().setHasTailCall();
|
||||
MFI.setHasTailCall();
|
||||
return DAG.getNode(HexagonISD::TC_RETURN, dl, NodeTys, Ops);
|
||||
}
|
||||
|
||||
// Set this here because we need to know this for "hasFP" in frame lowering.
|
||||
// The target-independent code calls getFrameRegister before setting it, and
|
||||
// getFrameRegister uses hasFP to determine whether the function has FP.
|
||||
MFI.setHasCalls(true);
|
||||
|
||||
unsigned OpCode = DoesNotReturn ? HexagonISD::CALLnr : HexagonISD::CALL;
|
||||
Chain = DAG.getNode(OpCode, dl, NodeTys, Ops);
|
||||
Glue = Chain.getValue(1);
|
||||
|
82
test/CodeGen/Hexagon/hasfp-crash1.ll
Normal file
82
test/CodeGen/Hexagon/hasfp-crash1.ll
Normal file
@ -0,0 +1,82 @@
|
||||
; RUN: llc -march=hexagon < %s | FileCheck %s
|
||||
;
|
||||
; Check that this testcase does not crash.
|
||||
; CHECK: jumpr r31
|
||||
|
||||
target triple = "hexagon"
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare i32 @foo0(i32*, i32, i64, i32, i8 zeroext, i8 zeroext, i32) local_unnamed_addr #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @foo1(i32* %a0, i32 %a1, i32 %a2, i32 %a3, i8 zeroext %a4, i8 zeroext %a5, i32 %a6) local_unnamed_addr #0 !dbg !33 {
|
||||
entry:
|
||||
tail call void @llvm.dbg.value(metadata i32 %a6, i64 0, metadata !51, metadata !52), !dbg !53
|
||||
ret i32 undef, !dbg !54
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind readnone speculatable
|
||||
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
|
||||
|
||||
attributes #0 = { nounwind "disable-tail-calls"="true" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "stack-protector-buffer-size"="8" "target-cpu"="hexagonv5" "target-features"="-hvx-double,-long-calls" }
|
||||
attributes #1 = { nounwind readnone speculatable }
|
||||
|
||||
!llvm.dbg.cu = !{!0}
|
||||
!llvm.module.flags = !{!26, !27}
|
||||
!llvm.linker.options = !{!29, !30, !31, !32, !29, !30, !31, !32}
|
||||
|
||||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !22)
|
||||
!1 = !DIFile(filename: "foo.i", directory: "/path")
|
||||
!2 = !{!3, !16}
|
||||
!3 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !4, line: 122, size: 8, elements: !5)
|
||||
!4 = !DIFile(filename: "foo.h", directory: "/path")
|
||||
!5 = !{!6, !7, !8, !9, !10, !11, !12, !13, !14, !15}
|
||||
!6 = !DIEnumerator(name: "E0", value: 7)
|
||||
!7 = !DIEnumerator(name: "E1", value: 6)
|
||||
!8 = !DIEnumerator(name: "E2", value: 5)
|
||||
!9 = !DIEnumerator(name: "E3", value: 0)
|
||||
!10 = !DIEnumerator(name: "E4", value: 1)
|
||||
!11 = !DIEnumerator(name: "E5", value: 7)
|
||||
!12 = !DIEnumerator(name: "E6", value: 5)
|
||||
!13 = !DIEnumerator(name: "E7", value: 4)
|
||||
!14 = !DIEnumerator(name: "E8", value: 4)
|
||||
!15 = !DIEnumerator(name: "E9", value: 10)
|
||||
!16 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !4, line: 136, size: 8, elements: !17)
|
||||
!17 = !{!18, !19, !20, !21}
|
||||
!18 = !DIEnumerator(name: "F0", value: 1)
|
||||
!19 = !DIEnumerator(name: "F1", value: 2)
|
||||
!20 = !DIEnumerator(name: "F2", value: 4)
|
||||
!21 = !DIEnumerator(name: "F3", value: 7)
|
||||
!22 = !{!23, !24, !25}
|
||||
!23 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
|
||||
!24 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
|
||||
!25 = !DIDerivedType(tag: DW_TAG_typedef, name: "t0_t", file: !4, line: 38, baseType: !24)
|
||||
!26 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!27 = !{i32 6, !"Linker Options", !28}
|
||||
!28 = !{!29, !30, !31, !32}
|
||||
!29 = !{!"foo0", !".text"}
|
||||
!30 = !{!"foo1", !".text"}
|
||||
!31 = !{!"foo2", !".text"}
|
||||
!32 = !{!"foo3", !".text"}
|
||||
!33 = distinct !DISubprogram(name: "foo1", scope: !34, file: !34, line: 84, type: !35, isLocal: false, isDefinition: true, scopeLine: 85, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !44)
|
||||
!34 = !DIFile(filename: "foo.c", directory: "/path")
|
||||
!35 = !DISubroutineType(types: !36)
|
||||
!36 = !{!37, !38, !39, !40, !41, !42, !43, !37}
|
||||
!37 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
!38 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 32)
|
||||
!39 = !DIDerivedType(tag: DW_TAG_typedef, name: "t1_t", file: !4, line: 35, baseType: !23)
|
||||
!40 = !DIDerivedType(tag: DW_TAG_typedef, name: "t2_t", file: !4, line: 36, baseType: !23)
|
||||
!41 = !DIDerivedType(tag: DW_TAG_typedef, name: "t3_t", file: !4, line: 43, baseType: !23)
|
||||
!42 = !DIDerivedType(tag: DW_TAG_typedef, name: "t4_t", file: !4, line: 133, baseType: !3)
|
||||
!43 = !DIDerivedType(tag: DW_TAG_typedef, name: "t5_t", file: !4, line: 141, baseType: !16)
|
||||
!44 = !{!45, !46, !47, !48, !49, !50, !51}
|
||||
!45 = !DILocalVariable(name: "a0", arg: 1, scope: !33, file: !34, line: 84, type: !38)
|
||||
!46 = !DILocalVariable(name: "a1", arg: 2, scope: !33, file: !34, line: 84, type: !39)
|
||||
!47 = !DILocalVariable(name: "a2", arg: 3, scope: !33, file: !34, line: 84, type: !40)
|
||||
!48 = !DILocalVariable(name: "a3", arg: 4, scope: !33, file: !34, line: 84, type: !41)
|
||||
!49 = !DILocalVariable(name: "a4", arg: 5, scope: !33, file: !34, line: 84, type: !42)
|
||||
!50 = !DILocalVariable(name: "a5", arg: 6, scope: !33, file: !34, line: 84, type: !43)
|
||||
!51 = !DILocalVariable(name: "a6", arg: 7, scope: !33, file: !34, line: 84, type: !37)
|
||||
!52 = !DIExpression()
|
||||
!53 = !DILocation(line: 84, column: 169, scope: !33)
|
||||
!54 = !DILocation(line: 86, column: 5, scope: !33)
|
83
test/CodeGen/Hexagon/hasfp-crash2.ll
Normal file
83
test/CodeGen/Hexagon/hasfp-crash2.ll
Normal file
@ -0,0 +1,83 @@
|
||||
; RUN: llc -march=hexagon < %s | FileCheck %s
|
||||
;
|
||||
; Check that this testcase does not crash.
|
||||
; CHECK: call foo0
|
||||
|
||||
target triple = "hexagon"
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @foo0() local_unnamed_addr #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define void @foo1() local_unnamed_addr #0 !dbg !33 {
|
||||
entry:
|
||||
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !51, metadata !52), !dbg !53
|
||||
tail call void @foo0(), !dbg !54
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind readnone speculatable
|
||||
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
|
||||
|
||||
attributes #0 = { nounwind "disable-tail-calls"="true" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "stack-protector-buffer-size"="8" "target-cpu"="hexagonv5" "target-features"="-hvx-double,-long-calls" }
|
||||
attributes #1 = { nounwind readnone speculatable }
|
||||
|
||||
!llvm.dbg.cu = !{!0}
|
||||
!llvm.module.flags = !{!26, !27}
|
||||
!llvm.linker.options = !{!29, !30, !31, !32, !29, !30, !31, !32, !29, !30, !31, !32, !29, !30, !31, !32, !29, !30, !31, !32, !29, !30, !31, !32}
|
||||
|
||||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !22)
|
||||
!1 = !DIFile(filename: "foo.i", directory: "/path")
|
||||
!2 = !{!3, !16}
|
||||
!3 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !4, line: 122, size: 8, elements: !5)
|
||||
!4 = !DIFile(filename: "foo.h", directory: "/path")
|
||||
!5 = !{!6, !7, !8, !9, !10, !11, !12, !13, !14, !15}
|
||||
!6 = !DIEnumerator(name: "E0", value: 7)
|
||||
!7 = !DIEnumerator(name: "E1", value: 6)
|
||||
!8 = !DIEnumerator(name: "E2", value: 5)
|
||||
!9 = !DIEnumerator(name: "E3", value: 0)
|
||||
!10 = !DIEnumerator(name: "E4", value: 1)
|
||||
!11 = !DIEnumerator(name: "E5", value: 7)
|
||||
!12 = !DIEnumerator(name: "E6", value: 5)
|
||||
!13 = !DIEnumerator(name: "E7", value: 4)
|
||||
!14 = !DIEnumerator(name: "E8", value: 4)
|
||||
!15 = !DIEnumerator(name: "E9", value: 10)
|
||||
!16 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !4, line: 136, size: 8, elements: !17)
|
||||
!17 = !{!18, !19, !20, !21}
|
||||
!18 = !DIEnumerator(name: "F0", value: 1)
|
||||
!19 = !DIEnumerator(name: "F1", value: 2)
|
||||
!20 = !DIEnumerator(name: "F2", value: 4)
|
||||
!21 = !DIEnumerator(name: "F3", value: 7)
|
||||
!22 = !{!23, !24, !25}
|
||||
!23 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
|
||||
!24 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
|
||||
!25 = !DIDerivedType(tag: DW_TAG_typedef, name: "t0_t", file: !4, line: 38, baseType: !24)
|
||||
!26 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!27 = !{i32 6, !"Linker Options", !28}
|
||||
!28 = !{!29, !30, !31, !32}
|
||||
!29 = !{!"foo0", !".text"}
|
||||
!30 = !{!"foo1", !".text"}
|
||||
!31 = !{!"foo2", !".text"}
|
||||
!32 = !{!"foo3", !".text"}
|
||||
!33 = distinct !DISubprogram(name: "foo1", scope: !34, file: !34, line: 84, type: !35, isLocal: false, isDefinition: true, scopeLine: 85, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !44)
|
||||
!34 = !DIFile(filename: "foo.c", directory: "/path")
|
||||
!35 = !DISubroutineType(types: !36)
|
||||
!36 = !{!37, !38, !39, !40, !41, !42, !43, !37}
|
||||
!37 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
!38 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 32)
|
||||
!39 = !DIDerivedType(tag: DW_TAG_typedef, name: "t1_t", file: !4, line: 35, baseType: !23)
|
||||
!40 = !DIDerivedType(tag: DW_TAG_typedef, name: "t2_t", file: !4, line: 36, baseType: !23)
|
||||
!41 = !DIDerivedType(tag: DW_TAG_typedef, name: "t3_t", file: !4, line: 43, baseType: !23)
|
||||
!42 = !DIDerivedType(tag: DW_TAG_typedef, name: "t4_t", file: !4, line: 133, baseType: !3)
|
||||
!43 = !DIDerivedType(tag: DW_TAG_typedef, name: "t5_t", file: !4, line: 141, baseType: !16)
|
||||
!44 = !{!45, !46, !47, !48, !49, !50, !51}
|
||||
!45 = !DILocalVariable(name: "a0", arg: 1, scope: !33, file: !34, line: 84, type: !38)
|
||||
!46 = !DILocalVariable(name: "a1", arg: 2, scope: !33, file: !34, line: 84, type: !39)
|
||||
!47 = !DILocalVariable(name: "a2", arg: 3, scope: !33, file: !34, line: 84, type: !40)
|
||||
!48 = !DILocalVariable(name: "a3", arg: 4, scope: !33, file: !34, line: 84, type: !41)
|
||||
!49 = !DILocalVariable(name: "a4", arg: 5, scope: !33, file: !34, line: 84, type: !42)
|
||||
!50 = !DILocalVariable(name: "a5", arg: 6, scope: !33, file: !34, line: 84, type: !43)
|
||||
!51 = !DILocalVariable(name: "a6", arg: 7, scope: !33, file: !34, line: 84, type: !37)
|
||||
!52 = !DIExpression()
|
||||
!53 = !DILocation(line: 84, column: 169, scope: !33)
|
||||
!54 = !DILocation(line: 86, column: 12, scope: !33)
|
Loading…
Reference in New Issue
Block a user