This is an archive of the discontinued LLVM Phabricator instance.

[ARM SEH 1] [llvm-readobj] Fix printing of Windows ARM unwind opcodes, add tests
ClosedPublic

Authored by mstorsjo on May 15 2022, 2:29 PM.

Details

Summary

The existing code was essentially untested; in some cases, it used
too narrow variable types to fit all the bits, in some cases the
bit manipulation operations were incorrect.

For the "ldr lr, [sp], #x" opcode, there's nothing in the documentation
that says it cannot be used in a prologue. (In practice, it would
probably seldom be used there, but technically there's nothing
stopping it from being used.) The documentation only specifies the
operation to replay for unwinding it, but the corresponding mirror
instruction to be printed for a prologue is "str lr, [sp, #-x]!".

Also improve printing of register masks, by aggregating registers
into ranges where possible, and make the printing of the terminating
branches clearer, as "bx <reg>" and "b.w <target>".

Diff Detail

Event Timeline

mstorsjo created this revision.May 15 2022, 2:29 PM
Herald added a project: Restricted Project. · View Herald Transcript
mstorsjo requested review of this revision.May 15 2022, 2:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2022, 2:29 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
efriedma added inline comments.May 16 2022, 11:33 AM
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
77

Is RT_POP simply unused?

204

While you're here, can you split printRegisters() into separate functions PrintGPRRegisters/PrintVFPRegisters? You've extracted out most of the shared logic anyway.

979

The isAArch64 || !XData.F() checks feel weird; even if the "F" bit is set, the prologue still has an effect. (The AArch64 equivalent is a prologue where the first opcode is end_c.) I think I'd prefer to just unconditionally print the prologue.

efriedma added inline comments.May 16 2022, 11:50 AM
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
77

Oh, nevermind, there's casts to the enum.

204

Just saw this is in the followup patch.

mstorsjo added inline comments.May 16 2022, 1:53 PM
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
979

Yep, I agree. I clearly hadn't understood the fragments properly when I implemented this part.

mstorsjo updated this revision to Diff 429999.May 17 2022, 4:45 AM

Always print the prologue for fragments

This revision is now accepted and ready to land.May 17 2022, 4:56 PM
This revision was landed with ongoing or failed builds.May 18 2022, 12:18 AM
This revision was automatically updated to reflect the committed changes.