
For any question, please contact Yan Cai 
  EmaiL: yancai@ios.ac.cn or ycai.mail@gmail.com
  Web:   lcs.ios.ac.cn/~yancai/

+----------------------------------------------------------------------------+
Directories
+----------------------------------------------------------------------------+
  DFixer:        The source code of DFixer.
  PatchGen:      The source code of patch generation file.
  dfixer_lib:    The source code of DFixer library (e.g., preAcq(m, n)).
  test:          A deadlock test file (deadlock.cpp).
  Readme:        This file. 
+----------------------------------------------------------------------------+


+----------------------------------------------------------------------------+
Tested Environment:
+----------------------------------------------------------------------------+
  LLVM & Clang: 3.6.2
  Linux: Ubuntu 14.04 x86
  Gcc:   4.8
+----------------------------------------------------------------------------+


+----------------------------------------------------------------------------+
Usage of DFixer:
+----------------------------------------------------------------------------+
Step 1: Compilation of DFixer (with LLVM compilation together)

  Put the whole directory of DFixer under LLVM_ROOT/lib/Transforms
  
  Modify the LLVM_ROOT/lib/Transforms/CMakeLists.txt to include DFixer 
  directory (i.e., appending a line "add_subdirectory(DFixer)").
  
  Following LLVM Compilation Instructions to compile LLVM and DFixer will be 
  compiled into a Linux shared library file (LLVM_BUILD/lib/LLVMDFixer.so)


Step 2: Generation of Fixing CMD File:

  Given Bitcode files, invoke DFixer as follows:

    opt  -load PATH_TO_DFIXER/LLVMDFixer.so -dfixer -dlkFile=DEADLOCK_DESCRIPTION_FILE \
     -cmdFile=FIXING_CMD_FILE BITCODE_FILES
     
  which generates all possible ways to fix the given deadlock (#Fixing 1, ... # Fixing 2, ...).



Step 3: Generation of Patch Files
  java -jar dfixerPatchGen.jar  BENCHMAKR_ROOT_DIR   FIXING_CMD_FILE
+----------------------------------------------------------------------------+


+----------------------------------------------------------------------------+
Example on deadlock.cpp under Test Directory.
+----------------------------------------------------------------------------+
Generate Bitcode file (deadlock.bc):
  1. clang++ -g -pthread -emit-llvm -c ./deadlock.cpp    
  (which generates a deadlock.bc file)
   
  2. opt  -load /home/yancai/Research/llvm/build362/lib/LLVMDFixer.so \
     -dfixer -dlkFile=deadlock.dlk -cmdFile=./fixingCmd ./deadlock.bc
  (which writes fixing CMD into ./fixingCmd file)
  
  3. java -jar dfixerPatchGen.jar  ./test/ ./test/fixingCmd
  (which generates following files: 
     1deadlock.cpp, 1deadlock.cpp.patch, as Fixing #1;
     2deadlock.cpp, 2deadlock.cpp.patch, as Fixing #2.)
     
  4. compile patched deadlock.cpp (e.g., deadlock_patched.cpp) with fixing.
  (Suppose fixing #2 is used: 
     g++ -g -pthread -I/home/yancai/Research/llvm/dfixer/dfixer_lib/ -c -o  \
         deadlock_patched.o ./deadlock_patched.cpp
     g++ -g -pthread deadlock_patched.o \
         /home/yancai/Research/llvm/dfixer/dfixer_lib/dfixer_lib.o \
         -o deadlock_patched.out)
+----------------------------------------------------------------------------+
