Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
5155 ↗ | (On Diff #107168) | Just use Fn->getName() below directly. |
5157 ↗ | (On Diff #107168) | ...and the attribute "..." is not set. |
test/Transforms/SimplifyCFG/Hexagon/disable-lookup-table.ll | ||
60 ↗ | (On Diff #107168) | Can you reduce this further? |
test/Transforms/SimplifyCFG/disable-lookup-table.ll | ||
29 ↗ | (On Diff #107168) | Since this is a bit fragile when it comes to other optimizations deciding to merge the ranges, can you test the reverse as well? I.e. that it is turned into a lookup table when just the attribute is missing. |
For backends with "tightly coupled memory", in scenarios where the data is far away from text pays a good amount of penalty in terms of latency.
Hexagon is one such backend. The tables (both lookup and jump) which are being generated are treated as globals with internal linkage and by default
will be placed in read only data.
Interestingly when programmers specify the command line flag "-fno-jump-tables", they assume there is no data that goes in to other sections.
In case of llvm, the attribute "no-jump-tables" has no effect on simplifyCFG which generates the lookup table. This leads me to introduce "no-lookup-tables"
It looks like TargetTransformInfo already has a hook, shouldBuildLookupTables(), for disabling this optimization. Why not just set that to false for Hexagon?
lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
5155 ↗ | (On Diff #107168) | FuncName is being used below to set the name of the table to switch.table.<FuncName> |
It looks like TargetTransformInfo already has a hook, shouldBuildLookupTables(), for disabling this optimization. Why not just set that to false for Hexagon?
TCM is often small and you don't want to either enable or disable the table generation for a specific backend. As of today,
hexagon-emit-lookup-tables llvm flag control the generation of lookup tables for hexagon backend.
The real problem here is , I do not want the user to use a combination of front end and backend flags to get the desired result.
We have decided to have this feature under "-fno-jump-tables" clang flag.
To this affect, this patch updates the code to control the generation of
lookup tables based on the attribute "no-jump-tables"
"Generate lookup tables based on a function attribute" is not very descriptive. How about "Make the no-jump-tables attribute also disable switch lookup tables"?
Also it makes me sad that the attribute isn't documented anywhere. Would you like to look into that, possible as a follow-up patch?
lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
5155 ↗ | (On Diff #108516) | There doesn't seem to be any need to move FuncName up here anymore, since it's not used until further down. |
Also it makes me sad that the attribute isn't documented anywhere. Would you like to look into that, possible as a follow-up patch?
Sure. I will push a follow up patch
I moved SimplifyCFG/disable-lookup-table.ll into SimplifyCFG/X86/disable-lookup-table.ll to avoid test failure when X86 backend is not enabled (rL309487).
Please update again if you prefer another way to avoid test failure. Thanks!