Skip to content

Commit

Permalink
Upgrade the Giri code to LLVM 3.4
Browse files Browse the repository at this point in the history
The main changes are:
 - The header files
 - The useless code is deleted
 - Rename of TargetData to DataLayout
 - Add -ltinfo to LDFLAGS of Makefile
  • Loading branch information
liuml07 committed Sep 21, 2013
1 parent 1fc0ffd commit c95fd25
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 73 deletions.
1 change: 1 addition & 0 deletions Makefile.common.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ include $(PROJ_SRC_ROOT)/Makefile.llvm.rules

CFLAGS += -Wno-deprecated
CXXFLAGS += -Wno-deprecated
LDFLAGS += -ltinfo
10 changes: 5 additions & 5 deletions include/Giri/Giri.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/Pass.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Target/TargetData.h"
#include "llvm/InstVisitor.h"
#include "llvm/IR/DataLayout.h"

#include <deque>
#include <set>
Expand All @@ -50,17 +50,17 @@ class TracingNoGiri : public BasicBlockPass,
/// This method is called after all the basic blocks have been transformed.
/// It inserts code to initialize the run-time of the tracing library.
virtual bool doFinalization(Module &M);
virtual bool doFinalization(Function &F) { return false; }

virtual bool doInitialization(Function &F) { return false; }
virtual bool doFinalization(Function &F) { return false; }

/// This method starts execution of the dynamic slice tracing instrumentation
/// pass. It will add code to a function that records the execution of basic
/// blocks.
virtual bool runOnBasicBlock(BasicBlock &BB);

virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<TargetData>();
AU.addRequired<DataLayout>();
AU.addRequired<QueryBasicBlockNumbers>();
AU.addPreserved<QueryBasicBlockNumbers>();

Expand Down Expand Up @@ -104,7 +104,7 @@ class TracingNoGiri : public BasicBlockPass,

private:
// Pointers to other passes
const TargetData *TD;
const DataLayout *TD;
const QueryBasicBlockNumbers *bbNumPass;
const QueryLoadStoreNumbers *lsNumPass;

Expand Down
2 changes: 1 addition & 1 deletion include/Giri/TraceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Value.h"
#include "llvm/IR/Value.h"

#include <deque>
#include <iterator>
Expand Down
4 changes: 2 additions & 2 deletions include/Utility/BasicBlockNumbering.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#ifndef DG_BASICBLOCKNUMBERING_H
#define DG_BASICBLOCKNUMBERING_H

#include "llvm/Function.h"
#include "llvm/Module.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"

#include <map>
Expand Down
3 changes: 1 addition & 2 deletions include/Utility/CountSrcLines.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include "Utility/LoadStoreNumbering.h"

#include "llvm/Pass.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Target/TargetData.h"
#include "llvm/InstVisitor.h"

#include <deque>
#include <set>
Expand Down
6 changes: 3 additions & 3 deletions include/Utility/LoadStoreNumbering.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

#include "Utility/Utils.h"

#include "llvm/Function.h"
#include "llvm/Module.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/InstVisitor.h"

#include <unordered_map>

Expand Down
4 changes: 1 addition & 3 deletions include/Utility/SourceLineMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
#ifndef DG_SOURCELINEMAPPING_H
#define DG_SOURCELINEMAPPING_H

#include "llvm/Instruction.h"
#include "llvm/IR/Instruction.h"
#include "llvm/Pass.h"

using namespace llvm;

class llvm::raw_ostream;

namespace dg {

/// \class This pass provides the functionality to find the source file and
Expand Down
12 changes: 6 additions & 6 deletions include/Utility/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
#ifndef UTILS_H
#define UTILS_H

#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Type.h"
#include "llvm/IR/Type.h"

#include <string>
#include <sstream>
Expand Down
24 changes: 3 additions & 21 deletions lib/Giri/Giri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "Utility/Utils.h"

#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/DebugInfo.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/InstIterator.h"
Expand Down Expand Up @@ -75,24 +75,6 @@ char DynamicGiri::ID = 0;
// Pass registration
static RegisterPass<DynamicGiri> X("dgiri", "Dynamic Backwards Slice Analysis");

/// This function determines whether the specified value is a source of
/// information (something that has a label independent of its input SSA values.
///
/// \param V - The value to analyze.
/// \return true if this value is a source; otherwise false, its label is the
/// join of the labels of its input operands.
static inline bool isASource(const Value *V) {
// Call instructions are sources *unless* they are inline assembly.
if (const CallInst *CI = dyn_cast<CallInst>(V))
return !isa<InlineAsm>(CI->getCalledValue());

return isa<LoadInst>(V) ||
isa<Argument>(V) ||
isa<AllocaInst>(V) ||
isa<Constant>(V) ||
isa<GlobalValue>(V);
}

bool DynamicGiri::findExecForcers(BasicBlock *BB,
std::set<unsigned> &bbNums) {
// Get the parent function containing this basic block. We'll need it for
Expand Down Expand Up @@ -271,7 +253,7 @@ void DynamicGiri::printBackwardsSlice(const Instruction *Criterion,
std::string errinfo;
raw_fd_ostream SliceFile(SliceFilename.c_str(),
errinfo,
llvm::raw_fd_ostream::F_Append);
sys::fs::F_Append);
if (!errinfo.empty()) {
errs() << "Error opening the slice output file: " << SliceFilename
<< " : " << errinfo << "\n";
Expand Down
4 changes: 2 additions & 2 deletions lib/Giri/TraceFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include "Giri/TraceFile.h"

#include "llvm/ADT/Statistic.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
Expand Down
18 changes: 8 additions & 10 deletions lib/Giri/TracingNoGiri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "Utility/VectorExtras.h"

#include "llvm/ADT/Statistic.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"

Expand Down Expand Up @@ -230,7 +230,7 @@ void TracingNoGiri::instrumentUnlock(Instruction *I) {

void TracingNoGiri::insertIntoGlobalCtorList(Function *RuntimeCtor) {
// Insert the run-time ctor into the ctor list.
LLVMContext & Context = RuntimeCtor->getParent()->getContext();
LLVMContext &Context = RuntimeCtor->getParent()->getContext();
Type *Int32Type = IntegerType::getInt32Ty(Context);
std::vector<Constant *> CtorInits;
CtorInits.push_back(ConstantInt::get(Int32Type, 65535));
Expand All @@ -240,7 +240,7 @@ void TracingNoGiri::insertIntoGlobalCtorList(Function *RuntimeCtor) {
// Get the current set of static global constructors and add the new ctor
// to the list.
std::vector<Constant *> CurrentCtors;
Module & M = *(RuntimeCtor->getParent());
Module &M = *(RuntimeCtor->getParent());
GlobalVariable *GVCtor = M.getNamedGlobal("llvm.global_ctors");
if (GVCtor) {
if (Constant *C = GVCtor->getInitializer()) {
Expand All @@ -265,15 +265,13 @@ void TracingNoGiri::insertIntoGlobalCtorList(Function *RuntimeCtor) {
// Create a new initializer.
ArrayType *AT = ArrayType::get(RuntimeCtorInit->getType(),
CurrentCtors.size());
Constant *NewInit = ConstantArray::get(AT, CurrentCtors);

// Create the new llvm.global_ctors global variable and replace all uses of
// the old global variable with the new one.
new GlobalVariable(M,
NewInit->getType(),
AT,
false,
GlobalValue::AppendingLinkage,
NewInit,
ConstantArray::get(AT, CurrentCtors),
"llvm.global_ctors");
}

Expand Down Expand Up @@ -679,7 +677,7 @@ void TracingNoGiri::visitCallInst(CallInst &CI) {
bool TracingNoGiri::runOnBasicBlock(BasicBlock &BB) {
// Fetch the analysis results for numbering basic blocks.
// Will be run once per module
TD = &getAnalysis<TargetData>();
TD = &getAnalysis<DataLayout>();
bbNumPass = &getAnalysis<QueryBasicBlockNumbers>();
lsNumPass = &getAnalysis<QueryLoadStoreNumbers>();

Expand Down
4 changes: 2 additions & 2 deletions lib/Utility/BasicBlockNumbering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

#include "Utility/BasicBlockNumbering.h"

#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/Utility/CountSrcLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "Utility/SourceLineMapping.h"

#include "llvm/ADT/Statistic.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
Expand Down
4 changes: 2 additions & 2 deletions lib/Utility/LoadStoreNumbering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "Utility/LoadStoreNumbering.h"

#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/Utility/PostDominatorFrontier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "Utility/PostDominanceFrontier.h"

#include "llvm/Instructions.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Debug.h"
#include "llvm/ADT/DepthFirstIterator.h"
Expand Down
12 changes: 6 additions & 6 deletions lib/Utility/SourceLineMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#include "Utility/Utils.h"

#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Function.h"
#include "llvm/Module.h"
#include "llvm/LLVMContext.h"
#include "llvm/DebugInfo.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/CallSite.h"
Expand Down
2 changes: 1 addition & 1 deletion runtime/Giri/Tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,5 +474,5 @@ void recordSelect(unsigned id, unsigned char flag) {
entryCache.addToEntryCache(Entry(RecordType::PDType,
id,
pthread_self(),
(unsigned char *)flag));
reinterpret_cast<unsigned char *>(flag)));
}
2 changes: 1 addition & 1 deletion tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ LEVEL = ..
#
# List all of the subdirectories that we will compile.
#
DIRS = PrintTrace Tracer
DIRS = PrintTrace

include $(LEVEL)/Makefile.common
8 changes: 4 additions & 4 deletions tools/Tracer/Tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#include "llvm/Analysis/Verifier.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Module.h"
#include "llvm/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
Expand All @@ -31,7 +31,7 @@
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Target/TargetData.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
Expand Down Expand Up @@ -105,7 +105,7 @@ int main(int argc, char **argv) {

// Build up all of the passes that we want to do to the module...
PassManager Passes;
Passes.add(new TargetData(M.get()));
Passes.add(new DataLayout(M.get()));

// Number all basic blocks and instructions.
Passes.add(new BasicBlockNumberPass());
Expand Down

0 comments on commit c95fd25

Please sign in to comment.