This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Make -g with empty assembler source work better.
ClosedPublic

Authored by probinson on Feb 27 2019, 5:23 PM.

Details

Summary

This was sometimes causing clang or llvm-mc to crash, and in other
cases could emit a bogus DWARF line-table header. This should be a
cleaner and more complete fix than r352541.

Addresses PR40538.

Diff Detail

Event Timeline

probinson created this revision.Feb 27 2019, 5:23 PM
probinson edited the summary of this revision. (Show Details)Feb 27 2019, 5:24 PM
aprantl added inline comments.Feb 27 2019, 5:37 PM
clang/tools/driver/cc1as_main.cpp
336

Why not move this to line 411?

llvm/lib/MC/MCDwarf.cpp
1018

Are there guaranteed to be >1 MCDwarfFiles?

probinson marked 2 inline comments as done.Feb 28 2019, 7:37 AM
probinson added inline comments.
clang/tools/driver/cc1as_main.cpp
336

Because on line 341, we std::move(*Buffer) into SrcMgr. I could try to figure out how to extract it from SrcMgr afterward, I guess.

llvm/lib/MC/MCDwarf.cpp
1018

Yes, because MCDwarfFiles[0] is never used. If it's non-empty, size will be at least 2. I could expand on the comment to say so; there's another place where I have a comment like that.

probinson updated this revision to Diff 188792.Feb 28 2019, 2:32 PM

Address review comments & rebase.

probinson marked 2 inline comments as done.Feb 28 2019, 2:32 PM
aprantl accepted this revision.Feb 28 2019, 2:35 PM
This revision is now accepted and ready to land.Feb 28 2019, 2:35 PM
dblaikie added inline comments.Feb 28 2019, 3:56 PM
llvm/lib/MC/MCContext.cpp
586

No need for the "(void)" here - this function isn't marked NO_DISCARD or anything liek that, by the looks of it?

probinson marked 2 inline comments as done.Feb 28 2019, 4:04 PM
probinson added inline comments.
llvm/lib/MC/MCContext.cpp
586

No, it's not. Wasn't entirely sure what the criteria were. I'll remove this.

This revision was automatically updated to reflect the committed changes.
probinson marked an inline comment as done.