This is an archive of the discontinued LLVM Phabricator instance.

[dfsan] Add explicit zero extensions for shadow parameters in function wrappers.
ClosedPublic

Authored by sdardis on May 19 2017, 2:24 AM.

Details

Summary

In the case where dfsan provides a custom wrapper for a function,
shadow parameters are added for each parameter of the function.
These parameters are i16s. For targets which do not consider this
a legal type, the lack of sign extension information would cause
LLVM to generate anyexts around their usage with phi variables
and calling convention logic.

Address this by introducing zero exts for each shadow parameter.

Diff Detail

Repository
rL LLVM

Event Timeline

sdardis created this revision.May 19 2017, 2:24 AM
pcc edited edge metadata.May 19 2017, 11:22 AM

Test case?

sdardis updated this revision to Diff 99946.May 23 2017, 10:21 AM

Add test case, change logic for add zext attributes so that all shadow parameters are covered, not just the first.

pcc added inline comments.May 31 2017, 1:20 PM
lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
1529 ↗(On Diff #99946)

I'm a little uncomfortable with this because it seems like we're effectively dropping attributes from the call instruction. If we don't expect to create a function definition the attributes on the declaration shouldn't matter, so maybe we should be adding the zeroext attributes just to the call rather than to the declaration.

sdardis updated this revision to Diff 111346.Aug 16 2017, 8:03 AM
sdardis edited the summary of this revision. (Show Details)

Address review comments.

pcc accepted this revision.Aug 16 2017, 8:07 PM

LGTM

test/Instrumentation/DataFlowSanitizer/shadow-args-zext.ll
9 ↗(On Diff #111346)

Prefer to move this and the two below inline with the original IR.

This revision is now accepted and ready to land.Aug 16 2017, 8:07 PM
This revision was automatically updated to reflect the committed changes.
sdardis marked an inline comment as done.

Thanks for the review.