[llvm] 20531b3 - [RelLookupTableConverter] Avoid querying TTI for declarations
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 16 02:39:35 PDT 2022
Author: Nikita Popov
Date: 2022-03-16T10:39:28+01:00
New Revision: 20531b3a6b091b8dd2e3992aec11ac10581e91e2
URL: https://github.com/llvm/llvm-project/commit/20531b3a6b091b8dd2e3992aec11ac10581e91e2
DIFF: https://github.com/llvm/llvm-project/commit/20531b3a6b091b8dd2e3992aec11ac10581e91e2.diff
LOG: [RelLookupTableConverter] Avoid querying TTI for declarations
This code queries TTI on a single function, which is considered to
be representative. This is a bit odd, but probably fine in practice.
However, I think we should at least avoid querying declarations,
which e.g. will generally lack target attributes, and for which
we don't seem to ever query TTI in other places.
Added:
Modified:
llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp b/llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp
index fd52285124c1b..037f42f5b0509 100644
--- a/llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp
+++ b/llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp
@@ -170,13 +170,17 @@ static void convertToRelLookupTable(GlobalVariable &LookupTable) {
// Convert lookup tables to relative lookup tables in the module.
static bool convertToRelativeLookupTables(
Module &M, function_ref<TargetTransformInfo &(Function &)> GetTTI) {
- Module::iterator FI = M.begin();
- if (FI == M.end())
- return false;
+ for (Function &F : M) {
+ if (F.isDeclaration())
+ continue;
- // Check if we have a target that supports relative lookup tables.
- if (!GetTTI(*FI).shouldBuildRelLookupTables())
- return false;
+ // Check if we have a target that supports relative lookup tables.
+ if (!GetTTI(F).shouldBuildRelLookupTables())
+ return false;
+
+ // We assume that the result is independent of the checked function.
+ break;
+ }
bool Changed = false;
More information about the llvm-commits
mailing list