diff options
author | Jessica Paquette <jpaquette@apple.com> | 2020-01-07 11:12:32 -0800 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2020-01-07 11:27:25 -0800 |
commit | acd258082477b8a4edf3037127efb5fed4494da3 (patch) | |
tree | a2bc78944f00807886d035b193d664e141724e76 /llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | |
parent | afa8211e979c25100c2ed41d8da1e18b45d0ef2b (diff) | |
download | bcm5719-llvm-acd258082477b8a4edf3037127efb5fed4494da3.tar.gz bcm5719-llvm-acd258082477b8a4edf3037127efb5fed4494da3.zip |
[MachineOutliner][AArch64] Save + restore LR in noreturn functions
Conservatively always save + restore LR in noreturn functions.
These functions do not end in a RET, and so they aren't guaranteed to have an
instruction which uses LR in any way. So, as a result, you can end up in
unfortunate situations where you can't backtrace out of these functions in a
debugger.
Remove the old noreturn test, and add a new one which is more descriptive.
Remove the restriction that we can't outline from noreturn functions as well
since we now do the right thing.
Diffstat (limited to 'llvm/lib/Target/AArch64/AArch64InstrInfo.cpp')
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index abde3e50021..54f3f7c1013 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -5868,11 +5868,21 @@ outliner::OutlinedFunction AArch64InstrInfo::getOutliningCandidateInfo( unsigned NumBytesNoStackCalls = 0; std::vector<outliner::Candidate> CandidatesWithoutStackFixups; + // Check if we have to save LR. for (outliner::Candidate &C : RepeatedSequenceLocs) { C.initLRU(TRI); + // If we have a noreturn caller, then we're going to be conservative and + // say that we have to save LR. If we don't have a ret at the end of the + // block, then we can't reason about liveness accurately. + // + // FIXME: We can probably do better than always disabling this in + // noreturn functions by fixing up the liveness info. + bool IsNoReturn = + C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn); + // Is LR available? If so, we don't need a save. - if (C.LRU.available(AArch64::LR)) { + if (C.LRU.available(AArch64::LR) && !IsNoReturn) { NumBytesNoStackCalls += 4; C.setCallInfo(MachineOutlinerNoLRSave, 4); CandidatesWithoutStackFixups.push_back(C); |