relax some types

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32982 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2007-01-07 07:22:20 +00:00
parent 35057c2625
commit febe5f1b3c
4 changed files with 20 additions and 21 deletions

View File

@@ -25,7 +25,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
const Type *ArgVTy = PointerType::get(PointerType::get(Type::Int8Ty)); const Type *ArgVTy = PointerType::get(PointerType::get(Type::Int8Ty));
const PointerType *UIntPtr = PointerType::get(Type::Int32Ty); const PointerType *UIntPtr = PointerType::get(Type::Int32Ty);
Module &M = *MainFn->getParent(); Module &M = *MainFn->getParent();
Function *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty, Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
ArgVTy, UIntPtr, Type::Int32Ty, ArgVTy, UIntPtr, Type::Int32Ty,
(Type *)0); (Type *)0);

View File

@@ -127,7 +127,7 @@ namespace {
//deciding when to sample. //deciding when to sample.
class CycleCounter : public Chooser { class CycleCounter : public Chooser {
uint64_t rm; uint64_t rm;
Function* F; Constant *F;
public: public:
CycleCounter(Module& m, uint64_t resetmask); CycleCounter(Module& m, uint64_t resetmask);
virtual ~CycleCounter(); virtual ~CycleCounter();

View File

@@ -45,17 +45,16 @@ static void InsertInstrumentationCall (BasicBlock *BB,
DOUT << "InsertInstrumentationCall (\"" << BB->getName () DOUT << "InsertInstrumentationCall (\"" << BB->getName ()
<< "\", \"" << FnName << "\", " << BBNumber << ")\n"; << "\", \"" << FnName << "\", " << BBNumber << ")\n";
Module &M = *BB->getParent ()->getParent (); Module &M = *BB->getParent ()->getParent ();
Function *InstrFn = M.getOrInsertFunction (FnName, Type::VoidTy, Constant *InstrFn = M.getOrInsertFunction (FnName, Type::VoidTy,
Type::Int32Ty, (Type *)0); Type::Int32Ty, (Type *)0);
std::vector<Value*> Args (1);
Args[0] = ConstantInt::get (Type::Int32Ty, BBNumber);
// Insert the call after any alloca or PHI instructions... // Insert the call after any alloca or PHI instructions.
BasicBlock::iterator InsertPos = BB->begin(); BasicBlock::iterator InsertPos = BB->begin();
while (isa<AllocaInst>(InsertPos) || isa<PHINode>(InsertPos)) while (isa<AllocaInst>(InsertPos) || isa<PHINode>(InsertPos))
++InsertPos; ++InsertPos;
new CallInst (InstrFn, Args, "", InsertPos); new CallInst(InstrFn, ConstantInt::get (Type::Int32Ty, BBNumber),
"", InsertPos);
} }
bool TraceBasicBlocks::runOnModule(Module &M) { bool TraceBasicBlocks::runOnModule(Module &M) {

View File

@@ -36,7 +36,7 @@ TraceFuncNames("tracefunc", cl::desc("Only trace specific functions in the "
cl::value_desc("function"), cl::Hidden); cl::value_desc("function"), cl::Hidden);
static void TraceValuesAtBBExit(BasicBlock *BB, static void TraceValuesAtBBExit(BasicBlock *BB,
Function *Printf, Function* HashPtrToSeqNum, Constant *Printf, Constant* HashPtrToSeqNum,
std::vector<Instruction*> *valuesStoredInFunction); std::vector<Instruction*> *valuesStoredInFunction);
// We trace a particular function if no functions to trace were specified // We trace a particular function if no functions to trace were specified
@@ -54,8 +54,8 @@ TraceThisFunction(Function &F)
namespace { namespace {
struct ExternalFuncs { struct ExternalFuncs {
Function *PrintfFunc, *HashPtrFunc, *ReleasePtrFunc; Constant *PrintfFunc, *HashPtrFunc, *ReleasePtrFunc;
Function *RecordPtrFunc, *PushOnEntryFunc, *ReleaseOnReturnFunc; Constant *RecordPtrFunc, *PushOnEntryFunc, *ReleaseOnReturnFunc;
void doInitialization(Module &M); // Add prototypes for external functions void doInitialization(Module &M); // Add prototypes for external functions
}; };
@@ -224,7 +224,7 @@ static std::string getPrintfCodeFor(const Value *V) {
static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore, static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore,
std::string Message, std::string Message,
Function *Printf, Function* HashPtrToSeqNum) { Constant *Printf, Constant* HashPtrToSeqNum) {
// Escape Message by replacing all % characters with %% chars. // Escape Message by replacing all % characters with %% chars.
std::string Tmp; std::string Tmp;
std::swap(Tmp, Message); std::swap(Tmp, Message);
@@ -266,8 +266,8 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore,
static void InsertVerbosePrintInst(Value *V, BasicBlock *BB, static void InsertVerbosePrintInst(Value *V, BasicBlock *BB,
Instruction *InsertBefore, Instruction *InsertBefore,
const std::string &Message, Function *Printf, const std::string &Message, Constant *Printf,
Function* HashPtrToSeqNum) { Constant * HashPtrToSeqNum) {
std::ostringstream OutStr; std::ostringstream OutStr;
if (V) WriteAsOperand(OutStr, V); if (V) WriteAsOperand(OutStr, V);
InsertPrintInst(V, BB, InsertBefore, Message+OutStr.str()+" = ", InsertPrintInst(V, BB, InsertBefore, Message+OutStr.str()+" = ",
@@ -277,7 +277,7 @@ static void InsertVerbosePrintInst(Value *V, BasicBlock *BB,
static void static void
InsertReleaseInst(Value *V, BasicBlock *BB, InsertReleaseInst(Value *V, BasicBlock *BB,
Instruction *InsertBefore, Instruction *InsertBefore,
Function* ReleasePtrFunc) { Constant *ReleasePtrFunc) {
const Type *SBP = PointerType::get(Type::Int8Ty); const Type *SBP = PointerType::get(Type::Int8Ty);
if (V->getType() != SBP) // Cast pointer to be sbyte* if (V->getType() != SBP) // Cast pointer to be sbyte*
@@ -290,7 +290,7 @@ InsertReleaseInst(Value *V, BasicBlock *BB,
static void static void
InsertRecordInst(Value *V, BasicBlock *BB, InsertRecordInst(Value *V, BasicBlock *BB,
Instruction *InsertBefore, Instruction *InsertBefore,
Function* RecordPtrFunc) { Constant *RecordPtrFunc) {
const Type *SBP = PointerType::get(Type::Int8Ty); const Type *SBP = PointerType::get(Type::Int8Ty);
if (V->getType() != SBP) // Cast pointer to be sbyte* if (V->getType() != SBP) // Cast pointer to be sbyte*
V = new BitCastInst(V, SBP, "RP_cast", InsertBefore); V = new BitCastInst(V, SBP, "RP_cast", InsertBefore);
@@ -325,7 +325,7 @@ ReleasePtrSeqNumbers(BasicBlock *BB,
// store instruction). // store instruction).
// //
static void TraceValuesAtBBExit(BasicBlock *BB, static void TraceValuesAtBBExit(BasicBlock *BB,
Function *Printf, Function* HashPtrToSeqNum, Constant *Printf, Constant * HashPtrToSeqNum,
std::vector<Instruction*> *valuesStoredInFunction) { std::vector<Instruction*> *valuesStoredInFunction) {
// Get an iterator to point to the insertion location, which is // Get an iterator to point to the insertion location, which is
// just before the terminator instruction. // just before the terminator instruction.
@@ -354,8 +354,8 @@ static void TraceValuesAtBBExit(BasicBlock *BB,
} }
} }
static inline void InsertCodeToShowFunctionEntry(Function &F, Function *Printf, static inline void InsertCodeToShowFunctionEntry(Function &F, Constant *Printf,
Function* HashPtrToSeqNum){ Constant * HashPtrToSeqNum){
// Get an iterator to point to the insertion location // Get an iterator to point to the insertion location
BasicBlock &BB = F.getEntryBlock(); BasicBlock &BB = F.getEntryBlock();
Instruction *InsertPos = BB.begin(); Instruction *InsertPos = BB.begin();
@@ -376,8 +376,8 @@ static inline void InsertCodeToShowFunctionEntry(Function &F, Function *Printf,
static inline void InsertCodeToShowFunctionExit(BasicBlock *BB, static inline void InsertCodeToShowFunctionExit(BasicBlock *BB,
Function *Printf, Constant *Printf,
Function* HashPtrToSeqNum) { Constant * HashPtrToSeqNum) {
// Get an iterator to point to the insertion location // Get an iterator to point to the insertion location
ReturnInst *Ret = cast<ReturnInst>(BB->getTerminator()); ReturnInst *Ret = cast<ReturnInst>(BB->getTerminator());