summaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
diff options
context:
space:
mode:
authorSjoerd Meijer <sjoerd.meijer@arm.com>2021-10-12 11:03:34 +0100
committerSjoerd Meijer <sjoerd.meijer@arm.com>2021-10-12 11:44:26 +0100
commitfc0fa85171e665f92cee97635bc3a5af8785aa8d (patch)
tree226b000d1638ee65fd7a6d51e370a7dad89426e4 /llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
parentcd0ba9dc58c5806f4e3cc9635ab1f64af6973a83 (diff)
[FuncSpec] Allow ConstExprs that are function pointers
This is a follow up of D110529 that disallowed constexprs. That change introduced a regression as this also disallowed constexprs that are function pointers, which is actually one of the motivating use cases that we do want to support. Differential Revision: https://reviews.llvm.org/D111567
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionSpecialization.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionSpecialization.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
index 0d2d55aa0cf7..8ab5311fd435 100644
--- a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -677,8 +677,12 @@ private:
auto *V = CS.getArgOperand(A->getArgNo());
if (isa<PoisonValue>(V))
return false;
- if (isa<ConstantExpr>(V))
- return false;
+
+ // For now, constant expressions are fine but only if they are function
+ // calls.
+ if (auto *CE = dyn_cast<ConstantExpr>(V))
+ if (!isa<Function>(CE->getOperand(0)))
+ return false;
// TrackValueOfGlobalVariable only tracks scalar global variables.
if (auto *GV = dyn_cast<GlobalVariable>(V)) {