Apply changes to migrate to LLVM upstream Oct 20th 2011.
- StructType::isAnonymous is renamed to isLiteral.
- StructType::createNamed is renamed to create.
- ConstantExpr::getGetElementPtr and
ConstantExpr::getInboundsGetElementPtr is adopting llvm::ArrayRef.
- TargetRegistry and TargetSelect is moved from Target to Support.
- LLVMInitialize<TARGET>MCInfo, LLVMInitialize<TARGET>MCCodeGenInfo, and
LLVMInitialize<TARGET>MCSubtargetInfo has been unified by
LLVMInitialize<TARGET>TargetMC.
- llvm::setCodeModel is no longer available. Now we should pass the code
model to createTargetMachine.
- llvm::Linker::LinkerModules come with one addtional parameter (3rd),
which indicate that rather the source module should be destroyed or
not. Passing llvm::Linker::DestroySource should result in same
semantics as the old code.
Change-Id: I863f804893e528c9e6c7bf73737c17176277b18b
diff --git a/bcinfo/BitReader_2_7/BitcodeReader.cpp b/bcinfo/BitReader_2_7/BitcodeReader.cpp
index 762a13d..d2449de 100644
--- a/bcinfo/BitReader_2_7/BitcodeReader.cpp
+++ b/bcinfo/BitReader_2_7/BitcodeReader.cpp
@@ -375,7 +375,7 @@
// If we have a forward reference, the only possible case is when it is to a
// named struct. Just create a placeholder for now.
- return TypeList[ID] = StructType::createNamed(Context, "");
+ return TypeList[ID] = StructType::create(Context, "");
}
/// FIXME: Remove in LLVM 3.1, only used by ParseOldTypeTable.
@@ -643,7 +643,7 @@
Res->setName(TypeName);
TypeList[NumRecords] = 0;
} else // Otherwise, create a new struct.
- Res = StructType::createNamed(Context, TypeName);
+ Res = StructType::create(Context, TypeName);
TypeName.clear();
SmallVector<Type*, 8> EltTys;
@@ -672,7 +672,7 @@
Res->setName(TypeName);
TypeList[NumRecords] = 0;
} else // Otherwise, create a new struct with no body.
- Res = StructType::createNamed(Context, TypeName);
+ Res = StructType::create(Context, TypeName);
TypeName.clear();
ResultTy = Res;
break;
@@ -806,7 +806,7 @@
break;
case bitc::TYPE_CODE_OPAQUE: // OPAQUE
if (NextTypeID < TypeList.size() && TypeList[NextTypeID] == 0)
- ResultTy = StructType::createNamed(Context, "");
+ ResultTy = StructType::create(Context, "");
break;
case bitc::TYPE_CODE_STRUCT_OLD: {// STRUCT_OLD
if (NextTypeID >= TypeList.size()) break;
@@ -817,7 +817,7 @@
// Set a type.
if (TypeList[NextTypeID] == 0)
- TypeList[NextTypeID] = StructType::createNamed(Context, "");
+ TypeList[NextTypeID] = StructType::create(Context, "");
std::vector<Type*> EltTys;
for (unsigned i = 1, e = Record.size(); i != e; ++i) {
@@ -936,7 +936,7 @@
// Only apply the type name to a struct type with no name.
if (StructType *STy = dyn_cast<StructType>(TypeList[TypeID]))
- if (!STy->isAnonymous() && !STy->hasName())
+ if (!STy->isLiteral() && !STy->hasName())
STy->setName(TypeName);
TypeName.clear();
break;
@@ -1380,11 +1380,11 @@
Elts.push_back(ValueList.getConstantFwdRef(Record[i+1], ElTy));
}
if (BitCode == bitc::CST_CODE_CE_INBOUNDS_GEP)
- V = ConstantExpr::getInBoundsGetElementPtr(Elts[0], &Elts[1],
- Elts.size()-1);
+ V = ConstantExpr::getInBoundsGetElementPtr(Elts[0],
+ llvm::ArrayRef<llvm::Constant*>(&Elts[1], Elts.size() - 1));
else
- V = ConstantExpr::getGetElementPtr(Elts[0], &Elts[1],
- Elts.size()-1);
+ V = ConstantExpr::getGetElementPtr(Elts[0],
+ llvm::ArrayRef<llvm::Constant*>(&Elts[1], Elts.size() - 1));
break;
}
case bitc::CST_CODE_CE_SELECT: // CE_SELECT: [opval#, opval#, opval#]
@@ -2215,7 +2215,7 @@
GEPIdx.push_back(Op);
}
- I = GetElementPtrInst::Create(BasePtr, GEPIdx.begin(), GEPIdx.end());
+ I = GetElementPtrInst::Create(BasePtr, GEPIdx);
InstructionList.push_back(I);
if (BitCode == bitc::FUNC_CODE_INST_INBOUNDS_GEP)
cast<GetElementPtrInst>(I)->setIsInBounds(true);
diff --git a/lib/ExecutionEngine/Compiler.cpp b/lib/ExecutionEngine/Compiler.cpp
index a26c1c3..be67bdf 100644
--- a/lib/ExecutionEngine/Compiler.cpp
+++ b/lib/ExecutionEngine/Compiler.cpp
@@ -54,12 +54,12 @@
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
-#include "llvm/Target/TargetRegistry.h"
-#include "llvm/Target/TargetSelect.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
#include "llvm/Type.h"
#include "llvm/GlobalValue.h"
@@ -154,19 +154,15 @@
#endif // DEFAULT_ARM_CODEGEN
#if defined(PROVIDE_ARM_CODEGEN)
- LLVMInitializeARMMCAsmInfo();
- LLVMInitializeARMMCCodeGenInfo();
- LLVMInitializeARMMCSubtargetInfo();
LLVMInitializeARMAsmPrinter();
+ LLVMInitializeARMTargetMC();
LLVMInitializeARMTargetInfo();
LLVMInitializeARMTarget();
#endif
#if defined(PROVIDE_X86_CODEGEN)
- LLVMInitializeX86MCAsmInfo();
- LLVMInitializeX86MCCodeGenInfo();
- LLVMInitializeX86MCSubtargetInfo();
LLVMInitializeX86AsmPrinter();
+ LLVMInitializeX86TargetMC();
LLVMInitializeX86TargetInfo();
LLVMInitializeX86Target();
#endif
@@ -197,15 +193,6 @@
llvm::FloatABIType = llvm::FloatABI::Soft;
llvm::UseSoftFloat = false;
-#if defined(DEFAULT_X86_64_CODEGEN)
- // Data address in X86_64 architecture may reside in a far-away place
- llvm::TargetMachine::setCodeModel(llvm::CodeModel::Medium);
-#else
- // This is set for the linker (specify how large of the virtual addresses
- // we can access for all unknown symbols.)
- llvm::TargetMachine::setCodeModel(llvm::CodeModel::Small);
-#endif
-
// Register the scheduler
llvm::RegisterScheduler::setDefault(llvm::createDefaultScheduler);
@@ -282,7 +269,9 @@
int Compiler::linkModule(llvm::Module *moduleWith) {
- if (llvm::Linker::LinkModules(mModule, moduleWith, &mError) != 0) {
+ if (llvm::Linker::LinkModules(mModule, moduleWith,
+ llvm::Linker::DestroySource,
+ &mError) != 0) {
return hasError();
}
@@ -323,8 +312,18 @@
FeaturesStr = F.getString();
}
+#if defined(DEFAULT_X86_64_CODEGEN)
+ // Data address in X86_64 architecture may reside in a far-away place
TM = Target->createTargetMachine(Triple, CPU, FeaturesStr,
- llvm::Reloc::Static);
+ llvm::Reloc::Static,
+ llvm::CodeModel::Medium);
+#else
+ // This is set for the linker (specify how large of the virtual addresses
+ // we can access for all unknown symbols.)
+ TM = Target->createTargetMachine(Triple, CPU, FeaturesStr,
+ llvm::Reloc::Static,
+ llvm::CodeModel::Small);
+#endif
if (TM == NULL) {
setError("Failed to create target machine implementation for the"
" specified triple '" + Triple + "'");