Improve bytecode load time and optimization (bb #2278).

Avoid quadratic load times: run module passes at the end, and run
rtcheck inserter at the end also.

Also optimize away some simple situations that the compiler couldn't,
like result of __is_bigendian() which is a constant at load time (but not at
compile time).
If we would have run LLVM's -O1 optimizers these would have been
optimized already, but we don't do that for 2 reasons:
 - optimizations may introduce new bugs
 - may take a bit longer time
Just run some simple transforms, and some custom optimizations for the bigendian
case.
0.96
Török Edvin 15 years ago
parent 12fb82a612
commit 6e52ce67c7
  1. 4
      ChangeLog
  2. 9
      libclamav/c++/ClamBCRTChecks.cpp
  3. 6
      libclamav/c++/Makefile.am
  4. 78
      libclamav/c++/Makefile.in
  5. 4
      libclamav/c++/aclocal.m4
  6. 287
      libclamav/c++/bytecode2llvm.cpp
  7. 149
      libclamav/c++/config/config.guess
  8. 47
      libclamav/c++/config/config.sub
  9. 419
      libclamav/c++/configure

@ -1,3 +1,7 @@
Tue Sep 21 20:19:41 EEST 2010 (edwin)
-------------------------------------
* libclamav/c++: improve bytecode load time, and optimization (bb #2278)
Tue Sep 21 16:32:22 CEST 2010 (tk)
----------------------------------
* sigtool/sigtool.c: don't use of sizeof() for malloc'ed buffer (bb#2283)

@ -66,14 +66,7 @@ namespace {
PtrVerifier() : FunctionPass((intptr_t)&ID),rootNode(0) {}
virtual bool runOnFunction(Function &F) {
#ifndef CLAMBC_COMPILER
// Bytecode was already verifier and had stack protector applied.
// We get called again because ALL bytecode functions loaded are part of
// the same module.
if (F.hasFnAttr(Attribute::StackProtect))
return false;
#endif
errs() << "Running on " << F.getName() << "\n";
DEBUG(F.dump());
Changed = false;
BaseMap.clear();

@ -538,7 +538,13 @@ libllvmjit_la_SOURCES=\
llvm/lib/Target/TargetLoweringObjectFile.cpp\
llvm/lib/Target/TargetMachine.cpp\
llvm/lib/Target/TargetRegisterInfo.cpp\
llvm/lib/Transforms/Scalar/ADCE.cpp\
llvm/lib/Transforms/Scalar/DCE.cpp\
llvm/lib/Transforms/Scalar/SCCP.cpp\
llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp\
llvm/lib/Transforms/IPO/ConstantMerge.cpp\
llvm/lib/Transforms/IPO/GlobalOpt.cpp\
llvm/lib/Transforms/IPO/GlobalDCE.cpp\
llvm/lib/VMCore/AsmWriter.cpp\
llvm/lib/VMCore/Attributes.cpp\
llvm/lib/VMCore/AutoUpgrade.cpp\

@ -303,14 +303,16 @@ am_libllvmjit_la_OBJECTS = CallGraph.lo AliasAnalysis.lo \
circular_raw_ostream.lo raw_ostream.lo Mangler.lo \
SubtargetFeature.lo TargetData.lo TargetInstrInfo.lo \
TargetLoweringObjectFile.lo TargetMachine.lo \
TargetRegisterInfo.lo DCE.lo AsmWriter.lo Attributes.lo \
AutoUpgrade.lo BasicBlock.lo ConstantFold.lo Constants.lo \
Core.lo Dominators.lo Function.lo GVMaterializer.lo Globals.lo \
IRBuilder.lo InlineAsm.lo Instruction.lo Instructions.lo \
IntrinsicInst.lo LLVMContext.lo LLVMContextImpl.lo \
LeakDetector.lo Metadata.lo Module.lo Pass.lo PassManager.lo \
PrintModulePass.lo Type.lo TypeSymbolTable.lo Use.lo Value.lo \
ValueSymbolTable.lo ValueTypes.lo Verifier.lo
TargetRegisterInfo.lo ADCE.lo DCE.lo SCCP.lo \
SimplifyCFGPass.lo ConstantMerge.lo GlobalOpt.lo GlobalDCE.lo \
AsmWriter.lo Attributes.lo AutoUpgrade.lo BasicBlock.lo \
ConstantFold.lo Constants.lo Core.lo Dominators.lo Function.lo \
GVMaterializer.lo Globals.lo IRBuilder.lo InlineAsm.lo \
Instruction.lo Instructions.lo IntrinsicInst.lo LLVMContext.lo \
LLVMContextImpl.lo LeakDetector.lo Metadata.lo Module.lo \
Pass.lo PassManager.lo PrintModulePass.lo Type.lo \
TypeSymbolTable.lo Use.lo Value.lo ValueSymbolTable.lo \
ValueTypes.lo Verifier.lo
libllvmjit_la_OBJECTS = $(am_libllvmjit_la_OBJECTS)
libllvmpowerpccodegen_la_LIBADD =
am__libllvmpowerpccodegen_la_SOURCES_DIST = \
@ -1334,7 +1336,13 @@ libllvmjit_la_SOURCES = \
llvm/lib/Target/TargetLoweringObjectFile.cpp\
llvm/lib/Target/TargetMachine.cpp\
llvm/lib/Target/TargetRegisterInfo.cpp\
llvm/lib/Transforms/Scalar/ADCE.cpp\
llvm/lib/Transforms/Scalar/DCE.cpp\
llvm/lib/Transforms/Scalar/SCCP.cpp\
llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp\
llvm/lib/Transforms/IPO/ConstantMerge.cpp\
llvm/lib/Transforms/IPO/GlobalOpt.cpp\
llvm/lib/Transforms/IPO/GlobalDCE.cpp\
llvm/lib/VMCore/AsmWriter.cpp\
llvm/lib/VMCore/Attributes.cpp\
llvm/lib/VMCore/AutoUpgrade.cpp\
@ -1809,6 +1817,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ADCE.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/APFloat.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/APInt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/APSInt.Plo@am__quote@
@ -1842,6 +1851,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CommandLine.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConstantFold.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConstantFolding.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConstantMerge.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConstantRange.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Constants.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Core.Plo@am__quote@
@ -1885,6 +1895,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GEPSplitter.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GVMaterializer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GVN.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GlobalDCE.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GlobalOpt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Globals.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GraphWriter.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Host.Plo@am__quote@
@ -2008,6 +2020,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Regex.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RegisterCoalescer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RegisterScavenging.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SCCP.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SSAUpdater.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ScalarEvolution.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ScalarEvolutionExpander.Plo@am__quote@
@ -2028,6 +2041,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Signals.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimpleRegisterCoalescing.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimplifyCFG.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimplifyCFGPass.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SjLjEHPrepare.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SlotIndexes.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SlowOperationInformer.Plo@am__quote@
@ -4584,6 +4598,14 @@ TargetRegisterInfo.lo: llvm/lib/Target/TargetRegisterInfo.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o TargetRegisterInfo.lo `test -f 'llvm/lib/Target/TargetRegisterInfo.cpp' || echo '$(srcdir)/'`llvm/lib/Target/TargetRegisterInfo.cpp
ADCE.lo: llvm/lib/Transforms/Scalar/ADCE.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ADCE.lo -MD -MP -MF $(DEPDIR)/ADCE.Tpo -c -o ADCE.lo `test -f 'llvm/lib/Transforms/Scalar/ADCE.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/Scalar/ADCE.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ADCE.Tpo $(DEPDIR)/ADCE.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='llvm/lib/Transforms/Scalar/ADCE.cpp' object='ADCE.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ADCE.lo `test -f 'llvm/lib/Transforms/Scalar/ADCE.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/Scalar/ADCE.cpp
DCE.lo: llvm/lib/Transforms/Scalar/DCE.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT DCE.lo -MD -MP -MF $(DEPDIR)/DCE.Tpo -c -o DCE.lo `test -f 'llvm/lib/Transforms/Scalar/DCE.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/Scalar/DCE.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/DCE.Tpo $(DEPDIR)/DCE.Plo
@ -4592,6 +4614,46 @@ DCE.lo: llvm/lib/Transforms/Scalar/DCE.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o DCE.lo `test -f 'llvm/lib/Transforms/Scalar/DCE.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/Scalar/DCE.cpp
SCCP.lo: llvm/lib/Transforms/Scalar/SCCP.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT SCCP.lo -MD -MP -MF $(DEPDIR)/SCCP.Tpo -c -o SCCP.lo `test -f 'llvm/lib/Transforms/Scalar/SCCP.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/Scalar/SCCP.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/SCCP.Tpo $(DEPDIR)/SCCP.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='llvm/lib/Transforms/Scalar/SCCP.cpp' object='SCCP.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o SCCP.lo `test -f 'llvm/lib/Transforms/Scalar/SCCP.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/Scalar/SCCP.cpp
SimplifyCFGPass.lo: llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT SimplifyCFGPass.lo -MD -MP -MF $(DEPDIR)/SimplifyCFGPass.Tpo -c -o SimplifyCFGPass.lo `test -f 'llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/SimplifyCFGPass.Tpo $(DEPDIR)/SimplifyCFGPass.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp' object='SimplifyCFGPass.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o SimplifyCFGPass.lo `test -f 'llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
ConstantMerge.lo: llvm/lib/Transforms/IPO/ConstantMerge.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ConstantMerge.lo -MD -MP -MF $(DEPDIR)/ConstantMerge.Tpo -c -o ConstantMerge.lo `test -f 'llvm/lib/Transforms/IPO/ConstantMerge.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/IPO/ConstantMerge.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ConstantMerge.Tpo $(DEPDIR)/ConstantMerge.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='llvm/lib/Transforms/IPO/ConstantMerge.cpp' object='ConstantMerge.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ConstantMerge.lo `test -f 'llvm/lib/Transforms/IPO/ConstantMerge.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/IPO/ConstantMerge.cpp
GlobalOpt.lo: llvm/lib/Transforms/IPO/GlobalOpt.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT GlobalOpt.lo -MD -MP -MF $(DEPDIR)/GlobalOpt.Tpo -c -o GlobalOpt.lo `test -f 'llvm/lib/Transforms/IPO/GlobalOpt.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/IPO/GlobalOpt.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/GlobalOpt.Tpo $(DEPDIR)/GlobalOpt.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='llvm/lib/Transforms/IPO/GlobalOpt.cpp' object='GlobalOpt.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GlobalOpt.lo `test -f 'llvm/lib/Transforms/IPO/GlobalOpt.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/IPO/GlobalOpt.cpp
GlobalDCE.lo: llvm/lib/Transforms/IPO/GlobalDCE.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT GlobalDCE.lo -MD -MP -MF $(DEPDIR)/GlobalDCE.Tpo -c -o GlobalDCE.lo `test -f 'llvm/lib/Transforms/IPO/GlobalDCE.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/IPO/GlobalDCE.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/GlobalDCE.Tpo $(DEPDIR)/GlobalDCE.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='llvm/lib/Transforms/IPO/GlobalDCE.cpp' object='GlobalDCE.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GlobalDCE.lo `test -f 'llvm/lib/Transforms/IPO/GlobalDCE.cpp' || echo '$(srcdir)/'`llvm/lib/Transforms/IPO/GlobalDCE.cpp
AsmWriter.lo: llvm/lib/VMCore/AsmWriter.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT AsmWriter.lo -MD -MP -MF $(DEPDIR)/AsmWriter.Tpo -c -o AsmWriter.lo `test -f 'llvm/lib/VMCore/AsmWriter.cpp' || echo '$(srcdir)/'`llvm/lib/VMCore/AsmWriter.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/AsmWriter.Tpo $(DEPDIR)/AsmWriter.Plo

@ -13,8 +13,8 @@
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
[m4_warning([this file was generated for autoconf 2.65.
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],,
[m4_warning([this file was generated for autoconf 2.67.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])

@ -63,12 +63,14 @@
#include "llvm/System/Memory.h"
#include "llvm/System/Mutex.h"
#include "llvm/System/Signals.h"
#include "llvm/Support/Timer.h"
#include "llvm/System/Threading.h"
#include "llvm/Target/TargetSelect.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Support/TargetFolder.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/System/ThreadLocal.h"
#include <cstdlib>
@ -77,6 +79,9 @@
#include <cerrno>
#include <string>
//#define TIMING
#undef TIMING
#include "llvm/Config/config.h"
#if !ENABLE_THREADS
#error "Thread support was explicitly disabled. Cannot continue"
@ -266,8 +271,12 @@ private:
llvm_unreachable("getStatic");
}
public:
Timer pmTimer;
Timer irgenTimer;
LLVMTypeMapper(LLVMContext &Context, const struct cli_bc_type *types,
unsigned count, const Type *Hidden=0) : Context(Context), numTypes(count)
unsigned count, const Type *Hidden=0) : Context(Context), numTypes(count),
pmTimer("Function passes"),irgenTimer("IR generation")
{
TypeMap.reserve(count);
// During recursive type construction pointers to Type* may be
@ -524,13 +533,90 @@ public:
};
char RuntimeLimits::ID;
// SimplifyCFG, ADCE, etc. won't remove a br i1 false ... they turn it into
// select i1 false ... which instcombine would simplify but we don't run
// instcombine.
class BrSimplifier : public FunctionPass {
public:
static char ID;
BrSimplifier() : FunctionPass(&ID) {}
virtual bool runOnFunction(Function &F) {
bool Changed = false;
for (Function::iterator I=F.begin(),E=F.end(); I != E; ++I) {
if (BranchInst *BI = dyn_cast<BranchInst>(I->getTerminator())) {
if (BI->isUnconditional())
continue;
Value *V = BI->getCondition();
if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
BasicBlock *Other;
if (CI->isOne()) {
BranchInst::Create(BI->getSuccessor(0), &*I);
Other = BI->getSuccessor(1);
} else {
BranchInst::Create(BI->getSuccessor(1), &*I);
Other = BI->getSuccessor(0);
}
Other->removePredecessor(&*I);
BI->eraseFromParent();
Changed = true;
}
}
for (BasicBlock::iterator J=I->begin(),JE=I->end();
J != JE;) {
SelectInst *SI = dyn_cast<SelectInst>(J);
++J;
if (!SI)
continue;
ConstantInt *CI = dyn_cast<ConstantInt>(SI->getCondition());
if (!CI)
continue;
if (CI->isOne())
SI->replaceAllUsesWith(SI->getTrueValue());
else
SI->replaceAllUsesWith(SI->getFalseValue());
SI->eraseFromParent();
Changed = true;
}
}
return Changed;
}
};
char BrSimplifier::ID;
/*
class SimpleGlobalDCE : public ModulePass {
ExecutionEngine *EE;
public:
static char ID;
SimpleGlobalDCE(ExecutionEngine *EE) : ModulePass(&ID), EE(EE) {}
virtual bool runOnModule(Module &M) {
bool Changed = false;
std::vector<GlobalValue*> toErase;
for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) {
GlobalValue *GV = &*I;
if (GV->use_empty() && !EE->getPointerToGlobalIfAvailable(GV))
toErase.push_back(GV);
}
for (std::vector<GlobalValue*>::iterator I=toErase.begin(), E=toErase.end();
I != E; ++I) {
(*I)->eraseFromParent();
Changed = true;
}
return Changed;
}
};
char SimpleGlobalDCE::ID;
*/
class VISIBILITY_HIDDEN LLVMCodegen {
private:
const struct cli_bc *bc;
Module *M;
LLVMContext &Context;
ExecutionEngine *EE;
PassManager &PM;
FunctionPassManager &PM, &PMUnsigned;
LLVMTypeMapper *TypeMap;
Function **apiFuncs;
@ -724,13 +810,12 @@ private:
return 0;
}
public:
LLVMCodegen(const struct cli_bc *bc, Module *M, struct CommonFunctions *CF, FunctionMapTy &cFuncs,
ExecutionEngine *EE, PassManager &PM,
ExecutionEngine *EE, FunctionPassManager &PM, FunctionPassManager &PMUnsigned,
Function **apiFuncs, LLVMTypeMapper &apiMap)
: bc(bc), M(M), Context(M->getContext()), EE(EE),
PM(PM), apiFuncs(apiFuncs),apiMap(apiMap),
PM(PM),PMUnsigned(PMUnsigned), apiFuncs(apiFuncs),apiMap(apiMap),
compiledFunctions(cFuncs), BytecodeID("bc"+Twine(bc->id)),
Folder(EE->getTargetData()), Builder(Context, Folder), CF(CF) {
@ -849,7 +934,11 @@ public:
return V;
}
bool generate() {
Function* generate() {
PrettyStackTraceString CrashInfo("Generate LLVM IR functions");
#ifdef TIMING
apiMap.irgenTimer.startTimer();
#endif
TypeMap = new LLVMTypeMapper(Context, bc->types + 4, bc->num_types - 5);
for (unsigned i=0;i<bc->dbgnode_cnt;i++) {
mdnodes.push_back(convertMDNode(i));
@ -893,7 +982,6 @@ public:
}
Function **Functions = new Function*[bc->num_func];
for (unsigned j=0;j<bc->num_func;j++) {
PrettyStackTraceString CrashInfo("Generate LLVM IR functions");
// Create LLVM IR Function
const struct cli_bc_func *func = &bc->funcs[j];
std::vector<const Type*> argTypes;
@ -908,16 +996,13 @@ public:
BytecodeID+"f"+Twine(j), M);
Functions[j]->setDoesNotThrow();
Functions[j]->setCallingConv(CallingConv::Fast);
Functions[j]->setLinkage(GlobalValue::InternalLinkage);
#ifdef C_LINUX
/* bb #2270, this should really be fixed either by LLVM or GCC.*/
Functions[j]->addFnAttr(Attribute::constructStackAlignmentFromInt(16));
#endif
}
const Type *I32Ty = Type::getInt32Ty(Context);
PM.add(createDeadCodeEliminationPass());
if (!bc->trusted)
PM.add(createClamBCRTChecks());
PM.add(new RuntimeLimits());
for (unsigned j=0;j<bc->num_func;j++) {
PrettyStackTraceString CrashInfo("Generate LLVM IR");
const struct cli_bc_func *func = &bc->funcs[j];
@ -1137,7 +1222,7 @@ public:
BasicBlock *False = BB[inst->u.branch.br_false];
if (Cond->getType() != Type::getInt1Ty(Context)) {
errs() << MODULE << "type mismatch in condition\n";
return false;
return 0;
}
Builder.CreateCondBr(Cond, True, False);
break;
@ -1235,7 +1320,7 @@ public:
Value *Op = convertOperand(func, I32Ty, inst->u.three[2]);
Op = GEPOperand(Op);
if (!createGEP(inst->dest, V, &Op, &Op+1))
return false;
return 0;
break;
}
case OP_BC_GEPZ:
@ -1247,7 +1332,7 @@ public:
Ops[1] = convertOperand(func, I32Ty, inst->u.three[2]);
Ops[1] = GEPOperand(Ops[1]);
if (!createGEP(inst->dest, V, Ops, Ops+2))
return false;
return 0;
break;
}
case OP_BC_GEPN:
@ -1262,7 +1347,7 @@ public:
Idxs.push_back(Op);
}
if (!createGEP(inst->dest, V, Idxs.begin(), Idxs.end()))
return false;
return 0;
break;
}
case OP_BC_STORE:
@ -1393,7 +1478,7 @@ public:
default:
errs() << MODULE << "JIT doesn't implement opcode " <<
inst->opcode << " yet!\n";
return false;
return 0;
}
}
}
@ -1402,60 +1487,77 @@ public:
errs() << MODULE << "Verification failed\n";
F->dump();
// verification failed
return false;
return 0;
}
delete [] Values;
delete [] BB;
#ifdef TIMING
apiMap.irgenTimer.stopTimer();
apiMap.pmTimer.startTimer();
#endif
if (bc->trusted) {
PM.doInitialization();
PM.run(*F);
PM.doFinalization();
}
else {
PMUnsigned.doInitialization();
PMUnsigned.run(*F);
PMUnsigned.doFinalization();
}
#ifdef TIMING
apiMap.pmTimer.stopTimer();
apiMap.irgenTimer.startTimer();
#endif
}
PM.run(*M);
for (unsigned j=0;j<bc->num_func;j++) {
PrettyStackTraceString CrashInfo("Generate LLVM IR2");
Function *F = Functions[j];
AddStackProtect(F);
}
DEBUG(M->dump());
delete TypeMap;
std::vector<const Type*> args;
args.clear();
args.push_back(HiddenCtx);
FunctionType *Callable = FunctionType::get(Type::getInt32Ty(Context),
args, false);
for (unsigned j=0;j<bc->num_func;j++) {
const struct cli_bc_func *func = &bc->funcs[j];
PrettyStackTraceString CrashInfo2("Native machine codegen");
// If prototype matches, add to callable functions
if (Functions[j]->getFunctionType() == Callable) {
// All functions have the Fast calling convention, however
// entrypoint can only be C, emit wrapper
Function *F = Function::Create(Functions[j]->getFunctionType(),
Function::ExternalLinkage,
Functions[j]->getName()+"_wrap", M);
F->setDoesNotThrow();
BasicBlock *BB = BasicBlock::Create(Context, "", F);
std::vector<Value*> args;
for (Function::arg_iterator J=F->arg_begin(),
JE=F->arg_end(); J != JE; ++JE) {
args.push_back(&*J);
}
CallInst *CI = CallInst::Create(Functions[j], args.begin(), args.end(), "", BB);
CI->setCallingConv(CallingConv::Fast);
ReturnInst::Create(Context, CI, BB);
// If prototype matches, add to callable functions
if (Functions[0]->getFunctionType() != Callable) {
errs() << "Wrong prototype for function 0 in bytecode " << bc->id << "\n";
return 0;
}
// All functions have the Fast calling convention, however
// entrypoint can only be C, emit wrapper
Function *F = Function::Create(Functions[0]->getFunctionType(),
Function::ExternalLinkage,
Functions[0]->getName()+"_wrap", M);
F->setDoesNotThrow();
BasicBlock *BB = BasicBlock::Create(Context, "", F);
std::vector<Value*> Args;
for (Function::arg_iterator J=F->arg_begin(),
JE=F->arg_end(); J != JE; ++JE) {
Args.push_back(&*J);
}
CallInst *CI = CallInst::Create(Functions[0], Args.begin(), Args.end(), "", BB);
CI->setCallingConv(CallingConv::Fast);
ReturnInst::Create(Context, CI, BB);
if (verifyFunction(*F, PrintMessageAction) == 0) {
DEBUG(errs() << "Generating code\n");
delete [] Functions;
if (verifyFunction(*F, PrintMessageAction))
return 0;
/* DEBUG(errs() << "Generating code\n");
// Codegen current function as executable machine code.
EE->getPointerToFunction(Functions[j]);
void *code = EE->getPointerToFunction(F);
DEBUG(errs() << "Code generation finished\n");
DEBUG(errs() << "Code generation finished\n");*/
compiledFunctions[func] = code;
}
}
}
delete [] Functions;
return true;
// compiledFunctions[func] = code;
#ifdef TIMING
apiMap.irgenTimer.stopTimer();
#endif
return F;
}
};
@ -1690,6 +1792,17 @@ static void setGuard(unsigned char* guardbuf)
cli_md5_final(guardbuf, &ctx);
}
static void addFPasses(FunctionPassManager &FPM, bool trusted, const TargetData *TD)
{
// Set up the optimizer pipeline. Start with registering info about how
// the target lays out data structures.
FPM.add(new TargetData(*TD));
// Promote allocas to registers.
FPM.add(createPromoteMemoryToRegisterPass());
FPM.add(new BrSimplifier());
FPM.add(createDeadCodeEliminationPass());
}
int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
{
if (!bcs->engine)
@ -1734,15 +1847,12 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
struct CommonFunctions CF;
addFunctionProtos(&CF, EE, M);
PassManager OurFPM;
FunctionPassManager OurFPM(M), OurFPMUnsigned(M);
M->setDataLayout(EE->getTargetData()->getStringRepresentation());
M->setTargetTriple(sys::getHostTriple());
// Set up the optimizer pipeline. Start with registering info about how
// the target lays out data structures.
OurFPM.add(new TargetData(*EE->getTargetData()));
// Promote allocas to registers.
OurFPM.add(createPromoteMemoryToRegisterPass());
OurFPM.add(createDeadCodeEliminationPass());
addFPasses(OurFPM, true, EE->getTargetData());
addFPasses(OurFPMUnsigned, false, EE->getTargetData());
//TODO: create a wrapper that calls pthread_getspecific
unsigned maxh = cli_globals[0].offset + sizeof(struct cli_bc_hooks);
@ -1803,7 +1913,7 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
FunctionType *FTy = FunctionType::get(Type::getVoidTy(M->getContext()),
false);
GlobalVariable *Guard = new GlobalVariable(*M, PointerType::getUnqual(Type::getInt8Ty(M->getContext())),
true, GlobalValue::ExternalLinkage, 0, "__stack_chk_guard");
true, GlobalValue::ExternalLinkage, 0, "__stack_chk_guard");
unsigned plus = 0;
if (2*sizeof(void*) <= 16 && cli_rndnum(2)==2) {
plus = sizeof(void*);
@ -1817,28 +1927,73 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
EE->addGlobalMapping(SFail, (void*)(intptr_t)jit_ssp_handler);
EE->getPointerToFunction(SFail);
llvm::Function **Functions = new Function*[bcs->count];
for (unsigned i=0;i<bcs->count;i++) {
const struct cli_bc *bc = &bcs->all_bcs[i];
if (bc->state == bc_skip || bc->state == bc_interp)
continue;
LLVMCodegen Codegen(bc, M, &CF, bcs->engine->compiledFunctions, EE,
OurFPM, apiFuncs, apiMap);
if (!Codegen.generate()) {
OurFPM, OurFPMUnsigned, apiFuncs, apiMap);
Function *F = Codegen.generate();
if (!F) {
errs() << MODULE << "JIT codegen failed\n";
return CL_EBYTECODE;
}
Functions[i] = F;
}
delete [] apiFuncs;
bool has_untrusted = false;
for (unsigned i=0;i<bcs->count;i++) {
bcs->all_bcs[i].state = bc_jit;
if (!bcs->all_bcs[i].trusted) {
has_untrusted = true;
break;
}
}
// compile all functions now, not lazily!
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
Function *Fn = &*I;
if (!Fn->isDeclaration())
EE->getPointerToFunction(Fn);
PassManager PM;
PM.add(new TargetData(*EE->getTargetData()));
// TODO: only run this on the untrusted bytecodes, not all of them...
if (has_untrusted)
PM.add(createClamBCRTChecks());
PM.add(createCFGSimplificationPass());
PM.add(createSCCPPass());
PM.add(createGlobalOptimizerPass());
PM.add(createConstantMergePass());
PM.add(new RuntimeLimits());
Timer pmTimer2("Transform passes");
#ifdef TIMING
pmTimer2.startTimer();
#endif
PM.run(*M);
#ifdef TIMING
pmTimer2.stopTimer();
#endif
DEBUG(M->dump());
{
PrettyStackTraceString CrashInfo2("Native machine codegen");
Timer codegenTimer("Native codegen");
#ifdef TIMING
codegenTimer.startTimer();
#endif
// compile all functions now, not lazily!
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
Function *Fn = &*I;
if (!Fn->isDeclaration())
EE->getPointerToFunction(Fn);
}
#ifdef TIMING
codegenTimer.stopTimer();
#endif
}
delete [] apiFuncs;
for (unsigned i=0;i<bcs->count;i++) {
const struct cli_bc_func *func = &bcs->all_bcs[i].funcs[0];
bcs->engine->compiledFunctions[func] = EE->getPointerToFunction(Functions[i]);
bcs->all_bcs[i].state = bc_jit;
}
delete [] Functions;
}
return CL_SUCCESS;
} catch (std::bad_alloc &badalloc) {

@ -1,10 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
timestamp='2009-06-10'
timestamp='2009-12-30'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -27,16 +27,16 @@ timestamp='2009-06-10'
# the same distribution terms that you use for the rest of that program.
# Originally written by Per Bothner <per@bothner.com>.
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
# Originally written by Per Bothner. Please send patches (context
# diff format) to <config-patches@gnu.org> and include a ChangeLog
# entry.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
# don't specify an explicit build system type.
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
me=`echo "$0" | sed -e 's,.*/,,'`
@ -56,8 +56,9 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -333,6 +334,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
echo i386-pc-auroraux${UNAME_RELEASE}
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
eval $set_cc_for_build
SUN_ARCH="i386"
@ -807,12 +811,12 @@ EOF
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
*:Interix*:[3456]*)
*:Interix*:*)
case ${UNAME_MACHINE} in
x86)
echo i586-pc-interix${UNAME_RELEASE}
exit ;;
EM64T | authenticamd | genuineintel)
authenticamd | genuineintel | EM64T)
echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;;
IA64)
@ -854,6 +858,20 @@ EOF
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
@ -876,6 +894,17 @@ EOF
frv:Linux:*:*)
echo frv-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
LIBC=gnu
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
exit ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
@ -901,39 +930,18 @@ EOF
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^CPU/{
s: ::g
p
}'`"
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
or32:Linux:*:*)
echo or32-unknown-linux-gnu
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
exit ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
@ -942,8 +950,11 @@ EOF
*) echo hppa-unknown-linux-gnu ;;
esac
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
@ -966,58 +977,6 @@ EOF
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
# Set LC_ALL=C to ensure ld outputs messages in English.
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
| sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g
s/.*supported targets: *//
s/ .*//
p'`
case "$ld_supported_targets" in
elf32-i386)
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;;
esac
# Determine whether the default compiler is a.out or elf
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <features.h>
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
LIBC=gnu
# else
LIBC=gnulibc1
# endif
# else
LIBC=gnulibc1
# endif
#else
#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
LIBC=gnu
#else
LIBC=gnuaout
#endif
#endif
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^LIBC/{
s: ::g
p
}'`"
test x"${LIBC}" != x && {
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
exit
}
test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
@ -1247,6 +1206,16 @@ EOF
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
i386)
eval $set_cc_for_build
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
UNAME_PROCESSOR="x86_64"
fi
fi ;;
unknown) UNAME_PROCESSOR=powerpc ;;
esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}

@ -1,10 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
timestamp='2009-06-11'
timestamp='2010-01-22'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@ -32,13 +32,16 @@ timestamp='2009-06-11'
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
# diff and a properly formatted GNU ChangeLog entry.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
@ -72,8 +75,9 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -149,7 +153,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray)
-apple | -axis | -knuth | -cray | -microblaze)
os=
basic_machine=$1
;;
@ -284,6 +288,7 @@ case $basic_machine in
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
@ -291,13 +296,14 @@ case $basic_machine in
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| ubicom32 \
| v850 | v850e \
| we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
m6811 | m68hc11 | m6812 | m68hc12 | picochip)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
os=-none
@ -340,7 +346,7 @@ case $basic_machine in
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
@ -368,15 +374,17 @@ case $basic_machine in
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile-* | tilegx-* \
| tron-* \
| ubicom32-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
@ -726,6 +734,9 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
microblaze)
basic_machine=microblaze-xilinx
;;
mingw32)
basic_machine=i386-pc
os=-mingw32
@ -1076,6 +1087,11 @@ case $basic_machine in
basic_machine=tic6x-unknown
os=-coff
;;
# This must be matched before tile*.
tilegx*)
basic_machine=tilegx-unknown
os=-linux-gnu
;;
tile*)
basic_machine=tile-unknown
os=-linux-gnu
@ -1247,6 +1263,9 @@ case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-auroraux)
os=-auroraux
;;
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
@ -1268,8 +1287,8 @@ case $os in
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -kopensolaris* \
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
@ -1290,7 +1309,7 @@ case $os in
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@ -1423,6 +1442,8 @@ case $os in
-dicos*)
os=-dicos
;;
-nacl*)
;;
-none)
;;
*)

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save