This is an archive of the discontinued LLVM Phabricator instance.

[llvm-profgen] Move profiled binary loading out of PerfReader
ClosedPublic

Authored by wlei on Aug 17 2021, 4:02 PM.

Details

Summary

Change to use unique pointer of profiled binary to unblock asan.

At same time, I realized we can decouple to move the profiled binary loading out of PerfReader, so I made some other related refactors.

Diff Detail

Event Timeline

wlei created this revision.Aug 17 2021, 4:02 PM
wlei requested review of this revision.Aug 17 2021, 4:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2021, 4:02 PM
wlei edited the summary of this revision. (Show Details)Aug 17 2021, 4:06 PM
wlei added reviewers: hoy, wenlei.
wlei updated this revision to Diff 367052.Aug 17 2021, 4:11 PM

fix one wrong code copy by mistake

wlei updated this revision to Diff 367053.Aug 17 2021, 4:15 PM

[NFC] remove two "getBinary"

hoy added a comment.Aug 17 2021, 4:22 PM

The code structure looks cleaner now, thanks.

llvm/tools/llvm-profgen/PerfReader.cpp
259

Is this moved to anywhere?

wlei added inline comments.Aug 17 2021, 4:29 PM
llvm/tools/llvm-profgen/PerfReader.cpp
259

Good catch, I was thinking the code below should catch the error, but I got it's better to remain the original logic.

// Attempt to open the binary.
OwningBinary<Binary> OBinary = unwrapOrError(createBinary(Path), Path);
Binary &Binary = *OBinary.getBinary();

auto *Obj = dyn_cast<ELFObjectFileBase>(&Binary);
if (!Obj)
  exitWithError("not a valid Elf image", Path);
wlei updated this revision to Diff 367056.Aug 17 2021, 4:29 PM

address Hongtao's feedback

hoy accepted this revision.Aug 17 2021, 4:40 PM
This revision is now accepted and ready to land.Aug 17 2021, 4:40 PM
wlei updated this revision to Diff 367061.Aug 17 2021, 4:48 PM

[NFC] tweak comments