From 889a20cf40c8e61a62e32bef38a0abea6194d6f1 Mon Sep 17 00:00:00 2001 From: Nicolai Haehnle Date: Mon, 11 Jul 2016 14:11:51 +0000 Subject: [Sink] Don't move calls to readonly functions across stores Summary: Reviewers: hfinkel, majnemer, tstellarAMD, sunfish Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17279 llvm-svn: 275066 --- llvm/lib/Transforms/Scalar/Sink.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/Sink.cpp b/llvm/lib/Transforms/Scalar/Sink.cpp index 5fa43bda9d0..d9a296c6312 100644 --- a/llvm/lib/Transforms/Scalar/Sink.cpp +++ b/llvm/lib/Transforms/Scalar/Sink.cpp @@ -76,11 +76,15 @@ static bool isSafeToMove(Instruction *Inst, AliasAnalysis &AA, Inst->mayThrow()) return false; - // Convergent operations cannot be made control-dependent on additional - // values. if (auto CS = CallSite(Inst)) { + // Convergent operations cannot be made control-dependent on additional + // values. if (CS.hasFnAttr(Attribute::Convergent)) return false; + + for (Instruction *S : Stores) + if (AA.getModRefInfo(S, CS) & MRI_Mod) + return false; } return true; -- cgit v1.2.3