This is an archive of the discontinued LLVM Phabricator instance.

[Assembler] Add test for !srcloc references in assembler diags
ClosedPublic

Authored by sanwou01 on Feb 20 2017, 7:14 AM.

Details

Summary

clang adds !srcloc metadata to inline assembly in LLVM bitcode generated
for inline assembly in C. The value of this !srcloc is passed to the
diagnostics handler if the inline assembly generates a diagnostic.
clang is able to turn this cookie back to a location in the C source
file.

To test this functionality without a dependency, make llc print the
!srcloc metadata if it is present. The added test uses this mechanism
to test that the correct !srclocs are passed to the diag handler.

Diff Detail

Repository
rL LLVM

Event Timeline

sanwou01 created this revision.Feb 20 2017, 7:14 AM
mehdi_amini added inline comments.Feb 20 2017, 10:16 AM
tools/llc/llc.cpp
266 ↗(On Diff #89117)

That could be noisy, wouldn't it? Maybe have an option to enable displaying this in llc?
Also, it this note following another message? What does it look like? (the note alone wouldn't be great).

sanwou01 added inline comments.Feb 21 2017, 3:30 AM
tools/llc/llc.cpp
266 ↗(On Diff #89117)

I did consider the noisiness of this message. Consider, the note is only printed if

  • !srcloc metadata is present; only the case in a clang-generated .ll file from a file containing inline assembly, and
  • a diagnostic is emitted from IR with !srcloc metadata, and
  • the .ll file is assembled using llc; none of the other tools are affected.

In short, this should not be very noisy.

Also, the note is always associated with the diagnostic printed by the SMD.print() above, so it is always printed after the proper diagnostic, e.g.:

<inline asm>:1:1: error: unknown instruction
              wibble
              ^
note: !srcloc = 107

Is this acceptable?

Could I please ask someone to have a look if they have a moment?

aka

ping :-)

mehdi_amini accepted this revision.Feb 27 2017, 8:53 AM

LGMT

tools/llc/llc.cpp
266 ↗(On Diff #89117)

Is this acceptable?

Sure! Thanks.

This revision is now accepted and ready to land.Feb 27 2017, 8:53 AM
This revision was automatically updated to reflect the committed changes.