From 81ced52374bf452a54a40df6e4978f0e13eff6cc Mon Sep 17 00:00:00 2001
From: Prakalp Srivastava <psrivas2@illinois.edu>
Date: Tue, 18 Nov 2014 23:05:32 +0000
Subject: [PATCH] Made modifications to make running test cases and passes more
 portable. If environment variable LLVM_SRC_ROOT is set, then running test
 cases should work. The passes and llvm-lit now use this variable to get llvm
 source root and define all paths relative to it

---
 llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp | 9 ++++++++-
 llvm/lib/Transforms/DFG2LLVM_NVPTX/Makefile           | 1 +
 llvm/test/VISC/lit.local.cfg                          | 4 +++-
 llvm/test/lit.cfg                                     | 1 +
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp b/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp
index dfc047a354..3ac623fb42 100644
--- a/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp
+++ b/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp
@@ -229,7 +229,14 @@ void CodeGenTraversal::initRuntimeAPI() {
 
   // Load Runtime API Module
   SMDiagnostic Err;
-  runtimeModule = ParseIRFile("/home/psrivas2/current-src/projects/visc-rt/visc-rt.ll", Err, M.getContext());
+
+  char* LLVM_SRC_ROOT = getenv("LLVM_SRC_ROOT");
+  assert(LLVM_SRC_ROOT != NULL && "Define LLVM_SRC_ROOT environment variable!");
+
+  Twine runtimeAPI = LLVM_SRC_ROOT;
+  runtimeAPI = runtimeAPI+"/projects/visc-rt/visc-rt.ll";
+
+  runtimeModule = ParseIRFile(runtimeAPI.str(), Err, M.getContext());
   if(runtimeModule == NULL)
     DEBUG(errs() << Err.getMessage());
   else
diff --git a/llvm/lib/Transforms/DFG2LLVM_NVPTX/Makefile b/llvm/lib/Transforms/DFG2LLVM_NVPTX/Makefile
index fb84552e49..05301e44e7 100644
--- a/llvm/lib/Transforms/DFG2LLVM_NVPTX/Makefile
+++ b/llvm/lib/Transforms/DFG2LLVM_NVPTX/Makefile
@@ -10,6 +10,7 @@
 LEVEL = ../../../
 LIBRARYNAME = LLVMDFG2LLVM_NVPTX
 LOADABLE_MODULE = 1
+#CXXFLAGS+= -Wc++11-extensions 
 #SHARED_LIBRARY = 1
 #BUILD_ARCHIVE = 1
 #USEDLIBS =
diff --git a/llvm/test/VISC/lit.local.cfg b/llvm/test/VISC/lit.local.cfg
index 4edd662ded..6f2da05161 100644
--- a/llvm/test/VISC/lit.local.cfg
+++ b/llvm/test/VISC/lit.local.cfg
@@ -1,2 +1,4 @@
-llvm_src = '/home/psrivas2/Hetero/VISC/Code/trunk/llvm'
+llvm_src = os.environ.get('LLVM_SRC_ROOT')
+if llvm_src == None:
+  lit.fatal('Define environment variable LLVM_SRC_ROOT')
 config.substitutions.append(('%llvm_src', llvm_src))
diff --git a/llvm/test/lit.cfg b/llvm/test/lit.cfg
index 8272e97c38..8774ab522c 100644
--- a/llvm/test/lit.cfg
+++ b/llvm/test/lit.cfg
@@ -126,6 +126,7 @@ if config.test_exec_root is None:
 
     # Get the source and object roots.
     llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
+    print llvm_src_root
     llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
 
     # Validate that we got a tree which points to here.
-- 
GitLab