This is an archive of the discontinued LLVM Phabricator instance.

[dfsan] Add origin address calculation
ClosedPublic

Authored by stephan.yichao.zhao on Feb 19 2021, 9:51 AM.

Diff Detail

Event Timeline

stephan.yichao.zhao requested review of this revision.Feb 19 2021, 9:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 19 2021, 9:51 AM
morehouse added inline comments.Feb 19 2021, 10:18 AM
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
1554

We can avoid this AND operation entirely by including it in the shadow mask.

llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
1554

Yeah. ~0x700...0003 works. It seems that the problem is we wanted to get both shadow and origin addresses. So

  1. with the current approach,

offset = addr & ~0x700...00
shadow = offset x 2
origin = offset + origin_base
// When align is < 4, we may need one more origin & 4

  1. if we use ~0x700...03

offset_s = addr & ~0x700...00
shadow = offset_s x 2
offset_o = addr & ~0x700...03
origin = offset_o + origin_base

So the case 1 actually uses 1 less IR instruction in most cases.

This revision is now accepted and ready to land.Feb 19 2021, 1:04 PM
This revision was landed with ongoing or failed builds.Feb 19 2021, 1:31 PM
This revision was automatically updated to reflect the committed changes.