20 #define DEBUG_TYPE "forceattrs" 24 cl::desc(
"Add an attribute to a function. This should be a " 25 "pair of 'function-name:attribute-name', for " 26 "example -force-attribute=foo:noinline. This " 27 "option can be specified multiple times."));
31 .Case(
"alwaysinline", Attribute::AlwaysInline)
32 .
Case(
"builtin", Attribute::Builtin)
35 .
Case(
"inlinehint", Attribute::InlineHint)
37 .
Case(
"minsize", Attribute::MinSize)
38 .
Case(
"naked", Attribute::Naked)
39 .
Case(
"nobuiltin", Attribute::NoBuiltin)
40 .
Case(
"noduplicate", Attribute::NoDuplicate)
41 .
Case(
"noimplicitfloat", Attribute::NoImplicitFloat)
42 .
Case(
"noinline", Attribute::NoInline)
43 .
Case(
"nonlazybind", Attribute::NonLazyBind)
44 .
Case(
"noredzone", Attribute::NoRedZone)
45 .
Case(
"noreturn", Attribute::NoReturn)
46 .
Case(
"nocf_check", Attribute::NoCfCheck)
47 .
Case(
"norecurse", Attribute::NoRecurse)
48 .
Case(
"nounwind", Attribute::NoUnwind)
49 .
Case(
"optforfuzzing", Attribute::OptForFuzzing)
50 .
Case(
"optnone", Attribute::OptimizeNone)
51 .
Case(
"optsize", Attribute::OptimizeForSize)
52 .
Case(
"readnone", Attribute::ReadNone)
53 .
Case(
"readonly", Attribute::ReadOnly)
54 .
Case(
"argmemonly", Attribute::ArgMemOnly)
55 .
Case(
"returns_twice", Attribute::ReturnsTwice)
56 .
Case(
"safestack", Attribute::SafeStack)
57 .
Case(
"shadowcallstack", Attribute::ShadowCallStack)
58 .
Case(
"sanitize_address", Attribute::SanitizeAddress)
59 .
Case(
"sanitize_hwaddress", Attribute::SanitizeHWAddress)
60 .
Case(
"sanitize_memory", Attribute::SanitizeMemory)
61 .
Case(
"sanitize_thread", Attribute::SanitizeThread)
62 .
Case(
"sanitize_memtag", Attribute::SanitizeMemTag)
63 .
Case(
"speculative_load_hardening", Attribute::SpeculativeLoadHardening)
64 .
Case(
"ssp", Attribute::StackProtect)
65 .
Case(
"sspreq", Attribute::StackProtectReq)
66 .
Case(
"sspstrong", Attribute::StackProtectStrong)
67 .
Case(
"strictfp", Attribute::StrictFP)
68 .
Case(
"uwtable", Attribute::UWTable)
82 <<
" unknown or not handled!\n");
104 struct ForceFunctionAttrsLegacyPass :
public ModulePass {
106 ForceFunctionAttrsLegacyPass() :
ModulePass(ID) {
111 bool runOnModule(
Module &M)
override {
126 "Force set function attributes",
false,
false)
129 return new ForceFunctionAttrsLegacyPass();
Super simple passes to force specific function attrs from the commandline into the IR for debugging p...
Pass interface - Implemented by all 'passes'.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
StringSwitch & Case(StringLiteral S, T Value)
static void addForcedAttributes(Function &F)
If F has any forced attributes given on the command line, add them.
LLVM_NODISCARD R Default(T Value)
No attributes have been set.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
A switch()-like statement whose cases are string literals.
A set of analyses that are preserved following a run of a transformation pass.
iterator_range< iterator > functions()
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static Attribute::AttrKind parseAttrKind(StringRef Kind)
static cl::list< std::string > ForceAttributes("force-attribute", cl::Hidden, cl::desc("Add an attribute to a function. This should be a " "pair of 'function-name:attribute-name', for " "example -force-attribute=foo:noinline. This " "option can be specified multiple times."))
Module.h This file contains the declarations for the Module class.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
INITIALIZE_PASS(ForceFunctionAttrsLegacyPass, "forceattrs", "Force set function attributes", false, false) Pass *llvm
StringRef getName() const
Return a constant reference to the value's name.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
void initializeForceFunctionAttrsLegacyPassPass(PassRegistry &)
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
StringRef - Represent a constant reference to a string, i.e.
A container for analyses that lazily runs them and caches their results.
Pass * createForceFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to force function attrs.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...