llvm.org GIT mirror llvm / 1b00507
Use the attribute builder to add attributes to call/invoke instruction. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165562 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 7 years ago
2 changed file(s) with 51 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
12791279
12801280 /// @brief Return true if the call should not be inlined.
12811281 bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
1282 void setIsNoInline(bool Value = true) {
1283 if (Value) addAttribute(~0, Attribute::NoInline);
1284 else removeAttribute(~0, Attribute::NoInline);
1282 void setIsNoInline() {
1283 Attributes::Builder B;
1284 B.addAttribute(Attributes::NoInline);
1285 addAttribute(~0, Attributes::get(B));
12851286 }
12861287
12871288 /// @brief Return true if the call can return twice
12881289 bool canReturnTwice() const {
12891290 return hasFnAttr(Attributes::ReturnsTwice);
12901291 }
1291 void setCanReturnTwice(bool Value = true) {
1292 if (Value) addAttribute(~0, Attribute::ReturnsTwice);
1293 else removeAttribute(~0, Attribute::ReturnsTwice);
1292 void setCanReturnTwice() {
1293 Attributes::Builder B;
1294 B.addAttribute(Attributes::ReturnsTwice);
1295 addAttribute(~0U, Attributes::get(B));
12941296 }
12951297
12961298 /// @brief Determine if the call does not access memory.
12971299 bool doesNotAccessMemory() const {
12981300 return hasFnAttr(Attributes::ReadNone);
12991301 }
1300 void setDoesNotAccessMemory(bool NotAccessMemory = true) {
1301 if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
1302 else removeAttribute(~0, Attribute::ReadNone);
1302 void setDoesNotAccessMemory() {
1303 Attributes::Builder B;
1304 B.addAttribute(Attributes::ReadNone);
1305 addAttribute(~0U, Attributes::get(B));
13031306 }
13041307
13051308 /// @brief Determine if the call does not access or only reads memory.
13061309 bool onlyReadsMemory() const {
13071310 return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
13081311 }
1309 void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
1310 if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
1311 else removeAttribute(~0, Attribute::ReadOnly | Attribute::ReadNone);
1312 void setOnlyReadsMemory() {
1313 Attributes::Builder B;
1314 B.addAttribute(Attributes::ReadOnly);
1315 addAttribute(~0, Attributes::get(B));
13121316 }
13131317
13141318 /// @brief Determine if the call cannot return.
13151319 bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
1316 void setDoesNotReturn(bool DoesNotReturn = true) {
1317 if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
1318 else removeAttribute(~0, Attribute::NoReturn);
1320 void setDoesNotReturn() {
1321 Attributes::Builder B;
1322 B.addAttribute(Attributes::NoReturn);
1323 addAttribute(~0, Attributes::get(B));
13191324 }
13201325
13211326 /// @brief Determine if the call cannot unwind.
13221327 bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
13231328 void setDoesNotThrow(bool DoesNotThrow = true) {
1324 if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
1325 else removeAttribute(~0, Attribute::NoUnwind);
1329 Attributes::Builder B;
1330 B.addAttribute(Attributes::NoUnwind);
1331 addAttribute(~0, Attributes::get(B));
13261332 }
13271333
13281334 /// @brief Determine if the call returns a structure through first
30423048
30433049 /// @brief Return true if the call should not be inlined.
30443050 bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
3045 void setIsNoInline(bool Value = true) {
3046 if (Value) addAttribute(~0, Attribute::NoInline);
3047 else removeAttribute(~0, Attribute::NoInline);
3051 void setIsNoInline() {
3052 Attributes::Builder B;
3053 B.addAttribute(Attributes::NoInline);
3054 addAttribute(~0, Attributes::get(B));
30483055 }
30493056
30503057 /// @brief Determine if the call does not access memory.
30513058 bool doesNotAccessMemory() const {
30523059 return hasFnAttr(Attributes::ReadNone);
30533060 }
3054 void setDoesNotAccessMemory(bool NotAccessMemory = true) {
3055 if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
3056 else removeAttribute(~0, Attribute::ReadNone);
3061 void setDoesNotAccessMemory() {
3062 Attributes::Builder B;
3063 B.addAttribute(Attributes::ReadNone);
3064 addAttribute(~0, Attributes::get(B));
30573065 }
30583066
30593067 /// @brief Determine if the call does not access or only reads memory.
30603068 bool onlyReadsMemory() const {
30613069 return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
30623070 }
3063 void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
3064 if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
3065 else removeAttribute(~0, Attribute::ReadOnly | Attribute::ReadNone);
3071 void setOnlyReadsMemory() {
3072 Attributes::Builder B;
3073 B.addAttribute(Attributes::ReadOnly);
3074 addAttribute(~0, Attributes::get(B));
30663075 }
30673076
30683077 /// @brief Determine if the call cannot return.
30693078 bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
3070 void setDoesNotReturn(bool DoesNotReturn = true) {
3071 if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
3072 else removeAttribute(~0, Attribute::NoReturn);
3079 void setDoesNotReturn() {
3080 Attributes::Builder B;
3081 B.addAttribute(Attributes::NoReturn);
3082 addAttribute(~0, Attributes::get(B));
30733083 }
30743084
30753085 /// @brief Determine if the call cannot unwind.
30763086 bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
3077 void setDoesNotThrow(bool DoesNotThrow = true) {
3078 if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
3079 else removeAttribute(~0, Attribute::NoUnwind);
3087 void setDoesNotThrow() {
3088 Attributes::Builder B;
3089 B.addAttribute(Attributes::NoUnwind);
3090 addAttribute(~0, Attributes::get(B));
30803091 }
30813092
30823093 /// @brief Determine if the call returns a structure through first
210210 bool doesNotAccessMemory() const {
211211 CALLSITE_DELEGATE_GETTER(doesNotAccessMemory());
212212 }
213 void setDoesNotAccessMemory(bool doesNotAccessMemory = true) {
214 CALLSITE_DELEGATE_SETTER(setDoesNotAccessMemory(doesNotAccessMemory));
213 void setDoesNotAccessMemory() {
214 CALLSITE_DELEGATE_SETTER(setDoesNotAccessMemory());
215215 }
216216
217217 /// @brief Determine if the call does not access or only reads memory.
218218 bool onlyReadsMemory() const {
219219 CALLSITE_DELEGATE_GETTER(onlyReadsMemory());
220220 }
221 void setOnlyReadsMemory(bool onlyReadsMemory = true) {
222 CALLSITE_DELEGATE_SETTER(setOnlyReadsMemory(onlyReadsMemory));
221 void setOnlyReadsMemory() {
222 CALLSITE_DELEGATE_SETTER(setOnlyReadsMemory());
223223 }
224224
225225 /// @brief Determine if the call cannot return.
226226 bool doesNotReturn() const {
227227 CALLSITE_DELEGATE_GETTER(doesNotReturn());
228228 }
229 void setDoesNotReturn(bool doesNotReturn = true) {
230 CALLSITE_DELEGATE_SETTER(setDoesNotReturn(doesNotReturn));
229 void setDoesNotReturn() {
230 CALLSITE_DELEGATE_SETTER(setDoesNotReturn());
231231 }
232232
233233 /// @brief Determine if the call cannot unwind.
234234 bool doesNotThrow() const {
235235 CALLSITE_DELEGATE_GETTER(doesNotThrow());
236236 }
237 void setDoesNotThrow(bool doesNotThrow = true) {
238 CALLSITE_DELEGATE_SETTER(setDoesNotThrow(doesNotThrow));
237 void setDoesNotThrow() {
238 CALLSITE_DELEGATE_SETTER(setDoesNotThrow());
239239 }
240240
241241 #undef CALLSITE_DELEGATE_GETTER