Push constness through LoopInfo::isLoopHeader and clean it up a bit.
[oota-llvm.git] / include / llvm / CodeGen / CommandFlags.h
index ec7daeeba763e685a47d1be16036213cecc2de8a..b824df3013d9e7413690b53f3f4ae7e121017a9d 100644 (file)
@@ -236,9 +236,8 @@ JTableType("jump-table-type",
 static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
   TargetOptions Options;
   Options.LessPreciseFPMADOption = EnableFPMAD;
-  Options.NoFramePointerElim = DisableFPElim;
   Options.AllowFPOpFusion = FuseFPOps;
-  Options.Reciprocals = ReciprocalOps;
+  Options.Reciprocals = TargetRecip(ReciprocalOps);
   Options.UnsafeFPMath = EnableUnsafeFPMath;
   Options.NoInfsFPMath = EnableNoInfsFPMath;
   Options.NoNaNsFPMath = EnableNoNaNsFPMath;
@@ -295,14 +294,30 @@ static inline std::string getFeaturesStr() {
   return Features.getString();
 }
 
-static inline void overrideFunctionAttributes(StringRef CPU, StringRef Features,
-                                              Module &M) {
+/// \brief Set function attributes of functions in Module M based on CPU,
+/// Features, and command line flags.
+static inline void setFunctionAttributes(StringRef CPU, StringRef Features,
+                                         Module &M) {
   for (auto &F : M) {
+    auto &Ctx = F.getContext();
+    AttributeSet Attrs = F.getAttributes(), NewAttrs;
+
     if (!CPU.empty())
-      llvm::overrideFunctionAttribute("target-cpu", CPU, F);
+      NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
+                                       "target-cpu", CPU);
 
     if (!Features.empty())
-      llvm::overrideFunctionAttribute("target-features", Features, F);
+      NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
+                                       "target-features", Features);
+
+    if (DisableFPElim.getNumOccurrences() > 0)
+      NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
+                                       "no-frame-pointer-elim",
+                                       DisableFPElim ? "true" : "false");
+
+    // Let NewAttrs override Attrs.
+    NewAttrs = Attrs.addAttributes(Ctx, AttributeSet::FunctionIndex, NewAttrs);
+    F.setAttributes(NewAttrs);
   }
 }