[pkg-d-commits] [ldc] 29/74: fix buildinng against LLVM master (#2111)

Matthias Klumpp mak at moszumanska.debian.org
Thu Jul 13 20:54:16 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.3.0-beta2
in repository ldc.

commit ae7f1a7f2c790816f5085e697f912f0341997778
Author: Rainer Schuetze <r.sagitario at gmx.de>
Date:   Tue May 16 20:43:29 2017 +0200

    fix buildinng against LLVM master (#2111)
---
 driver/toobj.cpp                    |  4 +++-
 gen/attributes.cpp                  |  4 ++++
 gen/cl_helpers.h                    |  4 +++-
 gen/inlineir.cpp                    |  7 -------
 gen/passes/GarbageCollect2Stack.cpp | 12 +++++++++++-
 gen/tocall.cpp                      |  7 ++++++-
 gen/trycatchfinally.cpp             | 10 +++++++---
 gen/uda.cpp                         |  5 +++++
 8 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/driver/toobj.cpp b/driver/toobj.cpp
index d8f6035..63f4ab3 100644
--- a/driver/toobj.cpp
+++ b/driver/toobj.cpp
@@ -225,7 +225,9 @@ class AssemblyAnnotator : public AssemblyAnnotationWriter {
     if (MDNode *N = FindSubprogram(F, Finder))
 #endif
     {
-#if LDC_LLVM_VER >= 307
+#if LDC_LLVM_VER >= 500
+      return N->getName();
+#elif LDC_LLVM_VER >= 307
       return N->getDisplayName();
 #else
       llvm::DISubprogram sub(N);
diff --git a/gen/attributes.cpp b/gen/attributes.cpp
index 3a8a9f8..0bdd4c7 100644
--- a/gen/attributes.cpp
+++ b/gen/attributes.cpp
@@ -79,8 +79,12 @@ AttrSet::extractFunctionAndReturnAttributes(const llvm::Function *function) {
 
 AttrSet &AttrSet::add(unsigned index, const AttrBuilder &builder) {
   if (builder.hasAttributes()) {
+#if LDC_LLVM_VER >= 500
+    set = set.addAttributes(gIR->context(), index, builder);
+#else
     auto as = LLAttributeSet::get(gIR->context(), index, builder);
     set = set.addAttributes(gIR->context(), index, as);
+#endif
   }
   return *this;
 }
diff --git a/gen/cl_helpers.h b/gen/cl_helpers.h
index c449222..4069b86 100644
--- a/gen/cl_helpers.h
+++ b/gen/cl_helpers.h
@@ -19,7 +19,9 @@
 #include "llvm/Support/Compiler.h"
 #include "gen/llvmcompat.h"
 
-#if LDC_LLVM_VER < 306
+#if LDC_LLVM_VER >= 500
+#define LLVM_END_WITH_NULL
+#elif LDC_LLVM_VER < 306
 #define LLVM_END_WITH_NULL END_WITH_NULL
 #endif
 
diff --git a/gen/inlineir.cpp b/gen/inlineir.cpp
index 806c311..bb87e1b 100644
--- a/gen/inlineir.cpp
+++ b/gen/inlineir.cpp
@@ -39,14 +39,7 @@ struct TempDisableDiscardValueNames {
 void copyFnAttributes(llvm::Function *wannabe, llvm::Function *idol) {
   auto attrSet = idol->getAttributes();
   auto fnAttrSet = attrSet.getFnAttributes();
-#if LDC_LLVM_VER >= 500
-  wannabe->addAttributes(LLAttributeSet::FunctionIndex,
-                         LLAttributeSet::get(gIR->context(),
-                                             LLAttributeSet::FunctionIndex,
-                                             fnAttrSet));
-#else
   wannabe->addAttributes(LLAttributeSet::FunctionIndex, fnAttrSet);
-#endif
 }
 } // anonymous namespace
 
diff --git a/gen/passes/GarbageCollect2Stack.cpp b/gen/passes/GarbageCollect2Stack.cpp
index c4ec02f..317af9f 100644
--- a/gen/passes/GarbageCollect2Stack.cpp
+++ b/gen/passes/GarbageCollect2Stack.cpp
@@ -39,6 +39,9 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
+#if LDC_LLVM_VER >= 500
+#include "llvm/Support/KnownBits.h"
+#endif
 
 #include <algorithm>
 
@@ -146,16 +149,23 @@ static bool isKnownLessThan(Value *Val, uint64_t Limit, const Analysis &A) {
   if (Bits > BitsLimit) {
     APInt Mask = APInt::getLowBitsSet(Bits, BitsLimit);
     Mask.flipAllBits();
+#if LDC_LLVM_VER >= 500
+    KnownBits Known(Bits);
+    computeKnownBits(Val, Known, A.DL);
+    if ((Known.Zero & Mask) != Mask) {
+      return false;
+    }
+#else
     APInt KnownZero(Bits, 0), KnownOne(Bits, 0);
 #if LDC_LLVM_VER >= 307
     computeKnownBits(Val, KnownZero, KnownOne, A.DL);
 #else
     computeKnownBits(Val, KnownZero, KnownOne, &A.DL);
 #endif
-
     if ((KnownZero & Mask) != Mask) {
       return false;
     }
+#endif
   }
 
   return true;
diff --git a/gen/tocall.cpp b/gen/tocall.cpp
index 80e8d11..579445b 100644
--- a/gen/tocall.cpp
+++ b/gen/tocall.cpp
@@ -994,9 +994,14 @@ DValue *DtoCallFunctionImpl(Loc &loc, Type *resulttype, DValue *fnval,
     call.setCallingConv(callconv);
   }
   // merge in function attributes set in callOrInvoke
+#if LDC_LLVM_VER >= 500
+  attrlist = attrlist.addAttributes(
+      gIR->context(), LLAttributeSet::FunctionIndex,
+      llvm::AttrBuilder(call.getAttributes(), LLAttributeSet::FunctionIndex));
+#else
   attrlist = attrlist.addAttributes(
       gIR->context(), LLAttributeSet::FunctionIndex, call.getAttributes());
-
+#endif
   call.setAttributes(attrlist);
 
   // Special case for struct constructor calls: For temporaries, using the
diff --git a/gen/trycatchfinally.cpp b/gen/trycatchfinally.cpp
index 17a132c..1ce5a85 100644
--- a/gen/trycatchfinally.cpp
+++ b/gen/trycatchfinally.cpp
@@ -620,10 +620,14 @@ TryCatchFinallyScopes::getLandingPadRef(CleanupCursor scope) {
 }
 
 namespace {
-llvm::LandingPadInst *createLandingPadInst(IRState &irs) {
-  LLType *retType =
+  llvm::LandingPadInst *createLandingPadInst(IRState &irs) {
+    LLType *retType =
       LLStructType::get(LLType::getInt8PtrTy(irs.context()),
-                        LLType::getInt32Ty(irs.context()), nullptr);
+        LLType::getInt32Ty(irs.context())
+#if LDC_LLVM_VER < 500
+        , nullptr
+#endif
+      );
 #if LDC_LLVM_VER >= 307
   if (!irs.func()->hasLLVMPersonalityFn()) {
     irs.func()->setLLVMPersonalityFn(
diff --git a/gen/uda.cpp b/gen/uda.cpp
index fe97757..6ec90c6 100644
--- a/gen/uda.cpp
+++ b/gen/uda.cpp
@@ -183,11 +183,16 @@ void applyAttrAllocSize(StructLiteralExp *sle, IrFunction *irFunc) {
   } else {
     builder.addAllocSizeAttr(llvmSizeIdx, llvm::Optional<unsigned>());
   }
+
+#if LDC_LLVM_VER >= 500
+  func->addAttributes(LLAttributeSet::FunctionIndex, builder);
+#else
   func->addAttributes(LLAttributeSet::FunctionIndex,
                       LLAttributeSet::get(func->getContext(),
                                           LLAttributeSet::FunctionIndex,
                                           builder));
 #endif
+#endif
 }
 
 // @llvmAttr("key", "value")

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list