mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
For PR780:
Break the "IncludeFile" mechanism into its own header file and adjust other files accordingly. Use this facility for the IntrinsicInst problem which was the subject of PR800. More to follow on this. llvm-svn: 28709
This commit is contained in:
parent
45e0a3c8fa
commit
3832b7f9c4
@ -31,7 +31,7 @@
|
||||
#define LLVM_ANALYSIS_ALIAS_ANALYSIS_H
|
||||
|
||||
#include "llvm/Support/CallSite.h"
|
||||
#include "llvm/Pass.h" // Need this for IncludeFile
|
||||
#include "llvm/Support/IncludeFile.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -39,6 +39,8 @@ class LoadInst;
|
||||
class StoreInst;
|
||||
class VAArgInst;
|
||||
class TargetData;
|
||||
class Pass;
|
||||
class AnalysisUsage;
|
||||
|
||||
class AliasAnalysis {
|
||||
protected:
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/Support/IncludeFile.h"
|
||||
|
||||
namespace llvm {
|
||||
/// IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic
|
||||
@ -312,6 +313,12 @@ namespace llvm {
|
||||
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
|
||||
}
|
||||
};
|
||||
|
||||
// A hack to ensure that the IntrinsicInst.cpp file gets added as a dependency
|
||||
// of any file that
|
||||
extern char LinkIntrinsicInstStub;
|
||||
static IncludeFile LinkIntrinsicInst(&LinkIntrinsicInstStub);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
59
include/llvm/LinkAllVMCore.h
Normal file
59
include/llvm/LinkAllVMCore.h
Normal file
@ -0,0 +1,59 @@
|
||||
//===- LinkAllVMCore.h - Reference All VMCore Code --------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by Reid Spencer and is distributed under the
|
||||
// University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This header file pulls in all analysis passes for tools like analyze and
|
||||
// bugpoint that need this functionality.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LINKALLVMCORE_H
|
||||
#define LLVM_LINKALLVMCORE_H
|
||||
|
||||
#include <llvm/Support/IncludeFile.h>
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/IntrinsicInst.h>
|
||||
#include <llvm/IntrinsicInst.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/Analysis/Dominators.h>
|
||||
#include <llvm/Analysis/Verifier.h>
|
||||
|
||||
namespace {
|
||||
struct ForceVMCoreLinking {
|
||||
ForceVMCoreLinking() {
|
||||
// We must reference the passes in such a way that compilers will not
|
||||
// delete it all as dead code, even with whole program optimization,
|
||||
// yet is effectively a NO-OP. As the compiler isn't smart enough
|
||||
// to know that getenv() never returns -1, this will do the job.
|
||||
if (std::getenv("bar") != (char*) -1)
|
||||
return;
|
||||
|
||||
(void)new llvm::LocalDataStructures();
|
||||
(void)new llvm::BUDataStructures();
|
||||
(void)new llvm::TDDataStructures();
|
||||
(void)new llvm::CompleteBUDataStructures();
|
||||
(void)new llvm::EquivClassGraphs();
|
||||
(void)llvm::createDataStructureStatsPass();
|
||||
(void)llvm::createDataStructureGraphCheckerPass();
|
||||
(void)llvm::createProfileLoaderPass();
|
||||
(void)llvm::createNoProfileInfoPass();
|
||||
(void)llvm::createInstCountPass();
|
||||
(void)new llvm::IntervalPartition();
|
||||
(void)new llvm::ImmediateDominators();
|
||||
(void)new llvm::PostDominatorSet();
|
||||
(void)new llvm::FindUsedTypes();
|
||||
(void)new llvm::ScalarEvolution();
|
||||
(void)new llvm::CallTargetFinder();
|
||||
((llvm::Function*)0)->viewCFGOnly();
|
||||
llvm::AliasSetTracker X(*(llvm::AliasAnalysis*)0);
|
||||
X.add((llvm::Value*)0, 0); // for -print-alias-sets
|
||||
}
|
||||
} ForceVMCoreLinking;
|
||||
}
|
||||
|
||||
#endif
|
@ -21,6 +21,7 @@
|
||||
#ifndef LLVM_PASS_SUPPORT_H
|
||||
#define LLVM_PASS_SUPPORT_H
|
||||
|
||||
#include "llvm/Support/IncludeFile.h"
|
||||
// No need to include Pass.h, we are being included by it!
|
||||
|
||||
namespace llvm {
|
||||
@ -367,17 +368,6 @@ struct PassRegistrationListener {
|
||||
virtual void passEnumerate(const PassInfo *P) {}
|
||||
};
|
||||
|
||||
|
||||
//===---------------------------------------------------------------------------
|
||||
/// IncludeFile class - This class is used as a hack to make sure that the
|
||||
/// implementation of a header file is included into a tool that uses the
|
||||
/// header. This is solely to overcome problems linking .a files and not
|
||||
/// getting the implementation of passes we need.
|
||||
///
|
||||
struct IncludeFile {
|
||||
IncludeFile(void *);
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
40
include/llvm/Support/IncludeFile.h
Normal file
40
include/llvm/Support/IncludeFile.h
Normal file
@ -0,0 +1,40 @@
|
||||
//===- llvm/Support/IncludeFile.h - Ensure Linking Of Library ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by Reid Spencer and is distributed under the
|
||||
// University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the IncludeFile class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// This class is used as a facility to make sure that the implementation of a
|
||||
/// header file is included into a tool that uses the header. This is solely
|
||||
/// to overcome problems linking .a files and not getting the implementation
|
||||
/// of compilation units we need. This is commonly an issue with the various
|
||||
/// Passes but also occurs elsewhere in LLVM. We like to use .a files because
|
||||
/// they link faster and provide the smallest executables. However, sometimes
|
||||
/// those executables are too small, if the program doesn't reference something
|
||||
/// that might be needed, especially by a loaded share object. This little class
|
||||
/// helps to resolve that problem. The basic strategy is to use this class in
|
||||
/// a header file and pass the address of a variable to the constructor. If the
|
||||
/// variable is defined in the header file's corresponding .cpp file then all
|
||||
/// tools/libraries that #include the header file will require the .cpp as well.
|
||||
/// For example:<br/>
|
||||
/// <tt>extern int LinkMyCodeStub;</tt><br/>
|
||||
/// <tt>static IncludeFile LinkMyModule(&LinkMyCodeStub);</tt><br/>
|
||||
/// @brief Class to ensure linking of corresponding object file.
|
||||
|
||||
#ifndef LLVM_SUPPORT_INCLUDEFILE_H
|
||||
#define LLVM_SUPPORT_INCLUDEFILE_H
|
||||
|
||||
namespace llvm {
|
||||
struct IncludeFile {
|
||||
IncludeFile(void *);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
40
include/llvm/System/IncludeFile.h
Normal file
40
include/llvm/System/IncludeFile.h
Normal file
@ -0,0 +1,40 @@
|
||||
//===- llvm/Support/IncludeFile.h - Ensure Linking Of Library ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by Reid Spencer and is distributed under the
|
||||
// University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the IncludeFile class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// This class is used as a facility to make sure that the implementation of a
|
||||
/// header file is included into a tool that uses the header. This is solely
|
||||
/// to overcome problems linking .a files and not getting the implementation
|
||||
/// of compilation units we need. This is commonly an issue with the various
|
||||
/// Passes but also occurs elsewhere in LLVM. We like to use .a files because
|
||||
/// they link faster and provide the smallest executables. However, sometimes
|
||||
/// those executables are too small, if the program doesn't reference something
|
||||
/// that might be needed, especially by a loaded share object. This little class
|
||||
/// helps to resolve that problem. The basic strategy is to use this class in
|
||||
/// a header file and pass the address of a variable to the constructor. If the
|
||||
/// variable is defined in the header file's corresponding .cpp file then all
|
||||
/// tools/libraries that #include the header file will require the .cpp as well.
|
||||
/// For example:<br/>
|
||||
/// <tt>extern int LinkMyCodeStub;</tt><br/>
|
||||
/// <tt>static IncludeFile LinkMyModule(&LinkMyCodeStub);</tt><br/>
|
||||
/// @brief Class to ensure linking of corresponding object file.
|
||||
|
||||
#ifndef LLVM_SUPPORT_INCLUDEFILE_H
|
||||
#define LLVM_SUPPORT_INCLUDEFILE_H
|
||||
|
||||
namespace llvm {
|
||||
struct IncludeFile {
|
||||
IncludeFile(void *);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -25,6 +25,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/BasicBlock.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Type.h"
|
||||
|
20
lib/Support/IncludeFile.cpp
Normal file
20
lib/Support/IncludeFile.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//===- lib/Support/IncludeFile.cpp - Ensure Linking Of Implementation -----===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by Reid Spencer and is distributed under the
|
||||
// University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the IncludeFile constructor.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Support/IncludeFile.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
// This constructor is used to ensure linking of other modules. See the
|
||||
// llvm/Support/IncludeFile.h header for details.
|
||||
IncludeFile::IncludeFile(void*) {}
|
20
lib/System/IncludeFile.cpp
Normal file
20
lib/System/IncludeFile.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//===- lib/Support/IncludeFile.cpp - Ensure Linking Of Implementation -----===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by Reid Spencer and is distributed under the
|
||||
// University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the IncludeFile constructor.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Support/IncludeFile.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
// This constructor is used to ensure linking of other modules. See the
|
||||
// llvm/Support/IncludeFile.h header for details.
|
||||
IncludeFile::IncludeFile(void*) {}
|
@ -71,3 +71,7 @@ std::string DbgStopPointInst::getDirectory() const {
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// LinkIntrinsicInstStub -- This is a hack to make sure that programs that
|
||||
/// #include IntrinsicInst.h also link this file. See Support/IncludeFile.h
|
||||
/// for further details.
|
||||
char llvm::LinkIntrinsicInstStub;
|
||||
|
@ -23,9 +23,6 @@
|
||||
#include <set>
|
||||
using namespace llvm;
|
||||
|
||||
// IncludeFile - Stub function used to help linking out.
|
||||
IncludeFile::IncludeFile(void*) {}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// AnalysisID Class Implementation
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user