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.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
/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. |
Comment Actions
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). |
/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? |
Comment Actions
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? |