This is an archive of the discontinued LLVM Phabricator instance.

[IRSim][IROutliner] Adding support for elevating constants that are not the same in each region to arguments
ClosedPublic

Authored by AndrewLitteken on Sep 8 2020, 9:53 AM.

Details

Summary

When there are constants that have the same structural location, but not the same value, between different regions, we cannot simply outline the region. Instead, we find the constants that are not the same in each location, and promote them to arguments to be passed into the respective functions. At each call site, we pass the constant in as an argument regardless of type.

Added/Edited Tests:

  • llvm/test/Transforms/IROutliner/outlining-constants-vs-registers.ll
  • llvm/test/Transforms/IROutliner/outlining-different-constants.ll
  • llvm/test/Transforms/IROutliner/outlining-different-globals.ll

Diff Detail

Event Timeline

AndrewLitteken created this revision.Sep 8 2020, 9:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2020, 9:53 AM
jroelofs added inline comments.
llvm/lib/Transforms/IPO/IROutliner.cpp
319

s/Seen/InInput/

might be a better name?

597

I'd expect an RAUW... what if the call returns something?

AndrewLitteken added inline comments.Sep 15 2020, 4:15 PM
llvm/lib/Transforms/IPO/IROutliner.cpp
597

The constructed functions do not return anything based on the CodeExtractor as they only contain single blocks. Additionally, this function only exists once since the extraction of a region only results in one function.

After extraction we replace the different calls with a call to the aggregate function we created.

jroelofs added inline comments.Sep 15 2020, 4:30 PM
llvm/lib/Transforms/IPO/IROutliner.cpp
597

Oh, I see. This is only acting on synthesized calls, not pre-existing ones.

Updating comments.

This revision is now accepted and ready to land.Sep 16 2020, 8:46 AM

Updating to reflect other patches.