Skip to content

Try disabling frame pointer elimination/enabling unwind tables to get backtraces #3957

Closed

Description

@benvanik

Follow-up from discord where full backtraces from our generated functions weren't showing in traces on Android.

On Windows this is what I did: https://github.com/google/iree/blob/e0ec2044f731db2c223809be822df3e361933571/iree%2Fcompiler%2FDialect%2FHAL%2FTarget%2FLLVM%2FAOT%2Finternal%2FWindowsLinkerTool.cpp#L80

That may be enough to replicate in UnixLinkerTools' configureModule - if it is, then we can make that common to both in the base LinkerTool class.

That may not work - my experience with DWARF is 10 years out of date so I have no idea if they even have unwind tables ;)

The other thing to try then is disabling frame pointer elimination, by adding this in the same configureModule function:

  for (auto &func : *llvmModule) {
    auto attrs = func.getAttributes();
    attrs = attrs.addAttribute(llvmModule->getContext(),
                               llvm::AttributeList::FunctionIndex,
                               "frame-pointer", "all");
    func.setAttributes(attrs);
  }

With this you should see on x86 some ebp manipulation at the start/end of each generated functions and hopefully some stack traces. Not sure what the equivalent to look for on arm is but I'm sure you do :)

The unwind tables are ideal as they don't change the code at all and are easy to strip (they're just extra sections in the final output) - but if we need the frame pointers to debug they are very cheap (~bytes/function) and worth always including on UnixLinkerTool.

Activity

  1. added
    bug 🐞
    codegen
    performance ⚡
    on Nov 21, 2020
  2. added this to the milestone on Nov 21, 2020
  3. added
    codegen/llvm
    and removed
    codegen
    on Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐞codegen/llvmperformance ⚡

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions