зеркало из https://github.com/microsoft/clang-1.git
Revert changes r97693, r97700, and r97718.
Our testing framework can't deal with disabled targets yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97719 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
3ff63027f6
Коммит
468ec6c026
|
@ -20,7 +20,6 @@
|
|||
namespace llvm {
|
||||
class LLVMContext;
|
||||
class Module;
|
||||
class TargetMachine;
|
||||
}
|
||||
|
||||
namespace clang {
|
||||
|
@ -37,7 +36,6 @@ namespace clang {
|
|||
CodeGenerator *CreateLLVMCodeGen(Diagnostic &Diags,
|
||||
const std::string &ModuleName,
|
||||
const CodeGenOptions &CGO,
|
||||
const llvm::TargetMachine &Machine,
|
||||
llvm::LLVMContext& C);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
#include "clang/Basic/TargetBuiltins.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
using namespace clang;
|
||||
using namespace CodeGen;
|
||||
using namespace llvm;
|
||||
|
@ -410,18 +407,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
|
|||
Value *F = CGM.getIntrinsic(Intrinsic::eh_unwind_init, 0, 0);
|
||||
return RValue::get(Builder.CreateCall(F));
|
||||
}
|
||||
case Builtin::BI__builtin_dwarf_sp_column: {
|
||||
const llvm::TargetMachine &Machine = CGM.getTargetMachine();
|
||||
llvm::TargetLowering *TL = Machine.getTargetLowering();
|
||||
assert(TL && "need lowering to codegen __builtin_dwarf_sp_column");
|
||||
const llvm::TargetRegisterInfo *TRI = Machine.getRegisterInfo();
|
||||
assert(TRI && "need register info to codegen __builtin_dwarf_sp_column");
|
||||
unsigned SP = TL->getStackPointerRegisterToSaveRestore();
|
||||
int DwarfSP = TRI->getDwarfRegNum(SP, /*for EH*/ true);
|
||||
|
||||
return RValue::get(
|
||||
llvm::ConstantInt::getSigned(cast<IntegerType>(LLVMIntTy), DwarfSP));
|
||||
}
|
||||
case Builtin::BI__builtin_extend_pointer: {
|
||||
// Extends a pointer to the size of an _Unwind_Word, which is
|
||||
// uint64_t on all platforms. Generally this gets poked into a
|
||||
|
|
|
@ -40,12 +40,11 @@ using namespace CodeGen;
|
|||
|
||||
|
||||
CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO,
|
||||
llvm::Module &M, const llvm::TargetMachine &TM,
|
||||
const llvm::TargetData &TD, Diagnostic &diags)
|
||||
llvm::Module &M, const llvm::TargetData &TD,
|
||||
Diagnostic &diags)
|
||||
: BlockModule(C, M, TD, Types, *this), Context(C),
|
||||
Features(C.getLangOptions()), CodeGenOpts(CGO), TheModule(M),
|
||||
TheTargetMachine(TM), TheTargetData(TD), TheTargetCodeGenInfo(0),
|
||||
Diags(diags),
|
||||
TheTargetData(TD), TheTargetCodeGenInfo(0), Diags(diags),
|
||||
Types(C, M, TD, getTargetCodeGenInfo().getABIInfo()),
|
||||
MangleCtx(C), VtableInfo(*this), Runtime(0),
|
||||
MemCpyFn(0), MemMoveFn(0), MemSetFn(0), CFConstantStringClassRef(0),
|
||||
|
|
|
@ -38,7 +38,6 @@ namespace llvm {
|
|||
class Function;
|
||||
class GlobalValue;
|
||||
class TargetData;
|
||||
class TargetMachine;
|
||||
class FunctionType;
|
||||
class LLVMContext;
|
||||
}
|
||||
|
@ -87,7 +86,6 @@ class CodeGenModule : public BlockModule {
|
|||
const LangOptions &Features;
|
||||
const CodeGenOptions &CodeGenOpts;
|
||||
llvm::Module &TheModule;
|
||||
const llvm::TargetMachine &TheTargetMachine;
|
||||
const llvm::TargetData &TheTargetData;
|
||||
mutable const TargetCodeGenInfo *TheTargetCodeGenInfo;
|
||||
Diagnostic &Diags;
|
||||
|
@ -170,8 +168,7 @@ class CodeGenModule : public BlockModule {
|
|||
llvm::LLVMContext &VMContext;
|
||||
public:
|
||||
CodeGenModule(ASTContext &C, const CodeGenOptions &CodeGenOpts,
|
||||
llvm::Module &M, const llvm::TargetMachine &TM,
|
||||
const llvm::TargetData &TD, Diagnostic &Diags);
|
||||
llvm::Module &M, const llvm::TargetData &TD, Diagnostic &Diags);
|
||||
|
||||
~CodeGenModule();
|
||||
|
||||
|
@ -201,9 +198,6 @@ public:
|
|||
const llvm::TargetData &getTargetData() const { return TheTargetData; }
|
||||
llvm::LLVMContext &getLLVMContext() { return VMContext; }
|
||||
const TargetCodeGenInfo &getTargetCodeGenInfo() const;
|
||||
const llvm::TargetMachine &getTargetMachine() const {
|
||||
return TheTargetMachine;
|
||||
}
|
||||
|
||||
/// getDeclVisibilityMode - Compute the visibility of the decl \arg D.
|
||||
LangOptions::VisibilityMode getDeclVisibilityMode(const Decl *D) const;
|
||||
|
|
|
@ -29,7 +29,6 @@ namespace {
|
|||
class CodeGeneratorImpl : public CodeGenerator {
|
||||
Diagnostic &Diags;
|
||||
llvm::OwningPtr<const llvm::TargetData> TD;
|
||||
const llvm::TargetMachine &TM;
|
||||
ASTContext *Ctx;
|
||||
const CodeGenOptions CodeGenOpts; // Intentionally copied in.
|
||||
protected:
|
||||
|
@ -37,11 +36,8 @@ namespace {
|
|||
llvm::OwningPtr<CodeGen::CodeGenModule> Builder;
|
||||
public:
|
||||
CodeGeneratorImpl(Diagnostic &diags, const std::string& ModuleName,
|
||||
const CodeGenOptions &CGO,
|
||||
const llvm::TargetMachine &TM,
|
||||
llvm::LLVMContext& C)
|
||||
: Diags(diags), TM(TM), CodeGenOpts(CGO),
|
||||
M(new llvm::Module(ModuleName, C)) {}
|
||||
const CodeGenOptions &CGO, llvm::LLVMContext& C)
|
||||
: Diags(diags), CodeGenOpts(CGO), M(new llvm::Module(ModuleName, C)) {}
|
||||
|
||||
virtual ~CodeGeneratorImpl() {}
|
||||
|
||||
|
@ -60,7 +56,7 @@ namespace {
|
|||
M->setDataLayout(Ctx->Target.getTargetDescription());
|
||||
TD.reset(new llvm::TargetData(Ctx->Target.getTargetDescription()));
|
||||
Builder.reset(new CodeGen::CodeGenModule(Context, CodeGenOpts,
|
||||
*M, TM, *TD, Diags));
|
||||
*M, *TD, Diags));
|
||||
}
|
||||
|
||||
virtual void HandleTopLevelDecl(DeclGroupRef DG) {
|
||||
|
@ -99,7 +95,6 @@ namespace {
|
|||
CodeGenerator *clang::CreateLLVMCodeGen(Diagnostic &Diags,
|
||||
const std::string& ModuleName,
|
||||
const CodeGenOptions &CGO,
|
||||
const llvm::TargetMachine &Machine,
|
||||
llvm::LLVMContext& C) {
|
||||
return new CodeGeneratorImpl(Diags, ModuleName, CGO, Machine, C);
|
||||
return new CodeGeneratorImpl(Diags, ModuleName, CGO, C);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@ namespace {
|
|||
|
||||
llvm::OwningPtr<llvm::Module> TheModule;
|
||||
llvm::TargetData *TheTargetData;
|
||||
llvm::OwningPtr<llvm::TargetMachine> TheTargetMachine;
|
||||
|
||||
mutable FunctionPassManager *CodeGenPasses;
|
||||
mutable PassManager *PerModulePasses;
|
||||
|
@ -85,7 +84,6 @@ namespace {
|
|||
|
||||
public:
|
||||
BackendConsumer(BackendAction action, Diagnostic &_Diags,
|
||||
llvm::TargetMachine &machine,
|
||||
const LangOptions &langopts, const CodeGenOptions &compopts,
|
||||
const TargetOptions &targetopts, bool TimePasses,
|
||||
const std::string &infile, llvm::raw_ostream *OS,
|
||||
|
@ -98,8 +96,8 @@ namespace {
|
|||
AsmOutStream(OS),
|
||||
LLVMIRGeneration("LLVM IR Generation Time"),
|
||||
CodeGenerationTime("Code Generation Time"),
|
||||
Gen(CreateLLVMCodeGen(Diags, infile, compopts, machine, C)),
|
||||
TheTargetData(0), TheTargetMachine(&machine),
|
||||
Gen(CreateLLVMCodeGen(Diags, infile, compopts, C)),
|
||||
TheTargetData(0),
|
||||
CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {
|
||||
|
||||
if (AsmOutStream)
|
||||
|
@ -218,6 +216,15 @@ bool BackendConsumer::AddEmitPasses() {
|
|||
} else {
|
||||
bool Fast = CodeGenOpts.OptimizationLevel == 0;
|
||||
|
||||
// Create the TargetMachine for generating code.
|
||||
std::string Error;
|
||||
std::string Triple = TheModule->getTargetTriple();
|
||||
const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
|
||||
if (!TheTarget) {
|
||||
Diags.Report(diag::err_fe_unable_to_create_target) << Error;
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: Expose these capabilities via actual APIs!!!! Aside from just
|
||||
// being gross, this is also totally broken if we ever care about
|
||||
// concurrency.
|
||||
|
@ -234,6 +241,32 @@ bool BackendConsumer::AddEmitPasses() {
|
|||
llvm::UseSoftFloat = CodeGenOpts.SoftFloat;
|
||||
UnwindTablesMandatory = CodeGenOpts.UnwindTables;
|
||||
|
||||
TargetMachine::setAsmVerbosityDefault(CodeGenOpts.AsmVerbose);
|
||||
|
||||
// FIXME: Parse this earlier.
|
||||
if (CodeGenOpts.RelocationModel == "static") {
|
||||
TargetMachine::setRelocationModel(llvm::Reloc::Static);
|
||||
} else if (CodeGenOpts.RelocationModel == "pic") {
|
||||
TargetMachine::setRelocationModel(llvm::Reloc::PIC_);
|
||||
} else {
|
||||
assert(CodeGenOpts.RelocationModel == "dynamic-no-pic" &&
|
||||
"Invalid PIC model!");
|
||||
TargetMachine::setRelocationModel(llvm::Reloc::DynamicNoPIC);
|
||||
}
|
||||
// FIXME: Parse this earlier.
|
||||
if (CodeGenOpts.CodeModel == "small") {
|
||||
TargetMachine::setCodeModel(llvm::CodeModel::Small);
|
||||
} else if (CodeGenOpts.CodeModel == "kernel") {
|
||||
TargetMachine::setCodeModel(llvm::CodeModel::Kernel);
|
||||
} else if (CodeGenOpts.CodeModel == "medium") {
|
||||
TargetMachine::setCodeModel(llvm::CodeModel::Medium);
|
||||
} else if (CodeGenOpts.CodeModel == "large") {
|
||||
TargetMachine::setCodeModel(llvm::CodeModel::Large);
|
||||
} else {
|
||||
assert(CodeGenOpts.CodeModel.empty() && "Invalid code model!");
|
||||
TargetMachine::setCodeModel(llvm::CodeModel::Default);
|
||||
}
|
||||
|
||||
std::vector<const char *> BackendArgs;
|
||||
BackendArgs.push_back("clang"); // Fake program name.
|
||||
if (!CodeGenOpts.DebugPass.empty()) {
|
||||
|
@ -250,6 +283,18 @@ bool BackendConsumer::AddEmitPasses() {
|
|||
llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
|
||||
(char**) &BackendArgs[0]);
|
||||
|
||||
std::string FeaturesStr;
|
||||
if (TargetOpts.CPU.size() || TargetOpts.Features.size()) {
|
||||
SubtargetFeatures Features;
|
||||
Features.setCPU(TargetOpts.CPU);
|
||||
for (std::vector<std::string>::const_iterator
|
||||
it = TargetOpts.Features.begin(),
|
||||
ie = TargetOpts.Features.end(); it != ie; ++it)
|
||||
Features.AddFeature(*it);
|
||||
FeaturesStr = Features.getString();
|
||||
}
|
||||
TargetMachine *TM = TheTarget->createTargetMachine(Triple, FeaturesStr);
|
||||
|
||||
// Set register scheduler & allocation policy.
|
||||
RegisterScheduler::setDefault(createDefaultScheduler);
|
||||
RegisterRegAlloc::setDefault(Fast ? createLocalRegisterAllocator :
|
||||
|
@ -282,8 +327,8 @@ bool BackendConsumer::AddEmitPasses() {
|
|||
TargetMachine::CodeGenFileType CGFT = TargetMachine::CGFT_AssemblyFile;
|
||||
if (Action == Backend_EmitObj)
|
||||
CGFT = TargetMachine::CGFT_ObjectFile;
|
||||
if (TheTargetMachine->addPassesToEmitFile(*PM, FormattedOutStream,
|
||||
CGFT, OptLevel, DisableVerify)) {
|
||||
if (TM->addPassesToEmitFile(*PM, FormattedOutStream, CGFT, OptLevel,
|
||||
DisableVerify)) {
|
||||
Diags.Report(diag::err_fe_unable_to_interface_with_target);
|
||||
return false;
|
||||
}
|
||||
|
@ -417,65 +462,8 @@ llvm::Module *CodeGenAction::takeModule() {
|
|||
return TheModule.take();
|
||||
}
|
||||
|
||||
static llvm::TargetMachine *CreateTargetMachine(CompilerInstance &CI) {
|
||||
const CodeGenOptions &CodeGenOpts = CI.getCodeGenOpts();
|
||||
const TargetOptions &TargetOpts = CI.getTargetOpts();
|
||||
|
||||
std::string Error;
|
||||
std::string Triple = CI.getTarget().getTriple().getTriple();
|
||||
const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
|
||||
if (!TheTarget) {
|
||||
CI.getDiagnostics().Report(diag::err_fe_unable_to_create_target) << Error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
TargetMachine::setAsmVerbosityDefault(CodeGenOpts.AsmVerbose);
|
||||
|
||||
// FIXME: Parse this earlier.
|
||||
if (CodeGenOpts.RelocationModel == "static") {
|
||||
TargetMachine::setRelocationModel(llvm::Reloc::Static);
|
||||
} else if (CodeGenOpts.RelocationModel == "pic") {
|
||||
TargetMachine::setRelocationModel(llvm::Reloc::PIC_);
|
||||
} else {
|
||||
assert(CodeGenOpts.RelocationModel == "dynamic-no-pic" &&
|
||||
"Invalid PIC model!");
|
||||
TargetMachine::setRelocationModel(llvm::Reloc::DynamicNoPIC);
|
||||
}
|
||||
|
||||
// FIXME: Parse this earlier.
|
||||
if (CodeGenOpts.CodeModel == "small") {
|
||||
TargetMachine::setCodeModel(llvm::CodeModel::Small);
|
||||
} else if (CodeGenOpts.CodeModel == "kernel") {
|
||||
TargetMachine::setCodeModel(llvm::CodeModel::Kernel);
|
||||
} else if (CodeGenOpts.CodeModel == "medium") {
|
||||
TargetMachine::setCodeModel(llvm::CodeModel::Medium);
|
||||
} else if (CodeGenOpts.CodeModel == "large") {
|
||||
TargetMachine::setCodeModel(llvm::CodeModel::Large);
|
||||
} else {
|
||||
assert(CodeGenOpts.CodeModel.empty() && "Invalid code model!");
|
||||
TargetMachine::setCodeModel(llvm::CodeModel::Default);
|
||||
}
|
||||
|
||||
std::string FeaturesStr;
|
||||
if (TargetOpts.CPU.size() || TargetOpts.Features.size()) {
|
||||
SubtargetFeatures Features;
|
||||
Features.setCPU(TargetOpts.CPU);
|
||||
for (std::vector<std::string>::const_iterator
|
||||
it = TargetOpts.Features.begin(),
|
||||
ie = TargetOpts.Features.end(); it != ie; ++it)
|
||||
Features.AddFeature(*it);
|
||||
FeaturesStr = Features.getString();
|
||||
}
|
||||
|
||||
return TheTarget->createTargetMachine(Triple, FeaturesStr);
|
||||
}
|
||||
|
||||
ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI,
|
||||
llvm::StringRef InFile) {
|
||||
llvm::OwningPtr<llvm::TargetMachine> TM(CreateTargetMachine(CI));
|
||||
if (!TM)
|
||||
return 0;
|
||||
|
||||
BackendAction BA = static_cast<BackendAction>(Act);
|
||||
llvm::OwningPtr<llvm::raw_ostream> OS;
|
||||
switch (BA) {
|
||||
|
@ -497,15 +485,9 @@ ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI,
|
|||
if (BA != Backend_EmitNothing && !OS)
|
||||
return 0;
|
||||
|
||||
return new BackendConsumer(BA,
|
||||
CI.getDiagnostics(),
|
||||
*TM.take(),
|
||||
CI.getLangOpts(),
|
||||
CI.getCodeGenOpts(),
|
||||
CI.getTargetOpts(),
|
||||
CI.getFrontendOpts().ShowTimers,
|
||||
InFile,
|
||||
OS.take(),
|
||||
return new BackendConsumer(BA, CI.getDiagnostics(), CI.getLangOpts(),
|
||||
CI.getCodeGenOpts(), CI.getTargetOpts(),
|
||||
CI.getFrontendOpts().ShowTimers, InFile, OS.take(),
|
||||
CI.getLLVMContext());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=APCS-GNU %s
|
||||
// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=AAPCS %s
|
||||
|
||||
// XFAIL: win32
|
||||
|
||||
// APCS-GNU: define arm_apcscc signext i8 @f0()
|
||||
// AAPCS: define arm_aapcscc signext i8 @f0()
|
||||
char f0(void) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// RUN: %clang_cc1 -triple armv6-unknown-unknown -emit-llvm -o %t %s
|
||||
|
||||
// XFAIL: win32
|
||||
|
||||
void test0(void) {
|
||||
asm volatile("mov r0, r0" :: );
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
// XFAIL: win32
|
||||
|
||||
// CHECK: declare arm_aapcscc i32 @printf(i8*, ...)
|
||||
void f0() {
|
||||
printf("a\n");
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// RUN: %clang_cc1 -triple thumbv7-eabi -target-cpu cortex-a8 -O3 -emit-llvm -o %t %s
|
||||
|
||||
// XFAIL: win32
|
||||
|
||||
void *f0()
|
||||
{
|
||||
return __builtin_thread_pointer();
|
||||
|
|
|
@ -162,10 +162,3 @@ void bar() {
|
|||
|
||||
}
|
||||
// CHECK: }
|
||||
|
||||
// CHECK: define void @test0(
|
||||
void test0() {
|
||||
// CHECK: i64 7
|
||||
unsigned long long x = __builtin_dwarf_sp_column();
|
||||
}
|
||||
// CHECK: }
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix LSB %s
|
||||
|
||||
// XFAIL: win32
|
||||
|
||||
// CHECK-LSB: @.str = private constant [8 x i8] c"string0\00"
|
||||
// CHECK-LSB: @.str1 = private constant [8 x i8] c"string1\00"
|
||||
// CHECK-LSB: @.str2 = internal constant [36 x i8] c"h\00e\00l\00l\00o\00 \00\92! \00\03& \00\90! \00w\00o\00r\00l\00d\00\00\00", align 2
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
// We also check _Bool and empty structures, as these can have annoying
|
||||
// corner cases.
|
||||
|
||||
// XFAIL: win32
|
||||
|
||||
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -O3 -emit-llvm -o %t
|
||||
// RUN: not grep '@g0' %t
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// XFAIL: win32
|
||||
|
||||
// RUN: %clang_cc1 -g -triple armv6-apple-darwin9 -emit-llvm -o %t %s
|
||||
// RUN: %clang_cc1 -g -triple armv6-unknown-unknown -emit-llvm -o %t %s
|
||||
// RUN: %clang_cc1 -g -triple bfin-unknown-unknown -emit-llvm -o %t %s
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// RUN: %clang -ccc-host-triple i386-apple-darwin9 -arch armv7 -flto -S -o - %s | FileCheck %s
|
||||
|
||||
// XFAIL: win32
|
||||
|
||||
// CHECK: @f0
|
||||
// CHECK-NOT: ssp
|
||||
// CHECK: ) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче