Add function attribute to represent the avoidance of generation of jump tables.
This is an initial step to supporting gcc's -fno-jump-tables flag.
Details
Diff Detail
Event Timeline
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
7978 | There is already a helper function in this file that decides whether or not to build jump tables: areJTsAllowed(). That's a better place to do this check. If we really want to disable jump tables, maybe the proper thing to do is to make TLI.isOperationLegalOrCustom(BR_JT) return false. I don't know if that's more or less convenient to do, though. |
Rebased no-jump-tables to key on Function Attributes not target options and removed
added llc command line flag as we can now pass this information textually in the file
Code look straightforward. Using a function attribute looks good to me. See a nit below.
test/CodeGen/X86/switch.ll | ||
---|---|---|
46 | Update comment: Should never be lowered as a jump table because of the attribute. |
I missed where someone suggested making this a function attribute.
What's the motivation for wanting some functions to get jump tables, and not others? Isn't it something you'd want for the whole program?
What happens if a function with nousejumptable gets inlined into a function without the attribute?
So having it as a function attribute was my idea :)
Otherwise, it's a good question. What should happen in LTO when you ask for one translation unit to be compiled without jump table support and the other one to be compiled with jump table support? Which one wins here? For some things it's more obvious, I'm not sure here.
-eric
I suppose it depends on the motivation for this patch. Why would one be compiling with -no-jump-tables? Is it just an optimization thing, or could there be a situation where a jump table would actually not work, despite the target supporting it in general? (Apologies if this is obvious, but it would be great to have it explained in the description of this patch.)
OK, sounds like it should poison on inlining then. (And likely is going to be used everywhere, but maximum safety here).
Make no-jump-tables soft attribute as suggested in D18407 and union merged no-jump-tables flags on inline
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
7978 | Realized I hadn't addressed this. This was probably the right thing originally, but isn't possible now that no-jump-tables is a function attribute. |
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
7978 | Please make areJTsAllowed() take a Function* parameter and do the check there instead. That way, the code will not waste time in findJumpTables() only to decide later to not build any. |
Please make areJTsAllowed() take a Function* parameter and do the check there instead. That way, the code will not waste time in findJumpTables() only to decide later to not build any.
test/Transforms/Inline/attributes.ll | ||
---|---|---|
246 | Why are you killing the noimplicitfloat test? |
test/Transforms/Inline/attributes.ll | ||
---|---|---|
246 | That's a good question. This was copied over at one point. I must have botched a rebase. Will fix. |
Cleanup FnAttr lookup
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
7964 | It does. There are a few more instances of this pattern in the codebase. I'll submit those separately. |
I don't think the comment adds value here; it's very clear that this is what the code below does.