Sumanth Gundapaneni via llvm-dev
2017-May-04 17:36 UTC
[llvm-dev] Look up table in function section
I have legit requirement to keep the switch generated lookup table in function section. The lookup table is being generated in SimplifyCFG pass and is treated as a global. Is there a good way to mark these lookup tables and recognize them later to keep them in function sections. --Sumanth -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170504/4447c5fa/attachment.html>
Friedman, Eli via llvm-dev
2017-May-04 18:08 UTC
[llvm-dev] Look up table in function section
On 5/4/2017 10:36 AM, Sumanth Gundapaneni via llvm-dev wrote:> > I have legit requirement to keep the switch generated lookup table in > function section. > > The lookup table is being generated in SimplifyCFG pass and is treated > as a global. > > Is there a good way to mark these lookup tables and recognize them > later to keep them in function sections. >There are target hooks to suppress the generation of lookup tables, if you need that. See shouldBuildLookupTables and shouldBuildLookupTablesForConstant in TargetTransformInfo. If you need something beyond that, you'll have to modify the transform. You can set a section on a global, but it sounds like that isn't what you want? In terms of putting IR globals into a function, the only precedent I can think of is the arm-constant-promote transform. -Eli -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170504/0d0d76cd/attachment.html>
Friedman, Eli via llvm-dev
2017-May-04 18:10 UTC
[llvm-dev] Look up table in function section
On 5/4/2017 11:08 AM, Friedman, Eli via llvm-dev wrote:> On 5/4/2017 10:36 AM, Sumanth Gundapaneni via llvm-dev wrote: >> >> I have legit requirement to keep the switch generated lookup table in >> function section. >> >> The lookup table is being generated in SimplifyCFG pass and is >> treated as a global. >> >> Is there a good way to mark these lookup tables and recognize them >> later to keep them in function sections. >> > > There are target hooks to suppress the generation of lookup tables, if > you need that. See shouldBuildLookupTables and > shouldBuildLookupTablesForConstant in TargetTransformInfo. If you > need something beyond that, you'll have to modify the transform. You > can set a section on a global, but it sounds like that isn't what you > want? > > In terms of putting IR globals into a function, the only precedent I > can think of is the arm-constant-promote transform.Err, sorry, I meant "arm-promote-constant"; see promoteToConstantPool in ARMISelLowering.cpp. -Eli -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170504/80ee9c05/attachment.html>
Tim Northover via llvm-dev
2017-May-04 18:51 UTC
[llvm-dev] Look up table in function section
On 4 May 2017 at 11:08, Friedman, Eli via llvm-dev <llvm-dev at lists.llvm.org> wrote:> In terms of putting IR globals into a function, the only precedent I can > think of is the arm-constant-promote transform.Jump table location is configurable for the generic case too (obviously, assuming an IR pass hasn't already made that decision for you). The callback is TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection, and I believe that just puts the tables at the end of a function. It's not usually that useful though: more gadgets to exploit and in the RISCy targets I know of you still have to address them as a full-on global to ensure they're in range. If at all possible, I wouldn't recommend going the ARMConstantIslands route and putting the tables in the middle of a function. That pass is a constant source of bugs. Tim.