From 5d99b15d8dc3f5f9bca64bd6817a5f499a2207ce Mon Sep 17 00:00:00 2001 From: Meador Inge Date: Sun, 6 Aug 2017 12:02:17 +0000 Subject: [PATCH] [AVR] Compute code model if one is not provided The patch from r310028 fixed things to work with the new `LLVMTargetMachine` constructor that came in on r309911. However, the fix was partial since an object of type `CodeModel::Model` must be passed to `LLVMTargetMachine` (not one of `Optional`). This patch fixes the problem in the same fashion that r309911 did for other machines: by checking if the passed optional code model has a value and using `CodeModel::Small` if not. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310200 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AVR/AVRTargetMachine.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Target/AVR/AVRTargetMachine.cpp b/lib/Target/AVR/AVRTargetMachine.cpp index 6430e767f3e..9865a79997c 100644 --- a/lib/Target/AVR/AVRTargetMachine.cpp +++ b/lib/Target/AVR/AVRTargetMachine.cpp @@ -40,17 +40,21 @@ static Reloc::Model getEffectiveRelocModel(Optional RM) { return RM.hasValue() ? *RM : Reloc::Static; } +static CodeModel::Model getEffectiveCodeModel(Optional CM) { + if (CM) + return *CM; + return CodeModel::Small; +} + AVRTargetMachine::AVRTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, Optional CM, - CodeGenOpt::Level OL, - bool JIT) - : LLVMTargetMachine( - T, AVRDataLayout, TT, - getCPU(CPU), FS, Options, getEffectiveRelocModel(RM), - CM, OL), + CodeGenOpt::Level OL, bool JIT) + : LLVMTargetMachine(T, AVRDataLayout, TT, getCPU(CPU), FS, Options, + getEffectiveRelocModel(RM), getEffectiveCodeModel(CM), + OL), SubTarget(TT, getCPU(CPU), FS, *this) { this->TLOF = make_unique(); initAsmInfo(); -- 2.40.0