[llvm] r310200 - [AVR] Compute code model if one is not provided

Meador Inge via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 6 05:02:17 PDT 2017


Author: meadori
Date: Sun Aug  6 05:02:17 2017
New Revision: 310200

URL: http://llvm.org/viewvc/llvm-project?rev=310200&view=rev
Log:
[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<CodeModel::Model>`).

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.

Modified:
    llvm/trunk/lib/Target/AVR/AVRTargetMachine.cpp

Modified: llvm/trunk/lib/Target/AVR/AVRTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/AVRTargetMachine.cpp?rev=310200&r1=310199&r2=310200&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AVR/AVRTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/AVR/AVRTargetMachine.cpp Sun Aug  6 05:02:17 2017
@@ -40,17 +40,21 @@ static Reloc::Model getEffectiveRelocMod
   return RM.hasValue() ? *RM : Reloc::Static;
 }
 
+static CodeModel::Model getEffectiveCodeModel(Optional<CodeModel::Model> CM) {
+  if (CM)
+    return *CM;
+  return CodeModel::Small;
+}
+
 AVRTargetMachine::AVRTargetMachine(const Target &T, const Triple &TT,
                                    StringRef CPU, StringRef FS,
                                    const TargetOptions &Options,
                                    Optional<Reloc::Model> RM,
                                    Optional<CodeModel::Model> 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<AVRTargetObjectFile>();
   initAsmInfo();




More information about the llvm-commits mailing list