This is an archive of the discontinued LLVM Phabricator instance.

Fix - CodeExtractor : Inherit Target Dependent Attributes from the parent function.
ClosedPublic

Authored by rriddle on Jul 22 2016, 6:08 PM.

Details

Summary

When extracting a set of blocks make sure to inherit all of the target dependent attributes to make sure that the function will be valid for lowering. One example is the "target-features" attribute for x86, if the extracted region has functionality that relies on a specific feature it will fail to be lowered.
This also allows for extracted functions to be valid for inlining, at least back into the parent function, as the target attributes are tested when inlining for compatibility.

Diff Detail

Repository
rL LLVM

Event Timeline

rriddle updated this revision to Diff 65201.Jul 22 2016, 6:08 PM
rriddle retitled this revision from to Fix - CodeExtractor : Inherit Target Dependent Attributes from the parent function..
rriddle updated this object.
rriddle added a reviewer: davide.
rriddle updated this object.
rriddle updated this object.
rriddle added a subscriber: llvm-commits.
majnemer added inline comments.
/Users/rriddle/Desktop/llvm/llvm/lib/Transforms/Utils/CodeExtractor.cpp
344 ↗(On Diff #65201)

space after if

353 ↗(On Diff #65201)

space after for

388 ↗(On Diff #65201)

space before {

/Users/rriddle/Desktop/llvm/llvm/test/Transforms/CodeExtractor/2016-07-20-InheritAttributes.ll
33–34 ↗(On Diff #65201)

This doesn't do anything because you never pipe into FileCheck.

rriddle updated this revision to Diff 65252.Jul 23 2016, 1:43 PM

Updated formatting and fixed error in test case

silvas added a subscriber: silvas.Jul 27 2016, 1:38 AM

The convention of putting the date in the test file name is no longer in fashion, so you can call the test file just InheritAttributes.ll

/Users/rriddle/Desktop/llvm/llvm/lib/Transforms/Utils/CodeExtractor.cpp
393 ↗(On Diff #65252)

Can you split this into a separate patch with its own test case?

/Users/rriddle/Desktop/llvm/llvm/test/Transforms/CodeExtractor/2016-07-20-InheritAttributes.ll
1 ↗(On Diff #65252)

You should also add a RUN line that pipes to FileCheck and actually checks for the expected result (e.g. specific attributes on the extracted function).

silvas added inline comments.Jul 27 2016, 4:30 PM
/Users/rriddle/Desktop/llvm/llvm/lib/Transforms/Utils/CodeExtractor.cpp
352 ↗(On Diff #65252)

Can you add a FIXME here that there may be target-dependent attributes that can't be copied?

rriddle updated this revision to Diff 66022.Jul 28 2016, 2:55 PM

Updated after Sean's comments

silvas accepted this revision.Jul 28 2016, 11:50 PM
silvas added a reviewer: silvas.

LGTM with a nit

test/Transforms/CodeExtractor/InheritTargetAttributes.ll
3 ↗(On Diff #66022)

Can you mention what explicitly goes wrong if we don't inherit them?

This revision is now accepted and ready to land.Jul 28 2016, 11:50 PM
rriddle updated this revision to Diff 66083.Jul 28 2016, 11:56 PM
rriddle edited edge metadata.

Fixed test description

Do you need me to commit this for you?

This revision was automatically updated to reflect the committed changes.

Should be committed in r277315, thanks!