[llvm] r238244 - Remove NoFramePointerElim and NoFramePointerElimOverride from TargetOptions and
Philip Reames
listmail at philipreames.com
Tue May 26 14:15:38 PDT 2015
Akira,
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?
Philip
On 05/26/2015 01:17 PM, Akira Hatanaka wrote:
> Author: ahatanak
> Date: Tue May 26 15:17:20 2015
> New Revision: 238244
>
> URL: http://llvm.org/viewvc/llvm-project?rev=238244&view=rev
> Log:
> Remove NoFramePointerElim and NoFramePointerElimOverride from TargetOptions and
> remove ExecutionEngine's dependence on CodeGen. NFC.
>
> This is a follow-up to r238080.
>
> Differential Revision: http://reviews.llvm.org/D9830
>
> Modified:
> llvm/trunk/include/llvm/CodeGen/CommandFlags.h
> llvm/trunk/include/llvm/Target/TargetOptions.h
> llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp
> llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp
> llvm/trunk/lib/ExecutionEngine/LLVMBuild.txt
> llvm/trunk/tools/llc/llc.cpp
> llvm/trunk/tools/opt/opt.cpp
>
> Modified: llvm/trunk/include/llvm/CodeGen/CommandFlags.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CommandFlags.h?rev=238244&r1=238243&r2=238244&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/CommandFlags.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/CommandFlags.h Tue May 26 15:17:20 2015
> @@ -229,8 +229,6 @@ JTableType("jump-table-type",
> static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
> TargetOptions Options;
> Options.LessPreciseFPMADOption = EnableFPMAD;
> - Options.NoFramePointerElim = DisableFPElim;
> - Options.NoFramePointerElimOverride = DisableFPElim.getNumOccurrences() > 0;
> Options.AllowFPOpFusion = FuseFPOps;
> Options.UnsafeFPMath = EnableUnsafeFPMath;
> Options.NoInfsFPMath = EnableNoInfsFPMath;
> @@ -288,4 +286,31 @@ static inline std::string getFeaturesStr
> return Features.getString();
> }
>
> +/// \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())
> + NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
> + "target-cpu", CPU);
> +
> + if (!Features.empty())
> + 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);
> + }
> +}
> +
> #endif
>
> Modified: llvm/trunk/include/llvm/Target/TargetOptions.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetOptions.h?rev=238244&r1=238243&r2=238244&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/TargetOptions.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetOptions.h Tue May 26 15:17:20 2015
> @@ -60,8 +60,7 @@ namespace llvm {
> class TargetOptions {
> public:
> TargetOptions()
> - : PrintMachineCode(false), NoFramePointerElim(false),
> - NoFramePointerElimOverride(false),
> + : PrintMachineCode(false),
> LessPreciseFPMADOption(false), UnsafeFPMath(false),
> NoInfsFPMath(false), NoNaNsFPMath(false),
> HonorSignDependentRoundingFPMathOption(false),
> @@ -81,14 +80,6 @@ namespace llvm {
> /// output from the code generator.
> unsigned PrintMachineCode : 1;
>
> - /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is
> - /// specified on the command line. If the target supports the frame pointer
> - /// elimination optimization, this option should disable it.
> - unsigned NoFramePointerElim : 1;
> -
> - /// This flag is true when "disable-fp-elim" appeared on the command line.
> - unsigned NoFramePointerElimOverride : 1;
> -
> /// DisableFramePointerElim - This returns true if frame pointer elimination
> /// optimization should be disabled for the given machine function.
> bool DisableFramePointerElim(const MachineFunction &MF) const;
> @@ -227,15 +218,6 @@ namespace llvm {
> MCTargetOptions MCOptions;
> };
>
> -/// \brief Set function attributes of functions in Module M based on CPU,
> -/// Features, and Options.
> -/// If AlwaysRecordAttrs is true, it will always record the function attributes
> -/// in Options regardless of whether those attributes were specified on the
> -/// tool's command line.
> -void setFunctionAttributes(StringRef CPU, StringRef Features,
> - const TargetOptions &Options, Module &M,
> - bool AlwaysRecordAttrs);
> -
> // Comparison operators:
>
>
>
> Modified: llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp?rev=238244&r1=238243&r2=238244&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp (original)
> +++ llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp Tue May 26 15:17:20 2015
> @@ -54,30 +54,3 @@ bool TargetOptions::HonorSignDependentRo
> StringRef TargetOptions::getTrapFunctionName() const {
> return TrapFuncName;
> }
> -
> -
> -void llvm::setFunctionAttributes(StringRef CPU, StringRef Features,
> - const TargetOptions &Options, Module &M,
> - bool AlwaysRecordAttrs) {
> - for (auto &F : M) {
> - auto &Ctx = F.getContext();
> - AttributeSet Attrs = F.getAttributes(), NewAttrs;
> -
> - if (!CPU.empty())
> - NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
> - "target-cpu", CPU);
> -
> - if (!Features.empty())
> - NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
> - "target-features", Features);
> -
> - if (Options.NoFramePointerElimOverride || AlwaysRecordAttrs)
> - NewAttrs = NewAttrs.addAttribute(
> - Ctx, AttributeSet::FunctionIndex, "no-frame-pointer-elim",
> - Options.NoFramePointerElim ? "true" : "false");
> -
> - // Let NewAttrs override Attrs.
> - NewAttrs = Attrs.addAttributes(Ctx, AttributeSet::FunctionIndex, NewAttrs);
> - F.setAttributes(NewAttrs);
> - }
> -}
>
> Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp?rev=238244&r1=238243&r2=238244&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp Tue May 26 15:17:20 2015
> @@ -177,15 +177,19 @@ LLVMBool LLVMCreateMCJITCompilerForModul
> memcpy(&options, PassedOptions, SizeOfPassedOptions);
>
> TargetOptions targetOptions;
> - targetOptions.NoFramePointerElim = options.NoFramePointerElim;
> targetOptions.EnableFastISel = options.EnableFastISel;
> std::unique_ptr<Module> Mod(unwrap(M));
>
> if (Mod)
> // Set function attribute "no-frame-pointer-elim" based on
> // NoFramePointerElim.
> - setFunctionAttributes(/* CPU */ "", /* Features */ "", targetOptions, *Mod,
> - /* AlwaysRecordAttrs */ true);
> + for (auto &F : *Mod) {
> + auto Attrs = F.getAttributes();
> + auto Value = options.NoFramePointerElim ? "true" : "false";
> + Attrs = Attrs.addAttribute(F.getContext(), AttributeSet::FunctionIndex,
> + "no-frame-pointer-elim", Value);
> + F.setAttributes(Attrs);
> + }
>
> std::string Error;
> EngineBuilder builder(std::move(Mod));
>
> Modified: llvm/trunk/lib/ExecutionEngine/LLVMBuild.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/LLVMBuild.txt?rev=238244&r1=238243&r2=238244&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/LLVMBuild.txt (original)
> +++ llvm/trunk/lib/ExecutionEngine/LLVMBuild.txt Tue May 26 15:17:20 2015
> @@ -22,4 +22,4 @@ subdirectories = Interpreter MCJIT Runti
> type = Library
> name = ExecutionEngine
> parent = Libraries
> -required_libraries = CodeGen Core MC Object RuntimeDyld Support
> +required_libraries = Core MC Object RuntimeDyld Support
>
> Modified: llvm/trunk/tools/llc/llc.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=238244&r1=238243&r2=238244&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llc/llc.cpp (original)
> +++ llvm/trunk/tools/llc/llc.cpp Tue May 26 15:17:20 2015
> @@ -304,11 +304,9 @@ static int compileModule(char **argv, LL
> if (const DataLayout *DL = Target->getDataLayout())
> M->setDataLayout(*DL);
>
> - // Override function attributes based on CPUStr, FeaturesStr, and Options.
> - // Pass AlwaysRecordAttrs=false as we want to override an attribute only when
> - // the corresponding cl::opt has been provided on llc's command line.
> - setFunctionAttributes(CPUStr, FeaturesStr, Options, *M,
> - /* AlwaysRecordAttrs */ false);
> + // Override function attributes based on CPUStr, FeaturesStr, and command line
> + // flags.
> + setFunctionAttributes(CPUStr, FeaturesStr, *M);
>
> if (RelaxAll.getNumOccurrences() > 0 &&
> FileType != TargetMachine::CGFT_ObjectFile)
>
> Modified: llvm/trunk/tools/opt/opt.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=238244&r1=238243&r2=238244&view=diff
> ==============================================================================
> --- llvm/trunk/tools/opt/opt.cpp (original)
> +++ llvm/trunk/tools/opt/opt.cpp Tue May 26 15:17:20 2015
> @@ -396,11 +396,9 @@ int main(int argc, char **argv) {
>
> std::unique_ptr<TargetMachine> TM(Machine);
>
> - // Override function attributes based on CPUStr, FeaturesStr, and Options.
> - // Pass AlwaysRecordAttrs=false as we want to override an attribute only when
> - // the corresponding cl::opt has been provided on opt's command line.
> - setFunctionAttributes(CPUStr, FeaturesStr, Options, *M,
> - /* AlwaysRecordAttrs */ false);
> + // Override function attributes based on CPUStr, FeaturesStr, and command line
> + // flags.
> + setFunctionAttributes(CPUStr, FeaturesStr, *M);
>
> // If the output is set to be emitted to standard out, and standard out is a
> // console, print out a warning message and refuse to do it. We don't
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list