diff options
author | Sumanth Gundapaneni <sgundapa@codeaurora.org> | 2017-07-28 22:25:40 +0000 |
---|---|---|
committer | Sumanth Gundapaneni <sgundapa@codeaurora.org> | 2017-07-28 22:25:40 +0000 |
commit | 8d50a50e986a76aa433aabd4fc22bc72c327f5b0 (patch) | |
tree | d5f1c66cbf5448a5f5e0262a789db06e5fa29fd2 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | f14996b962c4750ceaf675eefbc6cc1902b925ff (diff) | |
download | bcm5719-llvm-8d50a50e986a76aa433aabd4fc22bc72c327f5b0.tar.gz bcm5719-llvm-8d50a50e986a76aa433aabd4fc22bc72c327f5b0.zip |
[SimplifyCFG] Make the no-jump-tables attribute also disable switch lookup tables
Differential Revision: https://reviews.llvm.org/D35579
llvm-svn: 309444
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 8784b970214..6c9c44b1663 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -5151,8 +5151,11 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder, const TargetTransformInfo &TTI) { assert(SI->getNumCases() > 1 && "Degenerate switch?"); - // Only build lookup table when we have a target that supports it. - if (!TTI.shouldBuildLookupTables()) + Function *Fn = SI->getParent()->getParent(); + // Only build lookup table when we have a target that supports it or the + // attribute is not set. + if (!TTI.shouldBuildLookupTables() || + (Fn->getFnAttribute("no-jump-tables").getValueAsString() == "true")) return false; // FIXME: If the switch is too sparse for a lookup table, perhaps we could @@ -5333,7 +5336,7 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder, // If using a bitmask, use any value to fill the lookup table holes. Constant *DV = NeedMask ? ResultLists[PHI][0].second : DefaultResults[PHI]; - StringRef FuncName = SI->getParent()->getParent()->getName(); + StringRef FuncName = Fn->getName(); SwitchLookupTable Table(Mod, TableSize, MinCaseVal, ResultList, DV, DL, FuncName); |