diff options
author | James Molloy <james.molloy@arm.com> | 2015-10-28 10:41:29 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2015-10-28 10:41:29 +0000 |
commit | c67dec690f7a26522c22bdec569a888788a315d6 (patch) | |
tree | 5731c7ecf60286df5a8c0a729bf589ea73bde88f /llvm/lib/Analysis/GlobalsModRef.cpp | |
parent | 89ea433bd63f8d027fc66d6dbc4153464a65ec10 (diff) | |
download | llvm-c67dec690f7a26522c22bdec569a888788a315d6.zip llvm-c67dec690f7a26522c22bdec569a888788a315d6.tar.gz llvm-c67dec690f7a26522c22bdec569a888788a315d6.tar.bz2 |
[GlobalsAA] An indirect global that is initialized is not fair game
When checking if an indirect global (a global with pointer type) is only assigned by allocation functions, first check if the global is itself initialized. If it is, it's not only assigned by allocation functions.
This fixes PR25309. Thanks to David Majnemer for reducing the test case!
llvm-svn: 251508
Diffstat (limited to 'llvm/lib/Analysis/GlobalsModRef.cpp')
-rw-r--r-- | llvm/lib/Analysis/GlobalsModRef.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp index 3b808e3..c809ff8 100644 --- a/llvm/lib/Analysis/GlobalsModRef.cpp +++ b/llvm/lib/Analysis/GlobalsModRef.cpp @@ -395,11 +395,16 @@ bool GlobalsAAResult::AnalyzeUsesOfPointer(Value *V, /// Further, all loads out of GV must directly use the memory, not store the /// pointer somewhere. If this is true, we consider the memory pointed to by /// GV to be owned by GV and can disambiguate other pointers from it. -bool GlobalsAAResult::AnalyzeIndirectGlobalMemory(GlobalValue *GV) { +bool GlobalsAAResult::AnalyzeIndirectGlobalMemory(GlobalVariable *GV) { // Keep track of values related to the allocation of the memory, f.e. the // value produced by the malloc call and any casts. std::vector<Value *> AllocRelatedValues; + // If the initializer is a valid pointer, bail. + if (Constant *C = GV->getInitializer()) + if (!C->isNullValue()) + return false; + // Walk the user list of the global. If we find anything other than a direct // load or store, bail out. for (User *U : GV->users()) { |