diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/IPO/Attributor.cpp | 16 | ||||
| -rw-r--r-- | llvm/test/Transforms/IPConstantProp/thread_local_acs.ll | 1 |
2 files changed, 14 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)) diff --git a/llvm/test/Transforms/IPConstantProp/thread_local_acs.ll b/llvm/test/Transforms/IPConstantProp/thread_local_acs.ll index 0595a5ca7f1..6e10d23c145 100644 --- a/llvm/test/Transforms/IPConstantProp/thread_local_acs.ll +++ b/llvm/test/Transforms/IPConstantProp/thread_local_acs.ll @@ -1,4 +1,5 @@ ; RUN: opt -ipconstprop -S < %s | FileCheck %s +; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=1 < %s | FileCheck %s ; ; #include <threads.h> ; thread_local int gtl = 0; |

