about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorAugie Fackler <augie@google.com>2021-09-08 10:47:41 -0400
committerAugie Fackler <augie@google.com>2021-09-08 10:47:41 -0400
commit4d045406d1ee4c011e476fbeae81976c8012e886 (patch)
tree6fc55ce58639ab4402a5cd00ffa3b2df532547ec /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent484b79b950b1077d1bbfe6c4edf3bfe070d820b4 (diff)
downloadrust-4d045406d1ee4c011e476fbeae81976c8012e886.tar.gz
rust-4d045406d1ee4c011e476fbeae81976c8012e886.zip
RustWrapper: remove some uses of AttrBuilder
Turns out we can also use Attribute::get*() methods here, and avoid the
AttrBuilder and an extra helper method here.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp25
1 files changed, 6 insertions, 19 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index 3a7af73c87d..9850f395a0f 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -225,41 +225,28 @@ extern "C" void LLVMRustAddCallSiteAttrString(LLVMValueRef Instr, unsigned Index
   AddAttribute(Call, Index, Attr);
 }
 
-static inline void AddCallAttributes(CallBase *Call, unsigned Index, const AttrBuilder& B) {
-  AttributeList Attrs = Call->getAttributes();
-#if LLVM_VERSION_LT(14, 0)
-  Attrs = Attrs.addAttributes(Call->getContext(), Index, B);
-#else
-  Attrs = Attrs.addAttributesAtIndex(Call->getContext(), Index, B);
-#endif
-  Call->setAttributes(Attrs);
-}
-
 extern "C" void LLVMRustAddAlignmentCallSiteAttr(LLVMValueRef Instr,
                                                  unsigned Index,
                                                  uint32_t Bytes) {
   CallBase *Call = unwrap<CallBase>(Instr);
-  AttrBuilder B;
-  B.addAlignmentAttr(Bytes);
-  AddCallAttributes(Call, Index, B);
+  Attribute Attr = Attribute::getWithAlignment(Call->getContext(), Align(Bytes));
+  AddAttribute(Call, Index, Attr);
 }
 
 extern "C" void LLVMRustAddDereferenceableCallSiteAttr(LLVMValueRef Instr,
                                                        unsigned Index,
                                                        uint64_t Bytes) {
   CallBase *Call = unwrap<CallBase>(Instr);
-  AttrBuilder B;
-  B.addDereferenceableAttr(Bytes);
-  AddCallAttributes(Call, Index, B);
+  Attribute Attr = Attribute::getWithDereferenceableBytes(Call->getContext(), Bytes);
+  AddAttribute(Call, Index, Attr);
 }
 
 extern "C" void LLVMRustAddDereferenceableOrNullCallSiteAttr(LLVMValueRef Instr,
                                                              unsigned Index,
                                                              uint64_t Bytes) {
   CallBase *Call = unwrap<CallBase>(Instr);
-  AttrBuilder B;
-  B.addDereferenceableOrNullAttr(Bytes);
-  AddCallAttributes(Call, Index, B);
+  Attribute Attr = Attribute::getWithDereferenceableOrNullBytes(Call->getContext(), Bytes);
+  AddAttribute(Call, Index, Attr);
 }
 
 extern "C" void LLVMRustAddByValCallSiteAttr(LLVMValueRef Instr, unsigned Index,