[llvm] r317579 - Reland "Correct dwarf unwind information in function epilogue for X86"
Petar Jovanovic via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 8 05:55:39 PST 2017
There is one approach how to deal with this problem at:
https://reviews.llvm.org/D40979
________________________________
From: Reid Kleckner [rnk at google.com]
Sent: Wednesday, November 8, 2017 10:21 PM
To: Petar Jovanovic
Cc: llvm-commits
Subject: Re: [llvm] r317579 - Reland "Correct dwarf unwind information in function epilogue for X86"
There is a design issue with making CFI_INSTRUCTION duplicable. Darwin compact unwind info emission can't handle multiple prologue setups. I will revert this and put the reduced test case in the commit message.
On Wed, Nov 8, 2017 at 10:43 AM, Reid Kleckner <rnk at google.com<mailto:rnk at google.com>> wrote:
I confirmed this caused a regression for AArch64 and I am reducing a test case.
On Wed, Nov 8, 2017 at 9:34 AM, Reid Kleckner <rnk at google.com<mailto:rnk at google.com>> wrote:
I suspect this change introduced a bug in compact unwind info on AArch64:
https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.clang%2FToTiOS%2F250%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout
FAILED: ios_clang_arm64/obj/third_party/opus/opus/pitch.o
...
Assertion failed: (StackSize == 0 && "We already have the CFA offset!"), function generateCompactUnwindEncoding, file /b/c/b/ToTiOS/src/third_party/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp, line 487.
0 clang 0x00000001035d7fb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 clang 0x00000001035d86b6 llvm::sys::PrintStackTraceOnErrorSignal(llvm::StringRef, bool) + 838
2 libsystem_platform.dylib 0x00007fffeb995bba _sigtramp + 26
3 clang 0x0000000103294e79 llvm::MCCVLineEntry::Make(llvm::MCObjectStreamer*) + 25
4 libsystem_c.dylib 0x00007fffeb81c420 abort + 129
5 libsystem_c.dylib 0x00007fffeb7e3893 basename_r + 0
6 clang 0x0000000101e22067 llvm::createAArch64beAsmBackend(llvm::Target const&, llvm::MCRegisterInfo const&, llvm::Triple const&, llvm::StringRef, llvm::MCTargetOptions const&) + 8631
7 clang 0x00000001032bf4ef llvm::MCStreamer::generateCompactUnwindEncodings(llvm::MCAsmBackend*) + 79
8 clang 0x00000001032a1196 llvm::MCDwarfFrameEmitter::Emit(llvm::MCObjectStreamer&, llvm::MCAsmBackend*, bool) + 38
9 clang 0x00000001032b806e llvm::MCObjectStreamer::EmitFrames(llvm::MCAsmBackend*) + 62
10 clang 0x00000001032b12f5 llvm::createMachOStreamer(llvm::MCContext&, std::__1::unique_ptr<llvm::MCAsmBackend, std::__1::default_delete<llvm::MCAsmBackend> >&&, llvm::raw_pwrite_stream&, std::__1::unique_ptr<llvm::MCCodeEmitter, std::__1::default_delete<llvm::MCCodeEmitter> >&&, bool, bool, bool) + 5749
11 clang 0x00000001032c37f2 llvm::MCStreamer::Finish() + 306
12 clang 0x0000000103d6e271 llvm::AsmPrinter::doFinalization(llvm::Module&) + 3489
13 clang 0x0000000102ffa740 llvm::FPPassManager::doFinalization(llvm::Module&) + 80
14 clang 0x0000000102ffac8d llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1277
15 clang 0x000000010380cd33 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) + 15571
16 clang 0x0000000103a44ed5 clang::EmitObjAction::EmitObjAction(llvm::LLVMContext*) + 2341
17 clang 0x0000000103d10ccc clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) + 44
18 clang 0x00000001044cdfb5 clang::ParseAST(clang::Sema&, bool, bool) + 469
19 clang 0x0000000103ccdfdc clang::FrontendAction::Execute() + 76
20 clang 0x0000000103c86e41 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1217
21 clang 0x0000000103d340fa clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 4970
22 clang 0x0000000101c86a57 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1399
23 clang 0x0000000101c850df main + 11951
24 libdyld.dylib 0x00007fffeb788255 start + 1
I'll try to get a reproducer.
On Tue, Nov 7, 2017 at 6:40 AM, Petar Jovanovic via llvm-commits <llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>> wrote:
Author: petarj
Date: Tue Nov 7 06:40:27 2017
New Revision: 317579
URL: http://llvm.org/viewvc/llvm-project?rev=317579&view=rev
Log:
Reland "Correct dwarf unwind information in function epilogue for X86"
Reland r317100 with minor fix regarding ComputeCommonTailLength function in
BranchFolding.cpp. Skipping top CFI instructions block needs to executed on
several more return points in ComputeCommonTailLength().
Original r317100 message:
"Correct dwarf unwind information in function epilogue for X86"
This patch aims to provide correct dwarf unwind information in function
epilogue for X86.
It consists of two parts. The first part inserts CFI instructions that set
appropriate cfa offset and cfa register in emitEpilogue() in
X86FrameLowering. This part is X86 specific.
The second part is platform independent and ensures that:
- CFI instructions do not affect code generation
- Unwind information remains correct when a function is modified by
different passes. This is done in a late pass by analyzing information
about cfa offset and cfa register in BBs and inserting additional CFI
directives where necessary.
Changed CFI instructions so that they:
- are duplicable
- are not counted as instructions when tail duplicating or tail merging
- can be compared as equal
Added CFIInstrInserter pass:
- analyzes each basic block to determine cfa offset and register valid at
its entry and exit
- verifies that outgoing cfa offset and register of predecessor blocks match
incoming values of their successors
- inserts additional CFI directives at basic block beginning to correct the
rule for calculating CFA
Having CFI instructions in function epilogue can cause incorrect CFA
calculation rule for some basic blocks. This can happen if, due to basic
block reordering, or the existence of multiple epilogue blocks, some of the
blocks have wrong cfa offset and register values set by the epilogue block
above them.
CFIInstrInserter is currently run only on X86, but can be used by any target
that implements support for adding CFI instructions in epilogue.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171208/067e85bd/attachment.html>
More information about the llvm-commits
mailing list