This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][InstrRef] Fix over-droppage of locations from X86FloatingPoint fixup pass
ClosedPublic

Authored by jmorse on Aug 23 2021, 1:26 PM.

Details

Summary

Over in D105657, we started dropping instruction numbers (that become variable locations) from call instructions, as we can't correctly represent the x87 FP stack. Unfortunately, it turns out that the "special FP instructions" that this pass transforms includes "every call instruction" [0]. Thus, we've ended up dropping all return values from all calls. Ouch.

This patch adds a filter: only drop instruction numbers from calls if they return something on the FP stack. Seeing how LLVM only allows a single return value, this should drop instruction numbers on anything that returns a float, and nothing else.

Rather than writing a new test, I've modified the original one to have a positive and negative case: drop instruction number on a call with an FP-stack modification, keep it on a plain call.

(This patch removes a check for "ADD_F64m" -- this was only put in to ensure that we didn't accept spurious inputs, like a stack trace).

[0] https://github.com/llvm/llvm-project/blob/f46321207f7d28f21d0dfb3635933d1bd84b5e05/llvm/lib/Target/X86/X86FloatingPoint.cpp#L433

Diff Detail

Event Timeline

jmorse created this revision.Aug 23 2021, 1:26 PM
jmorse requested review of this revision.Aug 23 2021, 1:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2021, 1:26 PM
djtodoro accepted this revision.Aug 24 2021, 12:01 AM

Thanks!

This revision is now accepted and ready to land.Aug 24 2021, 12:01 AM

Some nits.

llvm/lib/Target/X86/X86FloatingPoint.cpp
1040–1041

Should update the comments?

llvm/test/DebugInfo/MIR/InstrRef/x86-fp-stackifier-drop-locations.mir
8

Should check the next CALLpcrel32 dropped debug-instr-number?

jmorse added inline comments.Aug 24 2021, 2:06 AM
llvm/lib/Target/X86/X86FloatingPoint.cpp
1040–1041

True -- I'll fold that in, thanks for the pointer.

llvm/test/DebugInfo/MIR/InstrRef/x86-fp-stackifier-drop-locations.mir
8

It should be caught by the --implicit-check-not on the FileCheck command line