From b8ca4ff6439c1543a0c6729cbcd6c70c3be7dc3c Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Sat, 13 Sep 2008 12:45:50 +0000 Subject: Fix PR2792: treat volatile loads as writing memory somewhere. Treat stores as reading memory, just to play safe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56188 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/IPA/GlobalsModRef.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/Analysis/IPA/GlobalsModRef.cpp') diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index 390a602..74327d5 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -431,12 +431,20 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) { for (inst_iterator II = inst_begin(SCC[i]->getFunction()), E = inst_end(SCC[i]->getFunction()); II != E && FunctionEffect != ModRef; ++II) - if (isa(*II)) + if (isa(*II)) { FunctionEffect |= Ref; - else if (isa(*II)) + if (cast(*II).isVolatile()) + // Volatile loads may have side-effects, so mark them as writing + // memory (for example, a flag inside the processor). + FunctionEffect |= Mod; + } else if (isa(*II)) { FunctionEffect |= Mod; - else if (isa(*II) || isa(*II)) + if (cast(*II).isVolatile()) + // Treat volatile stores as reading memory somewhere. + FunctionEffect |= Ref; + } else if (isa(*II) || isa(*II)) { FunctionEffect |= ModRef; + } if ((FunctionEffect & Mod) == 0) ++NumReadMemFunctions; -- cgit v1.1