llvm.org GIT mirror llvm / f5e6d70
Have 'addFnAttr' take the attribute enum value. Then have it build the attribute object and add it appropriately. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165595 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 8 years ago
4 changed file(s) with 19 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
175175
176176 /// addFnAttr - Add function attributes to this function.
177177 ///
178 void addFnAttr(Attributes N) {
178 void addFnAttr(Attributes::AttrVal N) {
179179 // Function Attributes are stored at ~0 index
180 addAttribute(~0U, N);
180 Attributes::Builder B;
181 B.addAttribute(N);
182 addAttribute(~0U, Attributes::get(B));
181183 }
182184
183185 /// removeFnAttr - Remove function attributes from this function.
220222 bool doesNotAccessMemory() const {
221223 return getFnAttributes().hasAttribute(Attributes::ReadNone);
222224 }
223 void setDoesNotAccessMemory(bool DoesNotAccessMemory = true) {
224 if (DoesNotAccessMemory) addFnAttr(Attribute::ReadNone);
225 else removeFnAttr(Attribute::ReadNone);
225 void setDoesNotAccessMemory() {
226 addFnAttr(Attributes::ReadNone);
226227 }
227228
228229 /// @brief Determine if the function does not access or only reads memory.
230231 return doesNotAccessMemory() ||
231232 getFnAttributes().hasAttribute(Attributes::ReadOnly);
232233 }
233 void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
234 if (OnlyReadsMemory) addFnAttr(Attribute::ReadOnly);
235 else removeFnAttr(Attribute::ReadOnly | Attribute::ReadNone);
234 void setOnlyReadsMemory() {
235 addFnAttr(Attributes::ReadOnly);
236236 }
237237
238238 /// @brief Determine if the function cannot return.
239239 bool doesNotReturn() const {
240240 return getFnAttributes().hasAttribute(Attributes::NoReturn);
241241 }
242 void setDoesNotReturn(bool DoesNotReturn = true) {
243 if (DoesNotReturn) addFnAttr(Attribute::NoReturn);
244 else removeFnAttr(Attribute::NoReturn);
242 void setDoesNotReturn() {
243 addFnAttr(Attributes::NoReturn);
245244 }
246245
247246 /// @brief Determine if the function cannot unwind.
248247 bool doesNotThrow() const {
249248 return getFnAttributes().hasAttribute(Attributes::NoUnwind);
250249 }
251 void setDoesNotThrow(bool DoesNotThrow = true) {
252 if (DoesNotThrow) addFnAttr(Attribute::NoUnwind);
253 else removeFnAttr(Attribute::NoUnwind);
250 void setDoesNotThrow() {
251 addFnAttr(Attributes::NoUnwind);
254252 }
255253
256254 /// @brief True if the ABI mandates (or the user requested) that this
258256 bool hasUWTable() const {
259257 return getFnAttributes().hasAttribute(Attributes::UWTable);
260258 }
261 void setHasUWTable(bool HasUWTable = true) {
262 if (HasUWTable)
263 addFnAttr(Attribute::UWTable);
264 else
265 removeFnAttr(Attribute::UWTable);
259 void setHasUWTable() {
260 addFnAttr(Attributes::UWTable);
266261 }
267262
268263 /// @brief True if this function needs an unwind table.
9393 // If the inlined function had a higher stack protection level than the
9494 // calling function, then bump up the caller's stack protection level.
9595 if (Callee->getFnAttributes().hasAttribute(Attributes::StackProtectReq))
96 Caller->addFnAttr(Attribute::StackProtectReq);
96 Caller->addFnAttr(Attributes::StackProtectReq);
9797 else if (Callee->getFnAttributes().hasAttribute(Attributes::StackProtect) &&
9898 !Caller->getFnAttributes().hasAttribute(Attributes::StackProtectReq))
99 Caller->addFnAttr(Attribute::StackProtect);
99 Caller->addFnAttr(Attributes::StackProtect);
100100
101101 // Look at all of the allocas that we inlined through this call site. If we
102102 // have already inlined other allocas through other calls into this function,
681681 "__llvm_gcov_init", M);
682682 F->setUnnamedAddr(true);
683683 F->setLinkage(GlobalValue::InternalLinkage);
684 Attributes::Builder B;
685 B.addAttribute(Attributes::NoInline);
686 F->addFnAttr(Attributes::get(B));
684 F->addFnAttr(Attributes::NoInline);
687685
688686 BB = BasicBlock::Create(*Ctx, "entry", F);
689687 Builder.SetInsertPoint(BB);
702700 cast(GCOVProfiler::getIncrementIndirectCounterFunc());
703701 Fn->setUnnamedAddr(true);
704702 Fn->setLinkage(GlobalValue::InternalLinkage);
705 Attributes::Builder B;
706 B.addAttribute(Attributes::NoInline);
707 Fn->addFnAttr(Attributes::get(B));
703 Fn->addFnAttr(Attributes::NoInline);
708704
709705 Type *Int32Ty = Type::getInt32Ty(*Ctx);
710706 Type *Int64Ty = Type::getInt64Ty(*Ctx);
345345 header->getName(), M);
346346 // If the old function is no-throw, so is the new one.
347347 if (oldFunction->doesNotThrow())
348 newFunction->setDoesNotThrow(true);
348 newFunction->setDoesNotThrow();
349349
350350 newFunction->getBasicBlockList().push_back(newRootNode);
351351