Index: gcc/llvm-backend.cpp
===================================================================
--- gcc/llvm-backend.cpp	(revision 126469)
+++ gcc/llvm-backend.cpp	(working copy)
@@ -88,7 +88,11 @@
 Module *TheModule = 0;
 DebugInfo *TheDebugInfo = 0;
 TargetMachine *TheTarget = 0;
+#ifdef LLVM_TEST_NOFOLDER
+NoFolder *TheFolder = 0;
+#else
 TargetFolder *TheFolder = 0;
+#endif
 TypeConverter *TheTypeConverter = 0;
 
 // A list of thunks to post-process.
@@ -535,7 +539,11 @@
   TheTarget->setMCUseLoc(false);
   assert(TheTarget->getTargetData()->isBigEndian() == BYTES_BIG_ENDIAN);
 
-  TheFolder = new TargetFolder(TheTarget->getTargetData());
+#ifdef LLVM_TEST_NOFOLDER
+  TheFolder = (NoFolder*) new NoFolder(getGlobalContext());
+#else
+  TheFolder = (TargetFolder*) new TargetFolder(TheTarget->getTargetData());
+#endif
 
   // Install information about target datalayout stuff into the module for
   // optimizer use.
Index: gcc/llvm-internal.h
===================================================================
--- gcc/llvm-internal.h	(revision 126469)
+++ gcc/llvm-internal.h	(working copy)
@@ -41,6 +41,9 @@
 #include "llvm/Support/IRBuilder.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/TargetFolder.h"
+#ifdef LLVM_TEST_NOFOLDER
+#include "llvm/Support/NoFolder.h"
+#endif
 #include "llvm/Support/raw_os_ostream.h"
 
 extern "C" {
@@ -67,7 +70,11 @@
 }
 using namespace llvm;
 
+#ifdef LLVM_TEST_NOFOLDER
+typedef IRBuilder<true, NoFolder> LLVMBuilder;
+#else
 typedef IRBuilder<true, TargetFolder> LLVMBuilder;
+#endif
 typedef SmallPtrSet<union tree_node *, 16> treeset;
 
 /// TheModule - This is the current global module that we are compiling into.
@@ -83,7 +90,11 @@
 extern llvm::TargetMachine *TheTarget;
 
 /// TheFolder - The constant folder to use.
+#ifdef LLVM_TEST_NOFOLDER
+extern NoFolder *TheFolder;
+#else
 extern TargetFolder *TheFolder;
+#endif
 
 /// getTargetData - Return the current TargetData object from TheTarget.
 const TargetData &getTargetData();
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 126469)
+++ gcc/Makefile.in	(working copy)
@@ -243,7 +243,8 @@
 ifeq ($(LLVMOBJDIR),)
 CPPFLAGS = @CPPFLAGS@
 else
-CPPFLAGS := @CPPFLAGS@ -DENABLE_LLVM $(shell $(LLVMBINPATH)/llvm-config --cppflags)
+#CPPFLAGS := @CPPFLAGS@ -DENABLE_LLVM $(shell $(LLVMBINPATH)/llvm-config --cppflags)
+CPPFLAGS := @CPPFLAGS@ -DENABLE_LLVM -DLLVM_TEST_NOFOLDER $(shell $(LLVMBINPATH)/llvm-config --cppflags)
 
 ifeq ($(BUILDMODE),)
 # When building against an installed copy of llvm, do not go back to the
