This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Registering default MCInstrAnalysis
ClosedPublic

Authored by aizatsky on Aug 11 2016, 2:10 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

aizatsky updated this revision to Diff 67748.Aug 11 2016, 2:10 PM
aizatsky retitled this revision from to [AArch64] Registering default MCInstrAnalysis Even in this form it s useful: it can detect branch instructions..
aizatsky updated this object.
aizatsky retitled this revision from [AArch64] Registering default MCInstrAnalysis Even in this form it s useful: it can detect branch instructions. to [AArch64] Registering default MCInstrAnalysis .Aug 11 2016, 2:12 PM
aizatsky updated this object.
aizatsky added a project: Restricted Project.
t.p.northover edited edge metadata.Aug 11 2016, 2:13 PM
t.p.northover added a subscriber: llvm-commits.

I just added llvm-commits to the subscribers, otherwise the mailing list won't see the patch.

It looks like this ought to be testable from llvm-objdump (it seems to ise the MCInstrAnalysis to produce better output for branches).

It looks like this ought to be testable from llvm-objdump (it seems to ise the MCInstrAnalysis to produce better output for branches).

No, not yet. It requires evaluateBranch to work. And that one doesn't work for AArch64 because offset arguments are not correctly annotated in assembly. (https://github.com/google/sanitizers/issues/706)

I was going to try to address the second issue in the next change. BTW if you have any pointers towards what needs to be changed, I would be grateful for any help/pointers.

And that one doesn't work for AArch64 because offset arguments are not correctly annotated in assembly. (https://github.com/google/sanitizers/issues/706).

Looking at the default implementation my best guess is that MI.getOperand(0).getImm() actually returns Offset / 4 for branches on AArch64 (because instructions must always be 4-byte aligned).

But I could be wrong, because I don't know exactly how it's failing.

Tim.

Depending on how you implement the AArch64 override you may want to set the branch operands to OPERAND_PCREL in the AArch64InstrInfo.td files to. Checking the opcodes directly is probably fine too though (you've got to know about them anyway to find the offset operand).

Depending on how you implement the AArch64 override you may want to set the branch operands to OPERAND_PCREL in the AArch64InstrInfo.td files to. Checking the opcodes directly is probably fine too though (you've got to know about them anyway to find the offset operand).

You are right, OperandType != MCOI::OPERAND_PCREL is never successful. Didn't look into getImm yet.

aizatsky updated this revision to Diff 67887.Aug 12 2016, 1:11 PM
aizatsky retitled this revision from [AArch64] Registering default MCInstrAnalysis to [AArch64] Registering default MCInstrAnalysis.
aizatsky edited edge metadata.

added test.

I managed to test this with my sancov tool. It can't print addresses yet, but at least it can initialize the instruction analysis.

Oh good! This looks fine, thanks for adding the test.

Tim.

This revision was automatically updated to reflect the committed changes.