mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-20 20:38:48 +00:00
Implement cast nodes correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2964 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f7ccb70604
commit
055dc2c67e
@ -248,9 +248,9 @@ void DSGraph::markIncompleteNodes() {
|
|||||||
markIncompleteNode(Args[i]);
|
markIncompleteNode(Args[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark all of the nodes pointed to by global nodes as incomplete...
|
// Mark all of the nodes pointed to by global or cast nodes as incomplete...
|
||||||
for (unsigned i = 0, e = Nodes.size(); i != e; ++i)
|
for (unsigned i = 0, e = Nodes.size(); i != e; ++i)
|
||||||
if (Nodes[i]->NodeType & DSNode::GlobalNode) {
|
if (Nodes[i]->NodeType & (DSNode::GlobalNode | DSNode::CastNode)) {
|
||||||
DSNode *N = Nodes[i];
|
DSNode *N = Nodes[i];
|
||||||
for (unsigned i = 0, e = N->getNumLinks(); i != e; ++i)
|
for (unsigned i = 0, e = N->getNumLinks(); i != e; ++i)
|
||||||
markIncompleteNode(N->getLink(i));
|
markIncompleteNode(N->getLink(i));
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/Analysis/DataStructure.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/iMemory.h"
|
#include "llvm/iMemory.h"
|
||||||
#include "llvm/iTerminators.h"
|
#include "llvm/iTerminators.h"
|
||||||
@ -14,7 +15,6 @@
|
|||||||
#include "llvm/GlobalVariable.h"
|
#include "llvm/GlobalVariable.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Support/InstVisitor.h"
|
#include "llvm/Support/InstVisitor.h"
|
||||||
#include "llvm/Analysis/DataStructure.h" // FIXME:
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
@ -66,17 +66,7 @@ namespace {
|
|||||||
void visitCallInst(CallInst &CI);
|
void visitCallInst(CallInst &CI);
|
||||||
void visitSetCondInst(SetCondInst &SCI) {} // SetEQ & friends are ignored
|
void visitSetCondInst(SetCondInst &SCI) {} // SetEQ & friends are ignored
|
||||||
void visitFreeInst(FreeInst &FI) {} // Ignore free instructions
|
void visitFreeInst(FreeInst &FI) {} // Ignore free instructions
|
||||||
void visitInstruction(Instruction &I) {
|
void visitInstruction(Instruction &I); // Visit unsafe ptr instruction
|
||||||
#ifndef NDEBUG
|
|
||||||
bool bad = isa<PointerType>(I.getType());
|
|
||||||
for (Instruction::op_iterator i = I.op_begin(), E = I.op_end(); i!=E; ++i)
|
|
||||||
bad |= isa<PointerType>(i->get()->getType());
|
|
||||||
if (bad) {
|
|
||||||
std::cerr << "\n\n\nUNKNOWN PTR INSTRUCTION type: " << I << "\n\n\n";
|
|
||||||
assert(0 && "Cannot proceed");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Helper functions used to implement the visitation functions...
|
// Helper functions used to implement the visitation functions...
|
||||||
@ -307,3 +297,18 @@ void GraphBuilder::visitCallInst(CallInst &CI) {
|
|||||||
if (isa<PointerType>(CI.getOperand(i)->getType()))
|
if (isa<PointerType>(CI.getOperand(i)->getType()))
|
||||||
Args.push_back(getLink(getValueNode(*CI.getOperand(i)), 0));
|
Args.push_back(getLink(getValueNode(*CI.getOperand(i)), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// visitInstruction - All safe instructions have been processed above, this case
|
||||||
|
// is where unsafe ptr instructions land.
|
||||||
|
//
|
||||||
|
void GraphBuilder::visitInstruction(Instruction &I) {
|
||||||
|
// If the return type is a pointer, mark the pointed node as being a cast node
|
||||||
|
if (isa<PointerType>(I.getType()))
|
||||||
|
getLink(getValueNode(I), 0)->NodeType |= DSNode::CastNode;
|
||||||
|
|
||||||
|
// If any operands are pointers, mark the pointed nodes as being a cast node
|
||||||
|
for (Instruction::op_iterator i = I.op_begin(), E = I.op_end(); i!=E; ++i)
|
||||||
|
if (isa<PointerType>(i->get()->getType()))
|
||||||
|
getLink(getValueNode(*i->get()), 0)->NodeType |= DSNode::CastNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user