<div dir="ltr">Hi Philip,<div><br></div><div>Are you using LLVMCreateMCJITCompiledForModule? If you are, you don't have to change anything as this commit preserves the existing behavior. If you are using another interface (for example, EngineBuilder::create), you'll need to attach the attribute "no-frame-pointer-elim" to every function in the module. I'm not aware of any documentation, but I think you can just write a piece of code like the one I committed in this patch (the changes I made in LLVMCreateMCJITCompiledForModule) to attach the attribute.</div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 26, 2015 at 2:15 PM, Philip Reames <span dir="ltr"><<a href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Akira,<br>
<br>
Can you give a bit more detail here?  I have an out of tree user of the EE interface which uses the NoFramePointerElim options.  I'm specifically using this to override the target default.  How do I update to preserve existing behaviour?  It looks like I need to attach a new attribute to every function declaration?  Can you point me to some documentation here?<span><font color="#888888"><br>
<br>
Philip</font></span><div><div><br>
<br>
On 05/26/2015 01:17 PM, Akira Hatanaka wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Author: ahatanak<br>
Date: Tue May 26 15:17:20 2015<br>
New Revision: 238244<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D238244-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=lICKfKTziBcVq2Yqk6Y25tBzRtjRnXiowrsoBJ79z6M&s=XlxIVqd75mKp9E6jjJIf-BVW8yzwgU8TAlipuRIyGz4&e=" target="_blank">http://llvm.org/viewvc/llvm-project?rev=238244&view=rev</a><br>
Log:<br>
Remove NoFramePointerElim and NoFramePointerElimOverride from TargetOptions and<br>
remove ExecutionEngine's dependence on CodeGen. NFC.<br>
<br>
This is a follow-up to r238080.<br>
<br>
Differential Revision: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D9830&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=lICKfKTziBcVq2Yqk6Y25tBzRtjRnXiowrsoBJ79z6M&s=tKV_54-c65JpGJxylReub-l6urCOY7cMp9vW1sv72OQ&e=" target="_blank">http://reviews.llvm.org/D9830</a><br>
<br>
Modified:<br>
     llvm/trunk/include/llvm/CodeGen/CommandFlags.h<br>
     llvm/trunk/include/llvm/Target/TargetOptions.h<br>
     llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp<br>
     llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp<br>
     llvm/trunk/lib/ExecutionEngine/LLVMBuild.txt<br>
     llvm/trunk/tools/llc/llc.cpp<br>
     llvm/trunk/tools/opt/opt.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/CodeGen/CommandFlags.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_CodeGen_CommandFlags.h-3Frev-3D238244-26r1-3D238243-26r2-3D238244-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=lICKfKTziBcVq2Yqk6Y25tBzRtjRnXiowrsoBJ79z6M&s=hdKqAiwlhRpTn87KArJ-9oCsLDygftL1D92xOTa6800&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CommandFlags.h?rev=238244&r1=238243&r2=238244&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/CodeGen/CommandFlags.h (original)<br>
+++ llvm/trunk/include/llvm/CodeGen/CommandFlags.h Tue May 26 15:17:20 2015<br>
@@ -229,8 +229,6 @@ JTableType("jump-table-type",<br>
  static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {<br>
    TargetOptions Options;<br>
    Options.LessPreciseFPMADOption = EnableFPMAD;<br>
-  Options.NoFramePointerElim = DisableFPElim;<br>
-  Options.NoFramePointerElimOverride = DisableFPElim.getNumOccurrences() > 0;<br>
    Options.AllowFPOpFusion = FuseFPOps;<br>
    Options.UnsafeFPMath = EnableUnsafeFPMath;<br>
    Options.NoInfsFPMath = EnableNoInfsFPMath;<br>
@@ -288,4 +286,31 @@ static inline std::string getFeaturesStr<br>
    return Features.getString();<br>
  }<br>
  +/// \brief Set function attributes of functions in Module M based on CPU,<br>
+/// Features, and command line flags.<br>
+static inline void setFunctionAttributes(StringRef CPU, StringRef Features,<br>
+                                         Module &M) {<br>
+  for (auto &F : M) {<br>
+    auto &Ctx = F.getContext();<br>
+    AttributeSet Attrs = F.getAttributes(), NewAttrs;<br>
+<br>
+    if (!CPU.empty())<br>
+      NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,<br>
+                                       "target-cpu", CPU);<br>
+<br>
+    if (!Features.empty())<br>
+      NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,<br>
+                                       "target-features", Features);<br>
+<br>
+    if (DisableFPElim.getNumOccurrences() > 0)<br>
+      NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,<br>
+                                       "no-frame-pointer-elim",<br>
+                                       DisableFPElim ? "true" : "false");<br>
+<br>
+    // Let NewAttrs override Attrs.<br>
+    NewAttrs = Attrs.addAttributes(Ctx, AttributeSet::FunctionIndex, NewAttrs);<br>
+    F.setAttributes(NewAttrs);<br>
+  }<br>
+}<br>
+<br>
  #endif<br>
<br>
Modified: llvm/trunk/include/llvm/Target/TargetOptions.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_Target_TargetOptions.h-3Frev-3D238244-26r1-3D238243-26r2-3D238244-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=lICKfKTziBcVq2Yqk6Y25tBzRtjRnXiowrsoBJ79z6M&s=876QtKEVlvkJ628Pugaok6WM-1lyQ6qg0gnY2vjRSAs&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetOptions.h?rev=238244&r1=238243&r2=238244&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Target/TargetOptions.h (original)<br>
+++ llvm/trunk/include/llvm/Target/TargetOptions.h Tue May 26 15:17:20 2015<br>
@@ -60,8 +60,7 @@ namespace llvm {<br>
    class TargetOptions {<br>
    public:<br>
      TargetOptions()<br>
-        : PrintMachineCode(false), NoFramePointerElim(false),<br>
-          NoFramePointerElimOverride(false),<br>
+        : PrintMachineCode(false),<br>
            LessPreciseFPMADOption(false), UnsafeFPMath(false),<br>
            NoInfsFPMath(false), NoNaNsFPMath(false),<br>
            HonorSignDependentRoundingFPMathOption(false),<br>
@@ -81,14 +80,6 @@ namespace llvm {<br>
      /// output from the code generator.<br>
      unsigned PrintMachineCode : 1;<br>
  -    /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is<br>
-    /// specified on the command line.  If the target supports the frame pointer<br>
-    /// elimination optimization, this option should disable it.<br>
-    unsigned NoFramePointerElim : 1;<br>
-<br>
-    /// This flag is true when "disable-fp-elim" appeared on the command line.<br>
-    unsigned NoFramePointerElimOverride : 1;<br>
-<br>
      /// DisableFramePointerElim - This returns true if frame pointer elimination<br>
      /// optimization should be disabled for the given machine function.<br>
      bool DisableFramePointerElim(const MachineFunction &MF) const;<br>
@@ -227,15 +218,6 @@ namespace llvm {<br>
      MCTargetOptions MCOptions;<br>
    };<br>
  -/// \brief Set function attributes of functions in Module M based on CPU,<br>
-/// Features, and Options.<br>
-/// If AlwaysRecordAttrs is true, it will always record the function attributes<br>
-/// in Options regardless of whether those attributes were specified on the<br>
-/// tool's command line.<br>
-void setFunctionAttributes(StringRef CPU, StringRef Features,<br>
-                           const TargetOptions &Options, Module &M,<br>
-                           bool AlwaysRecordAttrs);<br>
-<br>
  // Comparison operators:<br>
    <br>
Modified: llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_TargetOptionsImpl.cpp-3Frev-3D238244-26r1-3D238243-26r2-3D238244-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=lICKfKTziBcVq2Yqk6Y25tBzRtjRnXiowrsoBJ79z6M&s=MZfjWuX1X67xb2_Y9jmvcaj7v9QyRMdLmb98vJ4RynY&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp?rev=238244&r1=238243&r2=238244&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp Tue May 26 15:17:20 2015<br>
@@ -54,30 +54,3 @@ bool TargetOptions::HonorSignDependentRo<br>
  StringRef TargetOptions::getTrapFunctionName() const {<br>
    return TrapFuncName;<br>
  }<br>
-<br>
-<br>
-void llvm::setFunctionAttributes(StringRef CPU, StringRef Features,<br>
-                                 const TargetOptions &Options, Module &M,<br>
-                                 bool AlwaysRecordAttrs) {<br>
-  for (auto &F : M) {<br>
-    auto &Ctx = F.getContext();<br>
-    AttributeSet Attrs = F.getAttributes(), NewAttrs;<br>
-<br>
-    if (!CPU.empty())<br>
-      NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,<br>
-                                       "target-cpu", CPU);<br>
-<br>
-    if (!Features.empty())<br>
-      NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,<br>
-                                       "target-features", Features);<br>
-<br>
-    if (Options.NoFramePointerElimOverride || AlwaysRecordAttrs)<br>
-      NewAttrs = NewAttrs.addAttribute(<br>
-          Ctx, AttributeSet::FunctionIndex, "no-frame-pointer-elim",<br>
-          Options.NoFramePointerElim ? "true" : "false");<br>
-<br>
-    // Let NewAttrs override Attrs.<br>
-    NewAttrs = Attrs.addAttributes(Ctx, AttributeSet::FunctionIndex, NewAttrs);<br>
-    F.setAttributes(NewAttrs);<br>
-  }<br>
-}<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_ExecutionEngine_ExecutionEngineBindings.cpp-3Frev-3D238244-26r1-3D238243-26r2-3D238244-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=lICKfKTziBcVq2Yqk6Y25tBzRtjRnXiowrsoBJ79z6M&s=_4Ivn0taTDeExJM6-1LsMoQdlTOZaKrq_b3yIt-6eyw&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp?rev=238244&r1=238243&r2=238244&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp Tue May 26 15:17:20 2015<br>
@@ -177,15 +177,19 @@ LLVMBool LLVMCreateMCJITCompilerForModul<br>
    memcpy(&options, PassedOptions, SizeOfPassedOptions);<br>
        TargetOptions targetOptions;<br>
-  targetOptions.NoFramePointerElim = options.NoFramePointerElim;<br>
    targetOptions.EnableFastISel = options.EnableFastISel;<br>
    std::unique_ptr<Module> Mod(unwrap(M));<br>
      if (Mod)<br>
      // Set function attribute "no-frame-pointer-elim" based on<br>
      // NoFramePointerElim.<br>
-    setFunctionAttributes(/* CPU */ "", /* Features */ "", targetOptions, *Mod,<br>
-                          /* AlwaysRecordAttrs */ true);<br>
+    for (auto &F : *Mod) {<br>
+      auto Attrs = F.getAttributes();<br>
+      auto Value = options.NoFramePointerElim ? "true" : "false";<br>
+      Attrs = Attrs.addAttribute(F.getContext(), AttributeSet::FunctionIndex,<br>
+                                 "no-frame-pointer-elim", Value);<br>
+      F.setAttributes(Attrs);<br>
+    }<br>
      std::string Error;<br>
    EngineBuilder builder(std::move(Mod));<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/LLVMBuild.txt<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_ExecutionEngine_LLVMBuild.txt-3Frev-3D238244-26r1-3D238243-26r2-3D238244-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=lICKfKTziBcVq2Yqk6Y25tBzRtjRnXiowrsoBJ79z6M&s=9N54GNKF3C0CgtjYMWt-bQl6hHU0Q2z-n_5GiSfjc4Q&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/LLVMBuild.txt?rev=238244&r1=238243&r2=238244&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/LLVMBuild.txt (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/LLVMBuild.txt Tue May 26 15:17:20 2015<br>
@@ -22,4 +22,4 @@ subdirectories = Interpreter MCJIT Runti<br>
  type = Library<br>
  name = ExecutionEngine<br>
  parent = Libraries<br>
-required_libraries = CodeGen Core MC Object RuntimeDyld Support<br>
+required_libraries = Core MC Object RuntimeDyld Support<br>
<br>
Modified: llvm/trunk/tools/llc/llc.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_tools_llc_llc.cpp-3Frev-3D238244-26r1-3D238243-26r2-3D238244-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=lICKfKTziBcVq2Yqk6Y25tBzRtjRnXiowrsoBJ79z6M&s=UQ5UENpA4Ha7JBOn075WcwzCXoUb3qf3tCxo1s9qW1Y&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=238244&r1=238243&r2=238244&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llc/llc.cpp (original)<br>
+++ llvm/trunk/tools/llc/llc.cpp Tue May 26 15:17:20 2015<br>
@@ -304,11 +304,9 @@ static int compileModule(char **argv, LL<br>
    if (const DataLayout *DL = Target->getDataLayout())<br>
      M->setDataLayout(*DL);<br>
  -  // Override function attributes based on CPUStr, FeaturesStr, and Options.<br>
-  // Pass AlwaysRecordAttrs=false as we want to override an attribute only when<br>
-  // the corresponding cl::opt has been provided on llc's command line.<br>
-  setFunctionAttributes(CPUStr, FeaturesStr, Options, *M,<br>
-                        /* AlwaysRecordAttrs */ false);<br>
+  // Override function attributes based on CPUStr, FeaturesStr, and command line<br>
+  // flags.<br>
+  setFunctionAttributes(CPUStr, FeaturesStr, *M);<br>
      if (RelaxAll.getNumOccurrences() > 0 &&<br>
        FileType != TargetMachine::CGFT_ObjectFile)<br>
<br>
Modified: llvm/trunk/tools/opt/opt.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_tools_opt_opt.cpp-3Frev-3D238244-26r1-3D238243-26r2-3D238244-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=lICKfKTziBcVq2Yqk6Y25tBzRtjRnXiowrsoBJ79z6M&s=vxzCIHuazvOhfEvKD5loNWubMhDBxxZoDoIfHrZ6EDk&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=238244&r1=238243&r2=238244&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/opt/opt.cpp (original)<br>
+++ llvm/trunk/tools/opt/opt.cpp Tue May 26 15:17:20 2015<br>
@@ -396,11 +396,9 @@ int main(int argc, char **argv) {<br>
      std::unique_ptr<TargetMachine> TM(Machine);<br>
  -  // Override function attributes based on CPUStr, FeaturesStr, and Options.<br>
-  // Pass AlwaysRecordAttrs=false as we want to override an attribute only when<br>
-  // the corresponding cl::opt has been provided on opt's command line.<br>
-  setFunctionAttributes(CPUStr, FeaturesStr, Options, *M,<br>
-                        /* AlwaysRecordAttrs */ false);<br>
+  // Override function attributes based on CPUStr, FeaturesStr, and command line<br>
+  // flags.<br>
+  setFunctionAttributes(CPUStr, FeaturesStr, *M);<br>
      // If the output is set to be emitted to standard out, and standard out is a<br>
    // console, print out a warning message and refuse to do it.  We don't<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div></div>