summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-03 00:45:16 +0000
committerChris Lattner <sabre@nondot.org>2004-04-03 00:45:16 +0000
commit8ed3c8aa136ce09f8b5c9fa406180b9083bbd533 (patch)
tree073b030d406583268d77529495b721d5e4ea1204 /llvm/lib/Analysis
parentdb033fa425c622b47f4d854744cb690f167cca80 (diff)
downloadbcm5719-llvm-8ed3c8aa136ce09f8b5c9fa406180b9083bbd533.tar.gz
bcm5719-llvm-8ed3c8aa136ce09f8b5c9fa406180b9083bbd533.zip
Implement test/Regression/Transforms/GCSE/undefined_load.ll
llvm-svn: 12641
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/LoadValueNumbering.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LoadValueNumbering.cpp b/llvm/lib/Analysis/LoadValueNumbering.cpp
index b67aaddde32..97a57562bd7 100644
--- a/llvm/lib/Analysis/LoadValueNumbering.cpp
+++ b/llvm/lib/Analysis/LoadValueNumbering.cpp
@@ -22,6 +22,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/LoadValueNumbering.h"
+#include "llvm/Constant.h"
#include "llvm/Function.h"
#include "llvm/iMemory.h"
#include "llvm/iOther.h"
@@ -283,10 +284,14 @@ void LoadVN::getEqualNumberNodes(Value *V,
//
std::map<BasicBlock*, std::vector<LoadInst*> > CandidateLoads;
std::map<BasicBlock*, std::vector<StoreInst*> > CandidateStores;
+ std::set<AllocationInst*> Allocations;
while (!PointerSources.empty()) {
Value *Source = PointerSources.back();
PointerSources.pop_back(); // Get a source pointer...
+
+ if (AllocationInst *AI = dyn_cast<AllocationInst>(Source))
+ Allocations.insert(AI);
for (Value::use_iterator UI = Source->use_begin(), UE = Source->use_end();
UI != UE; ++UI)
@@ -329,6 +334,15 @@ void LoadVN::getEqualNumberNodes(Value *V,
if (isa<LoadInst>(I) && Instrs.count(I)) {
RetVals.push_back(I);
Instrs.erase(I);
+ } else if (AllocationInst *AI = dyn_cast<AllocationInst>(I)) {
+ // If we run into an allocation of the value being loaded, then the
+ // contenxt are not initialized. We can return any value, so we will
+ // return a zero.
+ if (Allocations.count(AI)) {
+ LoadInvalidatedInBBBefore = true;
+ RetVals.push_back(Constant::getNullValue(LI->getType()));
+ break;
+ }
}
if (AA.getModRefInfo(I, LoadPtr, LoadSize) & AliasAnalysis::Mod) {
OpenPOWER on IntegriCloud