llvm.org GIT mirror llvm / 6f49135
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238244 91177308-0d34-0410-b5e6-96231b3b80d8 Akira Hatanaka 5 years ago
7 changed file(s) with 42 addition(s) and 62 deletion(s). Raw diff Collapse all Expand all
228228 static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
229229 TargetOptions Options;
230230 Options.LessPreciseFPMADOption = EnableFPMAD;
231 Options.NoFramePointerElim = DisableFPElim;
232 Options.NoFramePointerElimOverride = DisableFPElim.getNumOccurrences() > 0;
233231 Options.AllowFPOpFusion = FuseFPOps;
234232 Options.UnsafeFPMath = EnableUnsafeFPMath;
235233 Options.NoInfsFPMath = EnableNoInfsFPMath;
287285 return Features.getString();
288286 }
289287
288 /// \brief Set function attributes of functions in Module M based on CPU,
289 /// Features, and command line flags.
290 static inline void setFunctionAttributes(StringRef CPU, StringRef Features,
291 Module &M) {
292 for (auto &F : M) {
293 auto &Ctx = F.getContext();
294 AttributeSet Attrs = F.getAttributes(), NewAttrs;
295
296 if (!CPU.empty())
297 NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
298 "target-cpu", CPU);
299
300 if (!Features.empty())
301 NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
302 "target-features", Features);
303
304 if (DisableFPElim.getNumOccurrences() > 0)
305 NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
306 "no-frame-pointer-elim",
307 DisableFPElim ? "true" : "false");
308
309 // Let NewAttrs override Attrs.
310 NewAttrs = Attrs.addAttributes(Ctx, AttributeSet::FunctionIndex, NewAttrs);
311 F.setAttributes(NewAttrs);
312 }
313 }
314
290315 #endif
5959 class TargetOptions {
6060 public:
6161 TargetOptions()
62 : PrintMachineCode(false), NoFramePointerElim(false),
63 NoFramePointerElimOverride(false),
62 : PrintMachineCode(false),
6463 LessPreciseFPMADOption(false), UnsafeFPMath(false),
6564 NoInfsFPMath(false), NoNaNsFPMath(false),
6665 HonorSignDependentRoundingFPMathOption(false),
7978 /// option is specified on the command line, and should enable debugging
8079 /// output from the code generator.
8180 unsigned PrintMachineCode : 1;
82
83 /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is
84 /// specified on the command line. If the target supports the frame pointer
85 /// elimination optimization, this option should disable it.
86 unsigned NoFramePointerElim : 1;
87
88 /// This flag is true when "disable-fp-elim" appeared on the command line.
89 unsigned NoFramePointerElimOverride : 1;
9081
9182 /// DisableFramePointerElim - This returns true if frame pointer elimination
9283 /// optimization should be disabled for the given machine function.
225216 /// Machine level options.
226217 MCTargetOptions MCOptions;
227218 };
228
229 /// \brief Set function attributes of functions in Module M based on CPU,
230 /// Features, and Options.
231 /// If AlwaysRecordAttrs is true, it will always record the function attributes
232 /// in Options regardless of whether those attributes were specified on the
233 /// tool's command line.
234 void setFunctionAttributes(StringRef CPU, StringRef Features,
235 const TargetOptions &Options, Module &M,
236 bool AlwaysRecordAttrs);
237219
238220 // Comparison operators:
239221
5353 StringRef TargetOptions::getTrapFunctionName() const {
5454 return TrapFuncName;
5555 }
56
57
58 void llvm::setFunctionAttributes(StringRef CPU, StringRef Features,
59 const TargetOptions &Options, Module &M,
60 bool AlwaysRecordAttrs) {
61 for (auto &F : M) {
62 auto &Ctx = F.getContext();
63 AttributeSet Attrs = F.getAttributes(), NewAttrs;
64
65 if (!CPU.empty())
66 NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
67 "target-cpu", CPU);
68
69 if (!Features.empty())
70 NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex,
71 "target-features", Features);
72
73 if (Options.NoFramePointerElimOverride || AlwaysRecordAttrs)
74 NewAttrs = NewAttrs.addAttribute(
75 Ctx, AttributeSet::FunctionIndex, "no-frame-pointer-elim",
76 Options.NoFramePointerElim ? "true" : "false");
77
78 // Let NewAttrs override Attrs.
79 NewAttrs = Attrs.addAttributes(Ctx, AttributeSet::FunctionIndex, NewAttrs);
80 F.setAttributes(NewAttrs);
81 }
82 }
176176 memcpy(&options, PassedOptions, SizeOfPassedOptions);
177177
178178 TargetOptions targetOptions;
179 targetOptions.NoFramePointerElim = options.NoFramePointerElim;
180179 targetOptions.EnableFastISel = options.EnableFastISel;
181180 std::unique_ptr Mod(unwrap(M));
182181
183182 if (Mod)
184183 // Set function attribute "no-frame-pointer-elim" based on
185184 // NoFramePointerElim.
186 setFunctionAttributes(/* CPU */ "", /* Features */ "", targetOptions, *Mod,
187 /* AlwaysRecordAttrs */ true);
185 for (auto &F : *Mod) {
186 auto Attrs = F.getAttributes();
187 auto Value = options.NoFramePointerElim ? "true" : "false";
188 Attrs = Attrs.addAttribute(F.getContext(), AttributeSet::FunctionIndex,
189 "no-frame-pointer-elim", Value);
190 F.setAttributes(Attrs);
191 }
188192
189193 std::string Error;
190194 EngineBuilder builder(std::move(Mod));
2121 type = Library
2222 name = ExecutionEngine
2323 parent = Libraries
24 required_libraries = CodeGen Core MC Object RuntimeDyld Support
24 required_libraries = Core MC Object RuntimeDyld Support
303303 if (const DataLayout *DL = Target->getDataLayout())
304304 M->setDataLayout(*DL);
305305
306 // Override function attributes based on CPUStr, FeaturesStr, and Options.
307 // Pass AlwaysRecordAttrs=false as we want to override an attribute only when
308 // the corresponding cl::opt has been provided on llc's command line.
309 setFunctionAttributes(CPUStr, FeaturesStr, Options, *M,
310 /* AlwaysRecordAttrs */ false);
306 // Override function attributes based on CPUStr, FeaturesStr, and command line
307 // flags.
308 setFunctionAttributes(CPUStr, FeaturesStr, *M);
311309
312310 if (RelaxAll.getNumOccurrences() > 0 &&
313311 FileType != TargetMachine::CGFT_ObjectFile)
395395
396396 std::unique_ptr TM(Machine);
397397
398 // Override function attributes based on CPUStr, FeaturesStr, and Options.
399 // Pass AlwaysRecordAttrs=false as we want to override an attribute only when
400 // the corresponding cl::opt has been provided on opt's command line.
401 setFunctionAttributes(CPUStr, FeaturesStr, Options, *M,
402 /* AlwaysRecordAttrs */ false);
398 // Override function attributes based on CPUStr, FeaturesStr, and command line
399 // flags.
400 setFunctionAttributes(CPUStr, FeaturesStr, *M);
403401
404402 // If the output is set to be emitted to standard out, and standard out is a
405403 // console, print out a warning message and refuse to do it. We don't