diff options
| author | Johannes Doerfert <johannes@jdoerfert.de> | 2019-11-01 18:45:25 -0500 |
|---|---|---|
| committer | Johannes Doerfert <johannes@jdoerfert.de> | 2019-11-02 00:32:39 -0500 |
| commit | e360ee62650609112b08e4ab2249e1e5a8c9e0d0 (patch) | |
| tree | 27dbae5938136db9455cf7b0649ac10bf2f661e5 /llvm/lib/Transforms | |
| parent | ed47a9cde4f667058ac34ef7805fc4093a5a4f7b (diff) | |
| download | bcm5719-llvm-e360ee62650609112b08e4ab2249e1e5a8c9e0d0.tar.gz bcm5719-llvm-e360ee62650609112b08e4ab2249e1e5a8c9e0d0.zip | |
[Attributor][FIX] Make AAValueSimplifyArgument aware of thread-dependent constants
As in IPConstantProp, thread-dependent constants need not be propagated
over callbacks. Took the comment and test from there, see also D56447.
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/Attributor.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 3d6a2c6f94f..4c8bb0f51e9 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -3653,9 +3653,19 @@ struct AAValueSimplifyArgument final : AAValueSimplifyImpl { auto PredForCallSite = [&](AbstractCallSite ACS) { // Check if we have an associated argument or not (which can happen for // callback calls). - if (Value *ArgOp = ACS.getCallArgOperand(getArgNo())) - return checkAndUpdate(A, *this, *ArgOp, SimplifiedAssociatedValue); - return false; + Value *ArgOp = ACS.getCallArgOperand(getArgNo()); + if (!ArgOp) + return false; + // We can only propagate thread independent values through callbacks. + // This is different to direct/indirect call sites because for them we + // know the thread executing the caller and callee is the same. For + // callbacks this is not guaranteed, thus a thread dependent value could + // be different for the caller and callee, making it invalid to propagate. + if (ACS.isCallbackCall()) + if (auto *C =dyn_cast<Constant>(ArgOp)) + if (C->isThreadDependent()) + return false; + return checkAndUpdate(A, *this, *ArgOp, SimplifiedAssociatedValue); }; if (!A.checkForAllCallSites(PredForCallSite, *this, true)) |

