This is an archive of the discontinued LLVM Phabricator instance.

[codeview] Decode and dump FP regs from S_FRAMEPROC records
ClosedPublic

Authored by rnk on Sep 10 2018, 3:31 PM.

Details

Summary

There are two registers encoded in the S_FRAMEPROC flags: one for locals
and one for parameters. The encoding is described by the
ExpandEncodedBasePointerReg function in cvinfo.h. Two bits are used to
indicate one of four possible values:

0: no register - Used when there are no variables.
1: SP / standard - Variables are stored relative to the standard SP
   for the ISA.
2: FP - Variables are addressed relative to the ISA frame
   pointer, i.e. EBP on x86. If realignment is required, parameters
   use this. If a dynamic alloca is used, locals will be EBP relative.
3: Alternative - Variables are stored relative to some alternative
   third callee-saved register. This is required to address highly
   aligned locals when there are dynamic stack adjustments. In this
   case, both the incoming SP saved in the standard FP and the current
   SP are at some dynamic offset from the locals. LLVM uses ESI in
   this case, MSVC uses EBX.

Most of the changes in this patch are to pass around the CPU so that we
can decode these into real, named architectural registers.

Event Timeline

rnk created this revision.Sep 10 2018, 3:31 PM
rnk added a reviewer: zturner.Sep 10 2018, 3:38 PM

Actually +@zturner this time.

zturner added inline comments.Sep 10 2018, 5:09 PM
llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h
796

Can you add an llvm_unreachable() here?

803–804

And here.

llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp
63

Having the Optional<> seems kinda lame. I think in other places that require "state" in order to dump we just assume that the thing we need is going to be there. Can we just default it to x86 if it's not present?

430–433

I keep seeing FP and reading "floating point". Is there any other abbreviation that can remove this ambiguity?

llvm/tools/llvm-readobj/COFFDumper.cpp
1154–1155

Yea, so in the minimal symbol dumper we default to X64 if we don't see it. Can we just do the same thing here and remove the Optional?

rnk marked 3 inline comments as done.Sep 11 2018, 2:40 PM
rnk added inline comments.
llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp
63

Sure. I feel like I was OCD at first, and then I was lazy for the minimal symbol dumper, but what the heck, less states is better.

430–433

Yeah, that's pretty bad. getLocalFramePtrReg?

rnk updated this revision to Diff 164975.Sep 11 2018, 2:41 PM
  • use less ambiguous name
  • pick a default CPU type for simplicity
zturner accepted this revision.Sep 11 2018, 2:48 PM
This revision is now accepted and ready to land.Sep 11 2018, 2:48 PM
This revision was automatically updated to reflect the committed changes.