[Mlir-commits] [llvm] [mlir] [MLIR] Add llvm (debug) attributes to CAPI (PR #83992)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Mar 6 04:08:40 PST 2024


https://github.com/edg-l updated https://github.com/llvm/llvm-project/pull/83992

>From 05ad34884781b1fb779fefa900be7420566c7637 Mon Sep 17 00:00:00 2001
From: Edgar Luque <git at edgarluque.com>
Date: Mon, 19 Feb 2024 13:43:36 +0100
Subject: [PATCH 1/4] [mlir] Add LLVM attributes to the c api

---
 mlir/include/mlir-c/BuiltinAttributes.h |   4 +
 mlir/include/mlir-c/Dialect/LLVM.h      | 124 +++++++++++++
 mlir/lib/CAPI/Dialect/LLVM.cpp          | 228 ++++++++++++++++++++++++
 mlir/lib/CAPI/IR/BuiltinAttributes.cpp  |   4 +
 mlir/test/CAPI/ir.c                     |   4 +
 mlir/test/CAPI/llvm.c                   | 148 ++++++++++++++-
 6 files changed, 511 insertions(+), 1 deletion(-)

diff --git a/mlir/include/mlir-c/BuiltinAttributes.h b/mlir/include/mlir-c/BuiltinAttributes.h
index 01d1b6008f5e21..231eb83b5e2694 100644
--- a/mlir/include/mlir-c/BuiltinAttributes.h
+++ b/mlir/include/mlir-c/BuiltinAttributes.h
@@ -266,6 +266,10 @@ mlirSymbolRefAttrGetNestedReference(MlirAttribute attr, intptr_t pos);
 /// Returns the typeID of an SymbolRef attribute.
 MLIR_CAPI_EXPORTED MlirTypeID mlirSymbolRefAttrGetTypeID(void);
 
+/// Creates a DisctinctAttr with the referenced attribute.
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirDisctinctAttrCreate(MlirAttribute referencedAttr);
+
 //===----------------------------------------------------------------------===//
 // Flat SymbolRef attribute.
 //===----------------------------------------------------------------------===//
diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h
index ac216b01f364d4..3393ec6f51cc03 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -11,6 +11,7 @@
 #define MLIR_C_DIALECT_LLVM_H
 
 #include "mlir-c/IR.h"
+#include "mlir-c/Support.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -98,6 +99,129 @@ MLIR_CAPI_EXPORTED MlirLogicalResult
 mlirLLVMStructTypeSetBody(MlirType structType, intptr_t nFieldTypes,
                           MlirType const *fieldTypes, bool isPacked);
 
+/// Creates a LLVM CConv attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx,
+                                                      uint64_t cconv);
+
+/// Creates a LLVM Comdat attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx,
+                                                       uint64_t comdat);
+
+/// Creates a LLVM Linkage attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx,
+                                                        uint64_t linkage);
+
+/// Creates a LLVM DINullType attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx);
+
+/// Creates a LLVM DIExpressionElem attribute.
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirLLVMDIExpressionElemAttrGet(MlirContext ctx, unsigned int opcode,
+                                intptr_t nArguments, uint64_t const *arguments);
+
+/// Creates a LLVM DIExpression attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIExpressionAttrGet(
+    MlirContext ctx, intptr_t nOperations, MlirAttribute const *operations);
+
+/// Creates a LLVM DIBasicType attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIBasicTypeAttrGet(
+    MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits,
+    unsigned int encoding);
+
+/// Creates a LLVM DICompositeType attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompositeTypeAttrGet(
+    MlirContext ctx, unsigned int tag, MlirAttribute name, MlirAttribute file,
+    uint32_t line, MlirAttribute scope, MlirAttribute baseType, int64_t flags,
+    uint64_t sizeInBits, uint64_t alignInBits, intptr_t nElements,
+    MlirAttribute const *elements);
+
+/// Creates a LLVM DIDerivedType attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIDerivedTypeAttrGet(
+    MlirContext ctx, unsigned int tag, MlirAttribute name,
+    MlirAttribute baseType, uint64_t sizeInBits, uint32_t alignInBits,
+    uint64_t offsetInBits);
+
+/// Gets the base type from a LLVM DIDerivedType attribute.
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType);
+
+/// Creates a LLVM DIFileAttr attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx,
+                                                       MlirAttribute name,
+                                                       MlirAttribute directory);
+
+/// Creates a LLVM DICompileUnit attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompileUnitAttrGet(
+    MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage,
+    MlirAttribute file, MlirAttribute producer, bool isOptimized,
+    uint64_t emissionKind);
+
+/// Creates a LLVM DIFlags attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx,
+                                                        uint64_t value);
+
+/// Creates a LLVM DILexicalBlock attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDILexicalBlockAttrGet(
+    MlirContext ctx, MlirAttribute scope, MlirAttribute file, unsigned int line,
+    unsigned int column);
+
+/// Creates a LLVM DILexicalBlockFile attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(
+    MlirContext ctx, MlirAttribute scope, MlirAttribute file,
+    unsigned int discriminator);
+
+/// Creates a LLVM DILocalVariableAttr attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDILocalVariableAttrGet(
+    MlirContext ctx, MlirAttribute scope, MlirAttribute name,
+    MlirAttribute diFile, unsigned int line, unsigned int arg,
+    unsigned int alignInBits, MlirAttribute diType);
+
+/// Creates a LLVM DISubprogramAttr attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDISubprogramAttrGet(
+    MlirContext ctx, MlirAttribute id, MlirAttribute compileUnit,
+    MlirAttribute scope, MlirAttribute name, MlirAttribute linkageName,
+    MlirAttribute file, unsigned int line, unsigned int scopeLine,
+    uint64_t subprogramFlags, MlirAttribute type);
+
+/// Gets the scope from this DISubprogramAttr.
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirLLVMDISubprogramAttrGetScope(MlirAttribute diSubprogram);
+
+/// Gets the line from this DISubprogramAttr.
+MLIR_CAPI_EXPORTED unsigned int
+mlirLLVMDISubprogramAttrGetLine(MlirAttribute diSubprogram);
+
+/// Gets the scope line from this DISubprogram.
+MLIR_CAPI_EXPORTED unsigned int
+mlirLLVMDISubprogramAttrGetScopeLine(MlirAttribute diSubprogram);
+
+/// Gets the compile unit from this DISubprogram.
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram);
+
+/// Gets the file from this DISubprogramAttr.
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirLLVMDISubprogramAttrGetFile(MlirAttribute diSubprogram);
+
+/// Gets the type from this DISubprogramAttr.
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirLLVMDISubprogramAttrGetType(MlirAttribute diSubprogram);
+
+/// Creates a LLVM DISubroutineTypeAttr attribute.
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx, unsigned int callingConvention,
+                                intptr_t nTypes, MlirAttribute const *types);
+
+/// Creates a LLVM DIModuleAttr attribute.
+MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIModuleAttrGet(
+    MlirContext ctx, MlirAttribute file, MlirAttribute scope,
+    MlirAttribute name, MlirAttribute configMacros, MlirAttribute includePath,
+    MlirAttribute apinotes, unsigned int line, bool isDecl);
+
+/// Gets the scope of this DIModuleAttr.
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index 642018a814ca12..d540b1a81ee0e4 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -7,9 +7,18 @@
 //===----------------------------------------------------------------------===//
 
 #include "mlir-c/Dialect/LLVM.h"
+#include "mlir-c/IR.h"
+#include "mlir-c/Support.h"
 #include "mlir/CAPI/Registration.h"
+#include "mlir/CAPI/Wrap.h"
+#include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
+#include "mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.h.inc"
 #include "mlir/Dialect/LLVMIR/LLVMTypes.h"
+#include "mlir/IR/Attributes.h"
+#include "mlir/IR/BuiltinAttributes.h"
+#include "mlir/Support/LLVM.h"
+#include <stdint.h>
 
 using namespace mlir;
 using namespace mlir::LLVM;
@@ -110,3 +119,222 @@ MlirLogicalResult mlirLLVMStructTypeSetBody(MlirType structType,
       cast<LLVM::LLVMStructType>(unwrap(structType))
           .setBody(unwrapList(nFieldTypes, fieldTypes, fields), isPacked));
 }
+
+MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx,
+                                              unsigned int opcode,
+                                              intptr_t nArguments,
+                                              uint64_t const *arguments) {
+  auto list = mlir::ArrayRef<uint64_t>(arguments, nArguments);
+  return wrap(DIExpressionElemAttr::get(unwrap(ctx), opcode, list));
+}
+
+MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations,
+                                          MlirAttribute const *operations) {
+  SmallVector<Attribute, 2> attrStorage;
+  attrStorage.reserve(nOperations);
+  mlir::ArrayRef<Attribute> tempList =
+      unwrapList(nOperations, operations, attrStorage);
+
+  SmallVector<DIExpressionElemAttr, 2> diExpressionElemStorage;
+  diExpressionElemStorage.reserve(tempList.size());
+
+  for (auto attr : tempList) {
+    diExpressionElemStorage.push_back(attr.cast<DIExpressionElemAttr>());
+  }
+
+  return wrap(DIExpressionAttr::get(unwrap(ctx), diExpressionElemStorage));
+}
+
+MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx) {
+  return wrap(DINullTypeAttr::get(unwrap(ctx)));
+}
+
+MlirAttribute mlirLLVMDIBasicTypeAttrGet(MlirContext ctx, unsigned int tag,
+                                         MlirAttribute name,
+                                         uint64_t sizeInBits,
+                                         unsigned int encoding) {
+  return wrap(DIBasicTypeAttr::get(
+      unwrap(ctx), tag, cast<StringAttr>(unwrap(name)), sizeInBits, encoding));
+}
+
+MlirAttribute mlirLLVMDICompositeTypeAttrGet(
+    MlirContext ctx, unsigned int tag, MlirAttribute name, MlirAttribute file,
+    uint32_t line, MlirAttribute scope, MlirAttribute baseType, int64_t flags,
+    uint64_t sizeInBits, uint64_t alignInBits, intptr_t nElements,
+    MlirAttribute const *elements) {
+  SmallVector<Attribute, 2> elementsStorage;
+  elementsStorage.reserve(nElements);
+
+  mlir::ArrayRef<Attribute> tempList =
+      unwrapList(nElements, elements, elementsStorage);
+
+  SmallVector<DINodeAttr, 2> diNodesStorage;
+  diNodesStorage.reserve(tempList.size());
+
+  for (auto attr : tempList) {
+    diNodesStorage.push_back(attr.cast<DINodeAttr>());
+  }
+
+  return wrap(DICompositeTypeAttr::get(
+      unwrap(ctx), tag, cast<StringAttr>(unwrap(name)),
+      cast<DIFileAttr>(unwrap(file)), line, cast<DIScopeAttr>(unwrap(scope)),
+      cast<DITypeAttr>(unwrap(baseType)), DIFlags(flags), sizeInBits,
+      alignInBits, diNodesStorage));
+}
+
+MlirAttribute mlirLLVMDIDerivedTypeAttrGet(MlirContext ctx, unsigned int tag,
+                                           MlirAttribute name,
+                                           MlirAttribute baseType,
+                                           uint64_t sizeInBits,
+                                           uint32_t alignInBits,
+                                           uint64_t offsetInBits) {
+  return wrap(DIDerivedTypeAttr::get(unwrap(ctx), tag,
+                                     cast<StringAttr>(unwrap(name)),
+                                     cast<DITypeAttr>(unwrap(baseType)),
+                                     sizeInBits, alignInBits, offsetInBits));
+}
+
+MlirAttribute
+mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType) {
+  return wrap(cast<DIDerivedTypeAttr>(unwrap(diDerivedType)).getBaseType());
+}
+
+MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx, uint64_t cconv) {
+  return wrap(CConvAttr::get(unwrap(ctx), CConv(cconv)));
+}
+
+MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx, uint64_t comdat) {
+  return wrap(ComdatAttr::get(unwrap(ctx), comdat::Comdat(comdat)));
+}
+
+MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx, uint64_t linkage) {
+  return wrap(LinkageAttr::get(unwrap(ctx), linkage::Linkage(linkage)));
+}
+
+MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx, MlirAttribute name,
+                                    MlirAttribute directory) {
+  return wrap(DIFileAttr::get(unwrap(ctx), cast<StringAttr>(unwrap(name)),
+                              cast<StringAttr>(unwrap(directory))));
+}
+
+MlirAttribute mlirLLVMDICompileUnitAttrGet(MlirContext ctx, MlirAttribute id,
+                                           unsigned int sourceLanguage,
+                                           MlirAttribute file,
+                                           MlirAttribute producer,
+                                           bool isOptimized,
+                                           uint64_t emissionKind) {
+  return wrap(DICompileUnitAttr::get(
+      unwrap(ctx), cast<DistinctAttr>(unwrap(id)), sourceLanguage,
+      cast<DIFileAttr>(unwrap(file)), cast<StringAttr>(unwrap(producer)),
+      isOptimized, DIEmissionKind(emissionKind)));
+}
+
+MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx, uint64_t value) {
+  return wrap(DIFlagsAttr::get(unwrap(ctx), DIFlags(value)));
+}
+
+MlirAttribute mlirLLVMDILexicalBlockAttrGet(MlirContext ctx,
+                                            MlirAttribute scope,
+                                            MlirAttribute file,
+                                            unsigned int line,
+                                            unsigned int column) {
+  return wrap(
+      DILexicalBlockAttr::get(unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
+                              cast<DIFileAttr>(unwrap(file)), line, column));
+}
+
+MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(MlirContext ctx,
+                                                MlirAttribute scope,
+                                                MlirAttribute file,
+                                                unsigned int discriminator) {
+  return wrap(DILexicalBlockFileAttr::get(
+      unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
+      cast<DIFileAttr>(unwrap(file)), discriminator));
+}
+
+MlirAttribute
+mlirLLVMDILocalVariableAttrGet(MlirContext ctx, MlirAttribute scope,
+                               MlirAttribute name, MlirAttribute diFile,
+                               unsigned int line, unsigned int arg,
+                               unsigned int alignInBits, MlirAttribute diType) {
+  return wrap(DILocalVariableAttr::get(
+      unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
+      cast<StringAttr>(unwrap(name)), cast<DIFileAttr>(unwrap(diFile)), line,
+      arg, alignInBits, cast<DITypeAttr>(unwrap(diType))));
+}
+
+MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx,
+                                              unsigned int callingConvention,
+                                              intptr_t nTypes,
+                                              MlirAttribute const *types) {
+  SmallVector<Attribute, 2> attrStorage;
+  attrStorage.reserve(nTypes);
+  mlir::ArrayRef<Attribute> tempList = unwrapList(nTypes, types, attrStorage);
+
+  SmallVector<DITypeAttr, 2> diTypesStorage;
+  diTypesStorage.reserve(tempList.size());
+
+  for (auto attr : tempList) {
+    diTypesStorage.push_back(attr.cast<DITypeAttr>());
+  }
+
+  return wrap(DISubroutineTypeAttr::get(unwrap(ctx), callingConvention,
+                                        diTypesStorage));
+}
+
+MlirAttribute mlirLLVMDISubprogramAttrGet(
+    MlirContext ctx, MlirAttribute id, MlirAttribute compileUnit,
+    MlirAttribute scope, MlirAttribute name, MlirAttribute linkageName,
+    MlirAttribute file, unsigned int line, unsigned int scopeLine,
+    uint64_t subprogramFlags, MlirAttribute type) {
+  return wrap(DISubprogramAttr::get(
+      unwrap(ctx), cast<DistinctAttr>(unwrap(id)),
+      cast<DICompileUnitAttr>(unwrap(compileUnit)),
+      cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
+      cast<StringAttr>(unwrap(linkageName)), cast<DIFileAttr>(unwrap(file)),
+      line, scopeLine, DISubprogramFlags(subprogramFlags),
+      cast<DISubroutineTypeAttr>(unwrap(type))));
+}
+
+MlirAttribute mlirLLVMDISubprogramAttrGetScope(MlirAttribute diSubprogram) {
+  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getScope());
+}
+
+unsigned int mlirLLVMDISubprogramAttrGetLine(MlirAttribute diSubprogram) {
+  return cast<DISubprogramAttr>(unwrap(diSubprogram)).getLine();
+}
+
+unsigned int mlirLLVMDISubprogramAttrGetScopeLine(MlirAttribute diSubprogram) {
+  return cast<DISubprogramAttr>(unwrap(diSubprogram)).getScopeLine();
+}
+
+MlirAttribute
+mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram) {
+  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getCompileUnit());
+}
+
+MlirAttribute mlirLLVMDISubprogramAttrGetFile(MlirAttribute diSubprogram) {
+  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getFile());
+}
+
+MlirAttribute mlirLLVMDISubprogramAttrGetType(MlirAttribute diSubprogram) {
+  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getType());
+}
+
+MlirAttribute mlirLLVMDIModuleAttrGet(MlirContext ctx, MlirAttribute file,
+                                      MlirAttribute scope, MlirAttribute name,
+                                      MlirAttribute configMacros,
+                                      MlirAttribute includePath,
+                                      MlirAttribute apinotes, unsigned int line,
+                                      bool isDecl) {
+  return wrap(DIModuleAttr::get(
+      unwrap(ctx), cast<DIFileAttr>(unwrap(file)),
+      cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
+      cast<StringAttr>(unwrap(configMacros)),
+      cast<StringAttr>(unwrap(includePath)), cast<StringAttr>(unwrap(apinotes)),
+      line, isDecl));
+}
+
+MlirAttribute mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule) {
+  return wrap(cast<DIModuleAttr>(unwrap(diModule)).getScope());
+}
diff --git a/mlir/lib/CAPI/IR/BuiltinAttributes.cpp b/mlir/lib/CAPI/IR/BuiltinAttributes.cpp
index b3066ee0c28bdc..726af884668b2d 100644
--- a/mlir/lib/CAPI/IR/BuiltinAttributes.cpp
+++ b/mlir/lib/CAPI/IR/BuiltinAttributes.cpp
@@ -289,6 +289,10 @@ MlirTypeID mlirSymbolRefAttrGetTypeID(void) {
   return wrap(SymbolRefAttr::getTypeID());
 }
 
+MlirAttribute mlirDisctinctAttrCreate(MlirAttribute referencedAttr) {
+  return wrap(mlir::DistinctAttr::create(unwrap(referencedAttr)));
+}
+
 //===----------------------------------------------------------------------===//
 // Flat SymbolRef attribute.
 //===----------------------------------------------------------------------===//
diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c
index a9850c0a132e75..8e79338c57a22a 100644
--- a/mlir/test/CAPI/ir.c
+++ b/mlir/test/CAPI/ir.c
@@ -1482,6 +1482,10 @@ int printAffineMap(MlirContext ctx) {
   // CHECK: (d0, d1, d2) -> (d0)
   // CHECK: (d0, d1, d2) -> (d2)
 
+  // CHECK: distinct[0]<"foo">
+  mlirAttributeDump(mlirDisctinctAttrCreate(
+      mlirStringAttrGet(ctx, mlirStringRefCreateFromCString("foo"))));
+
   return 0;
 }
 
diff --git a/mlir/test/CAPI/llvm.c b/mlir/test/CAPI/llvm.c
index 1817988dd67dd6..82e5dd5d1a8019 100644
--- a/mlir/test/CAPI/llvm.c
+++ b/mlir/test/CAPI/llvm.c
@@ -10,6 +10,7 @@
 // RUN: mlir-capi-llvm-test 2>&1 | FileCheck %s
 
 #include "mlir-c/Dialect/LLVM.h"
+#include "mlir-c/BuiltinAttributes.h"
 #include "mlir-c/BuiltinTypes.h"
 #include "mlir-c/IR.h"
 #include "mlir-c/Support.h"
@@ -77,7 +78,7 @@ static void testTypeCreation(MlirContext ctx) {
 
 // CHECK-LABEL: testStructTypeCreation
 static int testStructTypeCreation(MlirContext ctx) {
-  fprintf(stderr, "testStructTypeCreation");
+  fprintf(stderr, "testStructTypeCreation\n");
 
   // CHECK: !llvm.struct<()>
   mlirTypeDump(mlirLLVMStructTypeLiteralGet(ctx, /*nFieldTypes=*/0,
@@ -225,12 +226,157 @@ static int testStructTypeCreation(MlirContext ctx) {
   return 0;
 }
 
+// CHECK-LABEL: testLLVMAttributes
+static void testLLVMAttributes(MlirContext ctx) {
+  fprintf(stderr, "testLLVMAttributes\n");
+
+  // CHECK: #llvm.linkage<internal>
+  mlirAttributeDump(mlirLLVMLinkageAttrGet(ctx, 0x1));
+  // CHECK: #llvm.cconv<ccc>
+  mlirAttributeDump(mlirLLVMCConvAttrGet(ctx, 0x0));
+  // CHECK: #llvm<comdat any>
+  mlirAttributeDump(mlirLLVMComdatAttrGet(ctx, 0x0));
+}
+
+// CHECK-LABEL: testDebugInfoAttributes
+static void testDebugInfoAttributes(MlirContext ctx) {
+  fprintf(stderr, "testDebugInfoAttributes\n");
+
+  MlirAttribute foo =
+      mlirStringAttrGet(ctx, mlirStringRefCreateFromCString("foo"));
+  MlirAttribute bar =
+      mlirStringAttrGet(ctx, mlirStringRefCreateFromCString("bar"));
+  MlirAttribute id = mlirDisctinctAttrCreate(foo);
+
+  // CHECK: #llvm.di_null_type
+  mlirAttributeDump(mlirLLVMDINullTypeAttrGet(ctx));
+  // CHECK: #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits =
+  // 64, encoding = DW_ATE_signed>
+  MlirAttribute di_type = mlirLLVMDIBasicTypeAttrGet(ctx, 0, foo, 64, 0x5);
+  mlirAttributeDump(di_type);
+
+  MlirAttribute file = mlirLLVMDIFileAttrGet(ctx, foo, bar);
+
+  // CHECK: #llvm.di_file<"foo" in "bar">
+  mlirAttributeDump(file);
+
+  MlirAttribute compile_unit =
+      mlirLLVMDICompileUnitAttrGet(ctx, id, 0x1C, file, foo, false, 0x1);
+
+  // CHECK: #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
+  // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
+  // false, emissionKind = Full>
+  mlirAttributeDump(compile_unit);
+
+  MlirAttribute di_module = mlirLLVMDIModuleAttrGet(
+      ctx, file, compile_unit, foo,
+      mlirStringAttrGet(ctx, mlirStringRefCreateFromCString("")), bar, foo, 1,
+      0);
+  // CHECK: #llvm.di_module<file = <"foo" in "bar">, scope =
+  // #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
+  // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
+  // false, emissionKind = Full>, name = "foo", configMacros = "", includePath =
+  // "bar", apinotes = "foo", line = 1>
+  mlirAttributeDump(di_module);
+
+  // CHECK: #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
+  // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
+  // false, emissionKind = Full>
+  mlirAttributeDump(mlirLLVMDIModuleAttrGetScope(di_module));
+
+  // CHECK: 1 : i32
+  mlirAttributeDump(mlirLLVMDIFlagsAttrGet(ctx, 0x1));
+
+  // CHECK: #llvm.di_lexical_block<scope = #llvm.di_compile_unit<id =
+  // distinct[0]<"foo">, sourceLanguage = DW_LANG_Rust, file = <"foo" in "bar">,
+  // producer = "foo", isOptimized = false, emissionKind = Full>, file = <"foo"
+  // in "bar">, line = 1, column = 2>
+  mlirAttributeDump(
+      mlirLLVMDILexicalBlockAttrGet(ctx, compile_unit, file, 1, 2));
+
+  // CHECK: #llvm.di_lexical_block_file<scope = #llvm.di_compile_unit<id =
+  // distinct[0]<"foo">, sourceLanguage = DW_LANG_Rust, file = <"foo" in "bar">,
+  // producer = "foo", isOptimized = false, emissionKind = Full>, file = <"foo"
+  // in "bar">, discriminator = 3>
+  mlirAttributeDump(
+      mlirLLVMDILexicalBlockFileAttrGet(ctx, compile_unit, file, 3));
+
+  // CHECK: #llvm.di_local_variable<scope = #llvm.di_compile_unit<id =
+  // distinct[0]<"foo">, sourceLanguage = DW_LANG_Rust, file = <"foo" in "bar">,
+  // producer = "foo", isOptimized = false, emissionKind = Full>, name = "foo",
+  // file = <"foo" in "bar">, line = 1, alignInBits = 8, type =
+  // #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits = 64,
+  // encoding = DW_ATE_signed>>
+  mlirAttributeDump(mlirLLVMDILocalVariableAttrGet(ctx, compile_unit, foo, file,
+                                                   1, 0, 8, di_type));
+  // CHECK: #llvm.di_derived_type<tag = DW_TAG_null, name = "bar", baseType =
+  // #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits = 64,
+  // encoding = DW_ATE_signed>, sizeInBits = 64, alignInBits = 8>
+  mlirAttributeDump(
+      mlirLLVMDIDerivedTypeAttrGet(ctx, 0, bar, di_type, 64, 8, 0));
+
+  // CHECK: #llvm.di_composite_type<tag = DW_TAG_null, name = "foo", file =
+  // <"foo" in "bar">, line = 1, scope = #llvm.di_compile_unit<id =
+  // distinct[0]<"foo">, sourceLanguage = DW_LANG_Rust, file = <"foo" in "bar">,
+  // producer = "foo", isOptimized = false, emissionKind = Full>, baseType =
+  // #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits = 64,
+  // encoding = DW_ATE_signed>, sizeInBits = 64, alignInBits = 8, elements =
+  // #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits = 64,
+  // encoding = DW_ATE_signed>>
+  mlirAttributeDump(mlirLLVMDICompositeTypeAttrGet(
+      ctx, 0, foo, file, 1, compile_unit, di_type, 0, 64, 8, 1, &di_type));
+
+  MlirAttribute subroutine_type =
+      mlirLLVMDISubroutineTypeAttrGet(ctx, 0x0, 1, &di_type);
+
+  // CHECK: #llvm.di_subroutine_type<types = #llvm.di_basic_type<tag =
+  // DW_TAG_null, name = "foo", sizeInBits = 64, encoding = DW_ATE_signed>>
+  mlirAttributeDump(subroutine_type);
+
+  MlirAttribute di_subprogram =
+      mlirLLVMDISubprogramAttrGet(ctx, id, compile_unit, compile_unit, foo, bar,
+                                  file, 1, 2, 0, subroutine_type);
+  // CHECK: #llvm.di_subprogram<id = distinct[0]<"foo">, compileUnit = <id =
+  // distinct[0]<"foo">, sourceLanguage = DW_LANG_Rust, file = <"foo" in "bar">,
+  // producer = "foo", isOptimized = false, emissionKind = Full>, scope =
+  // #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
+  // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
+  // false, emissionKind = Full>, name = "foo", linkageName = "bar", file =
+  // <"foo" in "bar">, line = 1, scopeLine = 2, subprogramFlags = , type =
+  // <types = #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits =
+  // 64, encoding = DW_ATE_signed>>>
+  mlirAttributeDump(di_subprogram);
+
+  // CHECK: #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
+  // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
+  // false, emissionKind = Full>
+  mlirAttributeDump(mlirLLVMDISubprogramAttrGetScope(di_subprogram));
+
+  // CHECK: #llvm.di_file<"foo" in "bar">
+  mlirAttributeDump(mlirLLVMDISubprogramAttrGetFile(di_subprogram));
+
+  // CHECK: #llvm.di_subroutine_type<types = #llvm.di_basic_type<tag =
+  // DW_TAG_null, name = "foo", sizeInBits = 64, encoding = DW_ATE_signed>>
+  mlirAttributeDump(mlirLLVMDISubprogramAttrGetType(di_subprogram));
+
+  MlirAttribute expression_elem =
+      mlirLLVMDIExpressionElemAttrGet(ctx, 1, 1, &(uint64_t){1});
+
+  // CHECK: #llvm<di_expression_elem(1)>
+  mlirAttributeDump(expression_elem);
+
+  // CHECK: #llvm.di_expression<[(1)]>
+  mlirAttributeDump(mlirLLVMDIExpressionAttrGet(ctx, 1, &expression_elem));
+}
+
 int main(void) {
   MlirContext ctx = mlirContextCreate();
   mlirDialectHandleRegisterDialect(mlirGetDialectHandle__llvm__(), ctx);
   mlirContextGetOrLoadDialect(ctx, mlirStringRefCreateFromCString("llvm"));
   testTypeCreation(ctx);
   int result = testStructTypeCreation(ctx);
+  testLLVMAttributes(ctx);
+  testDebugInfoAttributes(ctx);
   mlirContextDestroy(ctx);
   if (result)
     fprintf(stderr, "FAILED: code %d", result);

>From c307946dc866a05f8ce2a7ebd247adf217178ac9 Mon Sep 17 00:00:00 2001
From: Edgar Luque <git at edgarluque.com>
Date: Wed, 6 Mar 2024 12:01:25 +0100
Subject: [PATCH 2/4] address some comments

---
 mlir/lib/CAPI/Dialect/LLVM.cpp | 40 +++++++++++-----------------------
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index d540b1a81ee0e4..3ffbbdf1fe262a 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -13,12 +13,9 @@
 #include "mlir/CAPI/Wrap.h"
 #include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
-#include "mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.h.inc"
 #include "mlir/Dialect/LLVMIR/LLVMTypes.h"
-#include "mlir/IR/Attributes.h"
-#include "mlir/IR/BuiltinAttributes.h"
-#include "mlir/Support/LLVM.h"
-#include <stdint.h>
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/SmallVectorExtras.h"
 
 using namespace mlir;
 using namespace mlir::LLVM;
@@ -124,7 +121,7 @@ MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx,
                                               unsigned int opcode,
                                               intptr_t nArguments,
                                               uint64_t const *arguments) {
-  auto list = mlir::ArrayRef<uint64_t>(arguments, nArguments);
+  auto list = ArrayRef<uint64_t>(arguments, nArguments);
   return wrap(DIExpressionElemAttr::get(unwrap(ctx), opcode, list));
 }
 
@@ -132,17 +129,12 @@ MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations,
                                           MlirAttribute const *operations) {
   SmallVector<Attribute, 2> attrStorage;
   attrStorage.reserve(nOperations);
-  mlir::ArrayRef<Attribute> tempList =
-      unwrapList(nOperations, operations, attrStorage);
 
-  SmallVector<DIExpressionElemAttr, 2> diExpressionElemStorage;
-  diExpressionElemStorage.reserve(tempList.size());
-
-  for (auto attr : tempList) {
-    diExpressionElemStorage.push_back(attr.cast<DIExpressionElemAttr>());
-  }
-
-  return wrap(DIExpressionAttr::get(unwrap(ctx), diExpressionElemStorage));
+  return wrap(DIExpressionAttr::get(
+      unwrap(ctx),
+      llvm::map_to_vector(
+          unwrapList(nOperations, operations, attrStorage),
+          [](Attribute a) { return a.cast<DIExpressionElemAttr>(); })));
 }
 
 MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx) {
@@ -165,7 +157,7 @@ MlirAttribute mlirLLVMDICompositeTypeAttrGet(
   SmallVector<Attribute, 2> elementsStorage;
   elementsStorage.reserve(nElements);
 
-  mlir::ArrayRef<Attribute> tempList =
+  ArrayRef<Attribute> tempList =
       unwrapList(nElements, elements, elementsStorage);
 
   SmallVector<DINodeAttr, 2> diNodesStorage;
@@ -269,17 +261,11 @@ MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx,
                                               MlirAttribute const *types) {
   SmallVector<Attribute, 2> attrStorage;
   attrStorage.reserve(nTypes);
-  mlir::ArrayRef<Attribute> tempList = unwrapList(nTypes, types, attrStorage);
-
-  SmallVector<DITypeAttr, 2> diTypesStorage;
-  diTypesStorage.reserve(tempList.size());
-
-  for (auto attr : tempList) {
-    diTypesStorage.push_back(attr.cast<DITypeAttr>());
-  }
 
-  return wrap(DISubroutineTypeAttr::get(unwrap(ctx), callingConvention,
-                                        diTypesStorage));
+  return wrap(DISubroutineTypeAttr::get(
+      unwrap(ctx), callingConvention,
+      llvm::map_to_vector(unwrapList(nTypes, types, attrStorage),
+                          [](Attribute a) { return a.cast<DITypeAttr>(); })));
 }
 
 MlirAttribute mlirLLVMDISubprogramAttrGet(

>From b85ff3a68f1edca6f0b9732852429f9fe00effe6 Mon Sep 17 00:00:00 2001
From: Edgar Luque <git at edgarluque.com>
Date: Wed, 6 Mar 2024 12:03:40 +0100
Subject: [PATCH 3/4] more fixes

---
 mlir/lib/CAPI/Dialect/LLVM.cpp | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index 3ffbbdf1fe262a..8c8902e95e88fb 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -127,7 +127,7 @@ MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx,
 
 MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations,
                                           MlirAttribute const *operations) {
-  SmallVector<Attribute, 2> attrStorage;
+  SmallVector<Attribute> attrStorage;
   attrStorage.reserve(nOperations);
 
   return wrap(DIExpressionAttr::get(
@@ -154,24 +154,16 @@ MlirAttribute mlirLLVMDICompositeTypeAttrGet(
     uint32_t line, MlirAttribute scope, MlirAttribute baseType, int64_t flags,
     uint64_t sizeInBits, uint64_t alignInBits, intptr_t nElements,
     MlirAttribute const *elements) {
-  SmallVector<Attribute, 2> elementsStorage;
+  SmallVector<Attribute> elementsStorage;
   elementsStorage.reserve(nElements);
 
-  ArrayRef<Attribute> tempList =
-      unwrapList(nElements, elements, elementsStorage);
-
-  SmallVector<DINodeAttr, 2> diNodesStorage;
-  diNodesStorage.reserve(tempList.size());
-
-  for (auto attr : tempList) {
-    diNodesStorage.push_back(attr.cast<DINodeAttr>());
-  }
-
   return wrap(DICompositeTypeAttr::get(
       unwrap(ctx), tag, cast<StringAttr>(unwrap(name)),
       cast<DIFileAttr>(unwrap(file)), line, cast<DIScopeAttr>(unwrap(scope)),
       cast<DITypeAttr>(unwrap(baseType)), DIFlags(flags), sizeInBits,
-      alignInBits, diNodesStorage));
+      alignInBits,
+      llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
+                          [](Attribute a) { return a.cast<DINodeAttr>(); })));
 }
 
 MlirAttribute mlirLLVMDIDerivedTypeAttrGet(MlirContext ctx, unsigned int tag,
@@ -259,7 +251,7 @@ MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx,
                                               unsigned int callingConvention,
                                               intptr_t nTypes,
                                               MlirAttribute const *types) {
-  SmallVector<Attribute, 2> attrStorage;
+  SmallVector<Attribute> attrStorage;
   attrStorage.reserve(nTypes);
 
   return wrap(DISubroutineTypeAttr::get(

>From deb2fb74f88cd3b1c4dfe77a7fc910a94218803a Mon Sep 17 00:00:00 2001
From: Edgar Luque <git at edgarluque.com>
Date: Wed, 6 Mar 2024 13:06:26 +0100
Subject: [PATCH 4/4] update some llvm-c api enums and dont use magic numbers

---
 llvm/include/llvm-c/Core.h         | 627 +++++++++++-------------
 llvm/include/llvm-c/DebugInfo.h    | 293 ++++++-----
 llvm/lib/IR/Core.cpp               | 750 ++++++++++++++---------------
 mlir/include/mlir-c/Dialect/LLVM.h |  17 +-
 mlir/lib/CAPI/Dialect/LLVM.cpp     |  13 +-
 mlir/test/CAPI/llvm.c              |  83 +---
 6 files changed, 824 insertions(+), 959 deletions(-)

diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 09746bdaf0c94e..77a53d3a6cd115 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -59,90 +59,90 @@ LLVM_C_EXTERN_C_BEGIN
 /// to reorder them.
 typedef enum {
   /* Terminator Instructions */
-  LLVMRet            = 1,
-  LLVMBr             = 2,
-  LLVMSwitch         = 3,
-  LLVMIndirectBr     = 4,
-  LLVMInvoke         = 5,
+  LLVMRet = 1,
+  LLVMBr = 2,
+  LLVMSwitch = 3,
+  LLVMIndirectBr = 4,
+  LLVMInvoke = 5,
   /* removed 6 due to API changes */
-  LLVMUnreachable    = 7,
-  LLVMCallBr         = 67,
+  LLVMUnreachable = 7,
+  LLVMCallBr = 67,
 
   /* Standard Unary Operators */
-  LLVMFNeg           = 66,
+  LLVMFNeg = 66,
 
   /* Standard Binary Operators */
-  LLVMAdd            = 8,
-  LLVMFAdd           = 9,
-  LLVMSub            = 10,
-  LLVMFSub           = 11,
-  LLVMMul            = 12,
-  LLVMFMul           = 13,
-  LLVMUDiv           = 14,
-  LLVMSDiv           = 15,
-  LLVMFDiv           = 16,
-  LLVMURem           = 17,
-  LLVMSRem           = 18,
-  LLVMFRem           = 19,
+  LLVMAdd = 8,
+  LLVMFAdd = 9,
+  LLVMSub = 10,
+  LLVMFSub = 11,
+  LLVMMul = 12,
+  LLVMFMul = 13,
+  LLVMUDiv = 14,
+  LLVMSDiv = 15,
+  LLVMFDiv = 16,
+  LLVMURem = 17,
+  LLVMSRem = 18,
+  LLVMFRem = 19,
 
   /* Logical Operators */
-  LLVMShl            = 20,
-  LLVMLShr           = 21,
-  LLVMAShr           = 22,
-  LLVMAnd            = 23,
-  LLVMOr             = 24,
-  LLVMXor            = 25,
+  LLVMShl = 20,
+  LLVMLShr = 21,
+  LLVMAShr = 22,
+  LLVMAnd = 23,
+  LLVMOr = 24,
+  LLVMXor = 25,
 
   /* Memory Operators */
-  LLVMAlloca         = 26,
-  LLVMLoad           = 27,
-  LLVMStore          = 28,
-  LLVMGetElementPtr  = 29,
+  LLVMAlloca = 26,
+  LLVMLoad = 27,
+  LLVMStore = 28,
+  LLVMGetElementPtr = 29,
 
   /* Cast Operators */
-  LLVMTrunc          = 30,
-  LLVMZExt           = 31,
-  LLVMSExt           = 32,
-  LLVMFPToUI         = 33,
-  LLVMFPToSI         = 34,
-  LLVMUIToFP         = 35,
-  LLVMSIToFP         = 36,
-  LLVMFPTrunc        = 37,
-  LLVMFPExt          = 38,
-  LLVMPtrToInt       = 39,
-  LLVMIntToPtr       = 40,
-  LLVMBitCast        = 41,
-  LLVMAddrSpaceCast  = 60,
+  LLVMTrunc = 30,
+  LLVMZExt = 31,
+  LLVMSExt = 32,
+  LLVMFPToUI = 33,
+  LLVMFPToSI = 34,
+  LLVMUIToFP = 35,
+  LLVMSIToFP = 36,
+  LLVMFPTrunc = 37,
+  LLVMFPExt = 38,
+  LLVMPtrToInt = 39,
+  LLVMIntToPtr = 40,
+  LLVMBitCast = 41,
+  LLVMAddrSpaceCast = 60,
 
   /* Other Operators */
-  LLVMICmp           = 42,
-  LLVMFCmp           = 43,
-  LLVMPHI            = 44,
-  LLVMCall           = 45,
-  LLVMSelect         = 46,
-  LLVMUserOp1        = 47,
-  LLVMUserOp2        = 48,
-  LLVMVAArg          = 49,
+  LLVMICmp = 42,
+  LLVMFCmp = 43,
+  LLVMPHI = 44,
+  LLVMCall = 45,
+  LLVMSelect = 46,
+  LLVMUserOp1 = 47,
+  LLVMUserOp2 = 48,
+  LLVMVAArg = 49,
   LLVMExtractElement = 50,
-  LLVMInsertElement  = 51,
-  LLVMShuffleVector  = 52,
-  LLVMExtractValue   = 53,
-  LLVMInsertValue    = 54,
-  LLVMFreeze         = 68,
+  LLVMInsertElement = 51,
+  LLVMShuffleVector = 52,
+  LLVMExtractValue = 53,
+  LLVMInsertValue = 54,
+  LLVMFreeze = 68,
 
   /* Atomic operators */
-  LLVMFence          = 55,
-  LLVMAtomicCmpXchg  = 56,
-  LLVMAtomicRMW      = 57,
+  LLVMFence = 55,
+  LLVMAtomicCmpXchg = 56,
+  LLVMAtomicRMW = 57,
 
   /* Exception Handling Operators */
-  LLVMResume         = 58,
-  LLVMLandingPad     = 59,
-  LLVMCleanupRet     = 61,
-  LLVMCatchRet       = 62,
-  LLVMCatchPad       = 63,
-  LLVMCleanupPad     = 64,
-  LLVMCatchSwitch    = 65
+  LLVMResume = 58,
+  LLVMLandingPad = 59,
+  LLVMCleanupRet = 61,
+  LLVMCatchRet = 62,
+  LLVMCatchPad = 63,
+  LLVMCleanupPad = 64,
+  LLVMCatchSwitch = 65
 } LLVMOpcode;
 
 typedef enum {
@@ -164,32 +164,23 @@ typedef enum {
   LLVMX86_MMXTypeKind,   /**< X86 MMX */
   LLVMTokenTypeKind,     /**< Tokens */
   LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */
-  LLVMBFloatTypeKind,    /**< 16 bit brain floating point type */
-  LLVMX86_AMXTypeKind,   /**< X86 AMX */
-  LLVMTargetExtTypeKind, /**< Target extension type */
+  LLVMBFloatTypeKind,         /**< 16 bit brain floating point type */
+  LLVMX86_AMXTypeKind,        /**< X86 AMX */
+  LLVMTargetExtTypeKind,      /**< Target extension type */
 } LLVMTypeKind;
 
 typedef enum {
-  LLVMExternalLinkage,    /**< Externally visible function */
-  LLVMAvailableExternallyLinkage,
-  LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
-  LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
-                            equivalent. */
-  LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
-  LLVMWeakAnyLinkage,     /**< Keep one copy of function when linking (weak) */
-  LLVMWeakODRLinkage,     /**< Same, but only replaced by something
-                            equivalent. */
-  LLVMAppendingLinkage,   /**< Special purpose, only applies to global arrays */
-  LLVMInternalLinkage,    /**< Rename collisions when linking (static
-                               functions) */
-  LLVMPrivateLinkage,     /**< Like Internal, but omit from symbol table */
-  LLVMDLLImportLinkage,   /**< Obsolete */
-  LLVMDLLExportLinkage,   /**< Obsolete */
-  LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
-  LLVMGhostLinkage,       /**< Obsolete */
-  LLVMCommonLinkage,      /**< Tentative definitions */
-  LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
-  LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
+  LLVMPrivateLinkage = 0,
+  LLVMInternalLinkage = 1,
+  LLVMAvailableExternallyLinkage = 2,
+  LLVMLinkOnceAnyLinkage = 3,
+  LLVMWeakAnyLinkage = 4,
+  LLVMCommonLinkage = 5,
+  LLVMAppendingLinkage = 6,
+  LLVMExternalWeakLinkage = 7,
+  LLVMLinkOnceODRLinkage = 8,
+  LLVMWeakODRLinkage = 9,
+  LLVMExternalLinkage = 10,
 } LLVMLinkage;
 
 typedef enum {
@@ -205,53 +196,58 @@ typedef enum {
 } LLVMUnnamedAddr;
 
 typedef enum {
-  LLVMDefaultStorageClass   = 0,
+  LLVMDefaultStorageClass = 0,
   LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
   LLVMDLLExportStorageClass = 2  /**< Function to be accessible from DLL. */
 } LLVMDLLStorageClass;
 
 typedef enum {
-  LLVMCCallConv             = 0,
-  LLVMFastCallConv          = 8,
-  LLVMColdCallConv          = 9,
-  LLVMGHCCallConv           = 10,
-  LLVMHiPECallConv          = 11,
-  LLVMAnyRegCallConv        = 13,
-  LLVMPreserveMostCallConv  = 14,
-  LLVMPreserveAllCallConv   = 15,
-  LLVMSwiftCallConv         = 16,
-  LLVMCXXFASTTLSCallConv    = 17,
-  LLVMX86StdcallCallConv    = 64,
-  LLVMX86FastcallCallConv   = 65,
-  LLVMARMAPCSCallConv       = 66,
-  LLVMARMAAPCSCallConv      = 67,
-  LLVMARMAAPCSVFPCallConv   = 68,
-  LLVMMSP430INTRCallConv    = 69,
-  LLVMX86ThisCallCallConv   = 70,
-  LLVMPTXKernelCallConv     = 71,
-  LLVMPTXDeviceCallConv     = 72,
-  LLVMSPIRFUNCCallConv      = 75,
-  LLVMSPIRKERNELCallConv    = 76,
-  LLVMIntelOCLBICallConv    = 77,
-  LLVMX8664SysVCallConv     = 78,
-  LLVMWin64CallConv         = 79,
+  LLVMCCallConv = 0,
+  LLVMFastCallConv = 8,
+  LLVMColdCallConv = 9,
+  LLVMGHCCallConv = 10,
+  LLVMHiPECallConv = 11,
+  LLVMAnyRegCallConv = 13,
+  LLVMPreserveMostCallConv = 14,
+  LLVMPreserveAllCallConv = 15,
+  LLVMSwiftCallConv = 16,
+  LLVMCXXFASTTLSCallConv = 17,
+  LLVMX86StdcallCallConv = 64,
+  LLVMX86FastcallCallConv = 65,
+  LLVMARMAPCSCallConv = 66,
+  LLVMARMAAPCSCallConv = 67,
+  LLVMARMAAPCSVFPCallConv = 68,
+  LLVMMSP430INTRCallConv = 69,
+  LLVMX86ThisCallCallConv = 70,
+  LLVMPTXKernelCallConv = 71,
+  LLVMPTXDeviceCallConv = 72,
+  LLVMSPIRFUNCCallConv = 75,
+  LLVMSPIRKERNELCallConv = 76,
+  LLVMIntelOCLBICallConv = 77,
+  LLVMX8664SysVCallConv = 78,
+  LLVMWin64CallConv = 79,
   LLVMX86VectorCallCallConv = 80,
-  LLVMHHVMCallConv          = 81,
-  LLVMHHVMCCallConv         = 82,
-  LLVMX86INTRCallConv       = 83,
-  LLVMAVRINTRCallConv       = 84,
-  LLVMAVRSIGNALCallConv     = 85,
-  LLVMAVRBUILTINCallConv    = 86,
-  LLVMAMDGPUVSCallConv      = 87,
-  LLVMAMDGPUGSCallConv      = 88,
-  LLVMAMDGPUPSCallConv      = 89,
-  LLVMAMDGPUCSCallConv      = 90,
-  LLVMAMDGPUKERNELCallConv  = 91,
-  LLVMX86RegCallCallConv    = 92,
-  LLVMAMDGPUHSCallConv      = 93,
+  LLVMHHVMCallConv = 81,
+  LLVMHHVMCCallConv = 82,
+  LLVMX86INTRCallConv = 83,
+  LLVMAVRINTRCallConv = 84,
+  LLVMAVRSIGNALCallConv = 85,
+  LLVMAVRBUILTINCallConv = 86,
+  LLVMAMDGPUVSCallConv = 87,
+  LLVMAMDGPUGSCallConv = 88,
+  LLVMAMDGPUPSCallConv = 89,
+  LLVMAMDGPUCSCallConv = 90,
+  LLVMAMDGPUKERNELCallConv = 91,
+  LLVMX86RegCallCallConv = 92,
+  LLVMAMDGPUHSCallConv = 93,
   LLVMMSP430BUILTINCallConv = 94,
-  LLVMAMDGPULSCallConv      = 95,
-  LLVMAMDGPUESCallConv      = 96
+  LLVMAMDGPULSCallConv = 95,
+  LLVMAMDGPUESCallConv = 96,
+  LLVMAArch64VectorCallCallConv = 97,
+  LLVMAArch64_SVE_VectorCallCallConv = 98,
+  LLVMWASMEmscriptenInvokeCallConv = 99,
+  LLVMAMDGPUGfxCallConv = 100,
+  LLVM68kINTRCallConv = 101,
 } LLVMCallConv;
 
 typedef enum {
@@ -321,8 +317,8 @@ typedef enum {
 } LLVMRealPredicate;
 
 typedef enum {
-  LLVMLandingPadCatch,    /**< A catch clause   */
-  LLVMLandingPadFilter    /**< A filter clause  */
+  LLVMLandingPadCatch, /**< A catch clause   */
+  LLVMLandingPadFilter /**< A filter clause  */
 } LLVMLandingPadClauseTy;
 
 typedef enum {
@@ -340,12 +336,12 @@ typedef enum {
   LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
                                      operations affecting a specific address,
                                      a consistent ordering exists */
-  LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
-                                   necessary to acquire a lock to access other
-                                   memory with normal loads and stores. */
-  LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
-                                   a barrier of the sort necessary to release
-                                   a lock. */
+  LLVMAtomicOrderingAcquire = 4,   /**< Acquire provides a barrier of the sort
+                                     necessary to acquire a lock to access other
+                                     memory with normal loads and stores. */
+  LLVMAtomicOrderingRelease = 5,   /**< Release is similar to Acquire, but with
+                                     a barrier of the sort necessary to release
+                                     a lock. */
   LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
                                           Release barrier (for fences and
                                           operations which both read and write
@@ -361,42 +357,42 @@ typedef enum {
 } LLVMAtomicOrdering;
 
 typedef enum {
-    LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
-    LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
-    LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
-    LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
-    LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
-    LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
-    LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
-    LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
-                             original using a signed comparison and return
-                             the old one */
-    LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
-                             original using a signed comparison and return
-                             the old one */
-    LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
-                             original using an unsigned comparison and return
-                             the old one */
-    LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
-                              original using an unsigned comparison and return
-                              the old one */
-    LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
-                              old one */
-    LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the
+  LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
+  LLVMAtomicRMWBinOpAdd,  /**< Add a value and return the old one */
+  LLVMAtomicRMWBinOpSub,  /**< Subtract a value and return the old one */
+  LLVMAtomicRMWBinOpAnd,  /**< And a value and return the old one */
+  LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
+  LLVMAtomicRMWBinOpOr,   /**< OR a value and return the old one */
+  LLVMAtomicRMWBinOpXor,  /**< Xor a value and return the old one */
+  LLVMAtomicRMWBinOpMax,  /**< Sets the value if it's greater than the
+                            original using a signed comparison and return
+                            the old one */
+  LLVMAtomicRMWBinOpMin,  /**< Sets the value if it's Smaller than the
+                            original using a signed comparison and return
+                            the old one */
+  LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
+                           original using an unsigned comparison and return
+                           the old one */
+  LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
+                            original using an unsigned comparison and return
+                            the old one */
+  LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
                             old one */
-    LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the
-                             original using an floating point comparison and
-                             return the old one */
-    LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the
-                             original using an floating point comparison and
-                             return the old one */
+  LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the
+                          old one */
+  LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the
+                           original using an floating point comparison and
+                           return the old one */
+  LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the
+                           original using an floating point comparison and
+                           return the old one */
 } LLVMAtomicRMWBinOp;
 
 typedef enum {
-    LLVMDSError,
-    LLVMDSWarning,
-    LLVMDSRemark,
-    LLVMDSNote
+  LLVMDSError,
+  LLVMDSWarning,
+  LLVMDSRemark,
+  LLVMDSNote
 } LLVMDiagnosticSeverity;
 
 typedef enum {
@@ -672,9 +668,9 @@ LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);
 /**
  * Create a string attribute.
  */
-LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
-                                           const char *K, unsigned KLength,
-                                           const char *V, unsigned VLength);
+LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, const char *K,
+                                           unsigned KLength, const char *V,
+                                           unsigned VLength);
 
 /**
  * Get the string attribute's kind.
@@ -863,8 +859,8 @@ LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,
  *
  * @see Module::getModuleFlag()
  */
-LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
-                                  const char *Key, size_t KeyLen);
+LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M, const char *Key,
+                                  size_t KeyLen);
 
 /**
  * Add a module-level flag to the module-level flags metadata if it doesn't
@@ -873,8 +869,7 @@ LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
  * @see Module::addModuleFlag()
  */
 void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
-                       const char *Key, size_t KeyLen,
-                       LLVMMetadataRef Val);
+                       const char *Key, size_t KeyLen, LLVMMetadataRef Val);
 
 /**
  * Dump a representation of a module to stderr.
@@ -1024,8 +1019,8 @@ LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
  *
  * @see llvm::Module::getNamedMetadata()
  */
-LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
-                                        const char *Name, size_t NameLen);
+LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M, const char *Name,
+                                        size_t NameLen);
 
 /**
  * Retrieve a NamedMDNode with the given name, creating a new node if no such
@@ -1033,9 +1028,8 @@ LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
  *
  * @see llvm::Module::getOrInsertNamedMetadata()
  */
-LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,
-                                                const char *Name,
-                                                size_t NameLen);
+LLVMNamedMDNodeRef
+LLVMGetOrInsertNamedMetadata(LLVMModuleRef M, const char *Name, size_t NameLen);
 
 /**
  * Retrieve the name of a NamedMDNode.
@@ -1341,9 +1335,8 @@ LLVMTypeRef LLVMPPCFP128Type(void);
  * The function is defined as a tuple of a return Type, a list of
  * parameter types, and whether the function is variadic.
  */
-LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
-                             LLVMTypeRef *ParamTypes, unsigned ParamCount,
-                             LLVMBool IsVarArg);
+LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes,
+                             unsigned ParamCount, LLVMBool IsVarArg);
 
 /**
  * Returns whether a function type is variadic.
@@ -1705,95 +1698,47 @@ LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
  * @{
  */
 
-#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
-  macro(Argument)                           \
-  macro(BasicBlock)                         \
-  macro(InlineAsm)                          \
-  macro(User)                               \
-    macro(Constant)                         \
-      macro(BlockAddress)                   \
-      macro(ConstantAggregateZero)          \
-      macro(ConstantArray)                  \
-      macro(ConstantDataSequential)         \
-        macro(ConstantDataArray)            \
-        macro(ConstantDataVector)           \
-      macro(ConstantExpr)                   \
-      macro(ConstantFP)                     \
-      macro(ConstantInt)                    \
-      macro(ConstantPointerNull)            \
-      macro(ConstantStruct)                 \
-      macro(ConstantTokenNone)              \
-      macro(ConstantVector)                 \
-      macro(GlobalValue)                    \
-        macro(GlobalAlias)                  \
-        macro(GlobalObject)                 \
-          macro(Function)                   \
-          macro(GlobalVariable)             \
-          macro(GlobalIFunc)                \
-      macro(UndefValue)                     \
-      macro(PoisonValue)                    \
-    macro(Instruction)                      \
-      macro(UnaryOperator)                  \
-      macro(BinaryOperator)                 \
-      macro(CallInst)                       \
-        macro(IntrinsicInst)                \
-          macro(DbgInfoIntrinsic)           \
-            macro(DbgVariableIntrinsic)     \
-              macro(DbgDeclareInst)         \
-            macro(DbgLabelInst)             \
-          macro(MemIntrinsic)               \
-            macro(MemCpyInst)               \
-            macro(MemMoveInst)              \
-            macro(MemSetInst)               \
-      macro(CmpInst)                        \
-        macro(FCmpInst)                     \
-        macro(ICmpInst)                     \
-      macro(ExtractElementInst)             \
-      macro(GetElementPtrInst)              \
-      macro(InsertElementInst)              \
-      macro(InsertValueInst)                \
-      macro(LandingPadInst)                 \
-      macro(PHINode)                        \
-      macro(SelectInst)                     \
-      macro(ShuffleVectorInst)              \
-      macro(StoreInst)                      \
-      macro(BranchInst)                     \
-      macro(IndirectBrInst)                 \
-      macro(InvokeInst)                     \
-      macro(ReturnInst)                     \
-      macro(SwitchInst)                     \
-      macro(UnreachableInst)                \
-      macro(ResumeInst)                     \
-      macro(CleanupReturnInst)              \
-      macro(CatchReturnInst)                \
-      macro(CatchSwitchInst)                \
-      macro(CallBrInst)                     \
-      macro(FuncletPadInst)                 \
-        macro(CatchPadInst)                 \
-        macro(CleanupPadInst)               \
-      macro(UnaryInstruction)               \
-        macro(AllocaInst)                   \
-        macro(CastInst)                     \
-          macro(AddrSpaceCastInst)          \
-          macro(BitCastInst)                \
-          macro(FPExtInst)                  \
-          macro(FPToSIInst)                 \
-          macro(FPToUIInst)                 \
-          macro(FPTruncInst)                \
-          macro(IntToPtrInst)               \
-          macro(PtrToIntInst)               \
-          macro(SExtInst)                   \
-          macro(SIToFPInst)                 \
-          macro(TruncInst)                  \
-          macro(UIToFPInst)                 \
-          macro(ZExtInst)                   \
-        macro(ExtractValueInst)             \
-        macro(LoadInst)                     \
-        macro(VAArgInst)                    \
-        macro(FreezeInst)                   \
-      macro(AtomicCmpXchgInst)              \
-      macro(AtomicRMWInst)                  \
-      macro(FenceInst)
+#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro)                                                         \
+  macro(Argument) macro(BasicBlock) macro(InlineAsm) macro(User) macro(Constant) macro(             \
+      BlockAddress) macro(ConstantAggregateZero) macro(ConstantArray) macro(ConstantDataSequential) \
+      macro(ConstantDataArray) macro(ConstantDataVector) macro(ConstantExpr) macro(                 \
+          ConstantFP) macro(ConstantInt) macro(ConstantPointerNull) macro(ConstantStruct)           \
+          macro(ConstantTokenNone) macro(ConstantVector) macro(GlobalValue) macro(                  \
+              GlobalAlias) macro(GlobalObject) macro(Function) macro(GlobalVariable)                \
+              macro(GlobalIFunc) macro(UndefValue) macro(PoisonValue) macro(Instruction) macro(     \
+                  UnaryOperator) macro(BinaryOperator) macro(CallInst) macro(IntrinsicInst)         \
+                  macro(DbgInfoIntrinsic) macro(DbgVariableIntrinsic) macro(                        \
+                      DbgDeclareInst) macro(DbgLabelInst) macro(MemIntrinsic)                       \
+                      macro(MemCpyInst) macro(MemMoveInst) macro(MemSetInst) macro(                 \
+                          CmpInst) macro(FCmpInst) macro(ICmpInst) macro(ExtractElementInst)        \
+                          macro(GetElementPtrInst) macro(InsertElementInst) macro(                  \
+                              InsertValueInst) macro(LandingPadInst) macro(PHINode)                 \
+                              macro(SelectInst) macro(ShuffleVectorInst) macro(                     \
+                                  StoreInst) macro(BranchInst) macro(IndirectBrInst)                \
+                                  macro(InvokeInst) macro(ReturnInst) macro(                        \
+                                      SwitchInst) macro(UnreachableInst) macro(ResumeInst)          \
+                                      macro(CleanupReturnInst) macro(CatchReturnInst) macro(        \
+                                          CatchSwitchInst) macro(CallBrInst)                        \
+                                          macro(FuncletPadInst) macro(CatchPadInst) macro(          \
+                                              CleanupPadInst) macro(UnaryInstruction)               \
+                                              macro(AllocaInst) macro(CastInst) macro(              \
+                                                  AddrSpaceCastInst) macro(BitCastInst)             \
+                                                  macro(FPExtInst) macro(FPToSIInst) macro(         \
+                                                      FPToUIInst) macro(FPTruncInst)                \
+                                                      macro(IntToPtrInst) macro(                    \
+                                                          PtrToIntInst) macro(SExtInst)             \
+                                                          macro(SIToFPInst) macro(                  \
+                                                              TruncInst) macro(UIToFPInst)          \
+                                                              macro(ZExtInst) macro(                \
+                                                                  ExtractValueInst) macro(LoadInst) \
+                                                                  macro(VAArgInst) macro(           \
+                                                                      FreezeInst)                   \
+                                                                      macro(                        \
+                                                                          AtomicCmpXchgInst)        \
+                                                                          macro(                    \
+                                                                              AtomicRMWInst)        \
+                                                                              macro(                \
+                                                                                  FenceInst)
 
 /**
  * @defgroup LLVMCCoreValueGeneral General APIs
@@ -1881,7 +1826,7 @@ LLVMBool LLVMIsPoison(LLVMValueRef Val);
  *
  * @see llvm::dyn_cast_or_null<>
  */
-#define LLVM_DECLARE_VALUE_CAST(name) \
+#define LLVM_DECLARE_VALUE_CAST(name)                                          \
   LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
 
@@ -2168,7 +2113,8 @@ double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
  * @see llvm::ConstantDataArray::getString()
  */
 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
-                                      unsigned Length, LLVMBool DontNullTerminate);
+                                      unsigned Length,
+                                      LLVMBool DontNullTerminate);
 
 /**
  * Create a ConstantDataSequential with string content in the global context.
@@ -2223,8 +2169,8 @@ LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
  * LLVMConstArray2
  * @see llvm::ConstantArray::get()
  */
-LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
-                            LLVMValueRef *ConstantVals, unsigned Length);
+LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals,
+                            unsigned Length);
 
 /**
  * Create a ConstantArray from values.
@@ -2240,8 +2186,7 @@ LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals,
  * @see llvm::ConstantStruct::get()
  */
 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
-                                  LLVMValueRef *ConstantVals,
-                                  unsigned Count);
+                                  LLVMValueRef *ConstantVals, unsigned Count);
 
 /**
  * Get element of a constant aggregate (struct, array or vector) at the
@@ -2290,17 +2235,23 @@ LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
+LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant,
+                             LLVMValueRef RHSConstant);
+LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant,
+                             LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
+LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant,
+                             LLVMValueRef RHSConstant);
+LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant,
+                             LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
+LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant,
+                             LLVMValueRef RHSConstant);
+LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant,
+                             LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
-                           LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
+LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, LLVMValueRef LHSConstant,
+                           LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
                            LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
@@ -2313,11 +2264,11 @@ LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
-LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
+LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal,
+                                    LLVMTypeRef ToType);
 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
                                      LLVMTypeRef ToType);
-LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
-                                  LLVMTypeRef ToType);
+LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
                                      LLVMValueRef IndexConstant);
 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
@@ -2339,8 +2290,8 @@ LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr);
 LLVMBasicBlockRef LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr);
 
 /** Deprecated: Use LLVMGetInlineAsm instead. */
-LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
-                                const char *AsmString, const char *Constraints,
+LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString,
+                                const char *Constraints,
                                 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
 
 /**
@@ -2529,8 +2480,8 @@ LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy,
  *
  * @see llvm::Module::getNamedAlias()
  */
-LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
-                                     const char *Name, size_t NameLen);
+LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M, const char *Name,
+                                     size_t NameLen);
 
 /**
  * Obtain an iterator to the first GlobalAlias in a Module.
@@ -2635,8 +2586,7 @@ unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
  *
  * @see llvm::Intrinsic::getDeclaration()
  */
-LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
-                                         unsigned ID,
+LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod, unsigned ID,
                                          LLVMTypeRef *ParamTypes,
                                          size_t ParamCount);
 
@@ -2856,10 +2806,9 @@ void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
  *
  * @see llvm::GlobalIFunc::create()
  */
-LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
-                                const char *Name, size_t NameLen,
-                                LLVMTypeRef Ty, unsigned AddrSpace,
-                                LLVMValueRef Resolver);
+LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M, const char *Name,
+                                size_t NameLen, LLVMTypeRef Ty,
+                                unsigned AddrSpace, LLVMValueRef Resolver);
 
 /**
  * Obtain a GlobalIFunc value from a Module by its name.
@@ -2868,8 +2817,8 @@ LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
  *
  * @see llvm::Module::getNamedIFunc()
  */
-LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
-                                     const char *Name, size_t NameLen);
+LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M, const char *Name,
+                                     size_t NameLen);
 
 /**
  * Obtain an iterator to the first GlobalIFunc in a Module.
@@ -3228,8 +3177,7 @@ void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
  *
  * @see llvm::Function::BasicBlockListType::push_back()
  */
-void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
-                                  LLVMBasicBlockRef BB);
+void LLVMAppendExistingBasicBlock(LLVMValueRef Fn, LLVMBasicBlockRef BB);
 
 /**
  * Create a new basic block without inserting it into a function.
@@ -3876,8 +3824,8 @@ void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
  * current debug location for the given builder.  If the builder has no current
  * debug location, this function is a no-op.
  *
- * @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general
- *             LLVMAddMetadataToInst.
+ * @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more
+ * general LLVMAddMetadataToInst.
  *
  * @see llvm::IRBuilder::SetInstDebugLocation()
  */
@@ -4053,12 +4001,12 @@ LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
                            const char *Name);
 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
                            const char *Name);
-LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
-                                const char *Name);
+LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS,
+                                LLVMValueRef RHS, const char *Name);
 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
                            const char *Name);
-LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
-                                const char *Name);
+LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS,
+                                LLVMValueRef RHS, const char *Name);
 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
                            const char *Name);
 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
@@ -4068,7 +4016,7 @@ LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
                            const char *Name);
 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
-                           const char *Name);
+                          const char *Name);
 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
                            const char *Name);
 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
@@ -4076,12 +4024,11 @@ LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
                           const char *Name);
 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
-                          const char *Name);
+                         const char *Name);
 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
                           const char *Name);
-LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
-                            LLVMValueRef LHS, LLVMValueRef RHS,
-                            const char *Name);
+LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS,
+                            LLVMValueRef RHS, const char *Name);
 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
                              const char *Name);
@@ -4165,19 +4112,17 @@ LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,
  *
  * @see llvm::IRRBuilder::CreateMemCpy()
  */
-LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B,
-                             LLVMValueRef Dst, unsigned DstAlign,
-                             LLVMValueRef Src, unsigned SrcAlign,
-                             LLVMValueRef Size);
+LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst,
+                             unsigned DstAlign, LLVMValueRef Src,
+                             unsigned SrcAlign, LLVMValueRef Size);
 /**
  * Creates and inserts a memmove between the specified pointers.
  *
  * @see llvm::IRRBuilder::CreateMemMove()
  */
-LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B,
-                              LLVMValueRef Dst, unsigned DstAlign,
-                              LLVMValueRef Src, unsigned SrcAlign,
-                              LLVMValueRef Size);
+LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B, LLVMValueRef Dst,
+                              unsigned DstAlign, LLVMValueRef Src,
+                              unsigned SrcAlign, LLVMValueRef Size);
 
 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
@@ -4204,17 +4149,19 @@ void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
 LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);
 void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);
 LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
-void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
+void LLVMSetOrdering(LLVMValueRef MemoryAccessInst,
+                     LLVMAtomicOrdering Ordering);
 LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst);
-void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp);
+void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst,
+                           LLVMAtomicRMWBinOp BinOp);
 
 /* Casts */
 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
                             LLVMTypeRef DestTy, const char *Name);
-LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
-                           LLVMTypeRef DestTy, const char *Name);
-LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
-                           LLVMTypeRef DestTy, const char *Name);
+LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy,
+                           const char *Name);
+LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy,
+                           const char *Name);
 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
                              LLVMTypeRef DestTy, const char *Name);
 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
@@ -4276,9 +4223,8 @@ LLVMBuildCallWithOperandBundles(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,
                                 LLVMValueRef *Args, unsigned NumArgs,
                                 LLVMOperandBundleRef *Bundles,
                                 unsigned NumBundles, const char *Name);
-LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
-                             LLVMValueRef Then, LLVMValueRef Else,
-                             const char *Name);
+LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, LLVMValueRef Then,
+                             LLVMValueRef Else, const char *Name);
 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
                             const char *Name);
 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
@@ -4378,18 +4324,15 @@ void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
  * @{
  */
 
-LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
-                                                  LLVMMemoryBufferRef *OutMemBuf,
-                                                  char **OutMessage);
+LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(
+    const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage);
 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
                                          char **OutMessage);
-LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
-                                                          size_t InputDataLength,
-                                                          const char *BufferName,
-                                                          LLVMBool RequiresNullTerminator);
-LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
-                                                              size_t InputDataLength,
-                                                              const char *BufferName);
+LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(
+    const char *InputData, size_t InputDataLength, const char *BufferName,
+    LLVMBool RequiresNullTerminator);
+LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(
+    const char *InputData, size_t InputDataLength, const char *BufferName);
 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 5924294708cc35..717e8f5829000c 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -65,8 +65,8 @@ typedef enum {
   LLVMDIFlagBigEndian = 1 << 27,
   LLVMDIFlagLittleEndian = 1 << 28,
   LLVMDIFlagIndirectVirtualBase = (1 << 2) | (1 << 5),
-  LLVMDIFlagAccessibility = LLVMDIFlagPrivate | LLVMDIFlagProtected |
-                            LLVMDIFlagPublic,
+  LLVMDIFlagAccessibility =
+      LLVMDIFlagPrivate | LLVMDIFlagProtected | LLVMDIFlagPublic,
   LLVMDIFlagPtrToMemberRep = LLVMDIFlagSingleInheritance |
                              LLVMDIFlagMultipleInheritance |
                              LLVMDIFlagVirtualInheritance
@@ -136,9 +136,10 @@ typedef enum {
  * The amount of debug information to emit.
  */
 typedef enum {
-    LLVMDWARFEmissionNone = 0,
-    LLVMDWARFEmissionFull,
-    LLVMDWARFEmissionLineTablesOnly
+  LLVMDWARFEmissionNone = 0,
+  LLVMDWARFEmissionFull,
+  LLVMDWARFEmissionLineTablesOnly,
+  LLVMDWARFEmissionDebugDirectivesOnly
 } LLVMDWARFEmissionKind;
 
 /**
@@ -187,6 +188,28 @@ typedef unsigned LLVMMetadataKind;
 /**
  * An LLVM DWARF type encoding.
  */
+enum {
+    LLVMDWARFAddressTypeEncoding = 0x1,
+    LLVMDWARFBooleanTypeEncoding = 0x2,
+    LLVMDWARFComplexFloatTypeEncoding = 0x31,
+    LLVMDWARFFloatTypeEncoding = 0x4,
+    LLVMDWARFSignedTypeEncoding = 0x5,
+    LLVMDWARFSignedCharTypeEncoding = 0x6,
+    LLVMDWARFUnsignedTypeEncoding = 0x7,
+    LLVMDWARFUnsignedCharTypeEncoding = 0x08,
+    LLVMDWARFImaginaryFloatTypeEncoding = 0x09,
+    LLVMDWARFPackedDecimalTypeEncoding = 0x0a,
+    LLVMDWARFNumericStringTypeEncoding = 0x0b,
+    LLVMDWARFEditedTypeEncoding = 0x0c,
+    LLVMDWARFSignedFixedTypeEncoding = 0x0d,
+    LLVMDWARFUnsignedFixedTypeEncoding = 0x0e,
+    LLVMDWARFDecimalFloatTypeEncoding = 0x0f,
+    LLVMDWARFUTFTypeEncoding = 0x10,
+    LLVMDWARFUCSTypeEncoding = 0x11,
+    LLVMDWARFASCIITypeEncoding = 0x12,
+    LLVMDWARFLoUserTypeEncoding = 0x80,
+    LLVMDWARFHiUserTypeEncoding = 0xff,
+};
 typedef unsigned LLVMDWARFTypeEncoding;
 
 /**
@@ -300,10 +323,11 @@ LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(
  * \param Directory    Directory.
  * \param DirectoryLen The length of the C string passed to \c Directory.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename,
-                        size_t FilenameLen, const char *Directory,
-                        size_t DirectoryLen);
+LLVMMetadataRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder,
+                                        const char *Filename,
+                                        size_t FilenameLen,
+                                        const char *Directory,
+                                        size_t DirectoryLen);
 
 /**
  * Creates a new descriptor for a module with the specified parent scope.
@@ -335,11 +359,10 @@ LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope,
  * \param ExportSymbols    Whether or not the namespace exports symbols, e.g.
  *                         this is true of C++ inline namespaces.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder,
-                             LLVMMetadataRef ParentScope,
-                             const char *Name, size_t NameLen,
-                             LLVMBool ExportSymbols);
+LLVMMetadataRef LLVMDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder,
+                                             LLVMMetadataRef ParentScope,
+                                             const char *Name, size_t NameLen,
+                                             LLVMBool ExportSymbols);
 
 /**
  * Create a new descriptor for the specified subprogram.
@@ -363,8 +386,8 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction(
     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
     size_t NameLen, const char *LinkageName, size_t LinkageNameLen,
     LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty,
-    LLVMBool IsLocalToUnit, LLVMBool IsDefinition,
-    unsigned ScopeLine, LLVMDIFlags Flags, LLVMBool IsOptimized);
+    LLVMBool IsLocalToUnit, LLVMBool IsDefinition, unsigned ScopeLine,
+    LLVMDIFlags Flags, LLVMBool IsOptimized);
 
 /**
  * Create a descriptor for a lexical block with the specified parent context.
@@ -374,9 +397,10 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction(
  * \param Line         The line in the source file.
  * \param Column       The column in the source file.
  */
-LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(
-    LLVMDIBuilderRef Builder, LLVMMetadataRef Scope,
-    LLVMMetadataRef File, unsigned Line, unsigned Column);
+LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Builder,
+                                                LLVMMetadataRef Scope,
+                                                LLVMMetadataRef File,
+                                                unsigned Line, unsigned Column);
 
 /**
  * Create a descriptor for a lexical block with a new file attached.
@@ -385,11 +409,10 @@ LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(
  * \param File           Source file.
  * \param Discriminator  DWARF path discriminator value.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Builder,
-                                    LLVMMetadataRef Scope,
-                                    LLVMMetadataRef File,
-                                    unsigned Discriminator);
+LLVMMetadataRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Builder,
+                                                    LLVMMetadataRef Scope,
+                                                    LLVMMetadataRef File,
+                                                    unsigned Discriminator);
 
 /**
  * Create a descriptor for an imported namespace. Suitable for e.g. C++
@@ -399,12 +422,9 @@ LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Builder,
  * \param File       File where the declaration is located.
  * \param Line       Line number of the declaration.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder,
-                                               LLVMMetadataRef Scope,
-                                               LLVMMetadataRef NS,
-                                               LLVMMetadataRef File,
-                                               unsigned Line);
+LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromNamespace(
+    LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef NS,
+    LLVMMetadataRef File, unsigned Line);
 
 /**
  * Create a descriptor for an imported module that aliases another
@@ -467,10 +487,10 @@ LLVMMetadataRef LLVMDIBuilderCreateImportedDeclaration(
  * \note If the item to which this location is attached cannot be
  *       attributed to a source line, pass 0 for the line and column.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateDebugLocation(LLVMContextRef Ctx, unsigned Line,
-                                 unsigned Column, LLVMMetadataRef Scope,
-                                 LLVMMetadataRef InlinedAt);
+LLVMMetadataRef LLVMDIBuilderCreateDebugLocation(LLVMContextRef Ctx,
+                                                 unsigned Line, unsigned Column,
+                                                 LLVMMetadataRef Scope,
+                                                 LLVMMetadataRef InlinedAt);
 
 /**
  * Get the line number of this debug location.
@@ -559,12 +579,10 @@ LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder,
  * \param Flags           E.g.: \c LLVMDIFlagLValueReference.
  *                        These flags are used to emit dwarf attributes.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder,
-                                  LLVMMetadataRef File,
-                                  LLVMMetadataRef *ParameterTypes,
-                                  unsigned NumParameterTypes,
-                                  LLVMDIFlags Flags);
+LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(
+    LLVMDIBuilderRef Builder, LLVMMetadataRef File,
+    LLVMMetadataRef *ParameterTypes, unsigned NumParameterTypes,
+    LLVMDIFlags Flags);
 
 /**
  * Create debugging information entry for a macro.
@@ -655,7 +673,6 @@ LLVMMetadataRef LLVMDIBuilderCreateUnionType(
     LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang,
     const char *UniqueId, size_t UniqueIdLen);
 
-
 /**
  * Create debugging information entry for an array.
  * \param Builder      The DIBuilder.
@@ -665,11 +682,9 @@ LLVMMetadataRef LLVMDIBuilderCreateUnionType(
  * \param Subscripts   Subscripts.
  * \param NumSubscripts Number of subscripts.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size,
-                             uint32_t AlignInBits, LLVMMetadataRef Ty,
-                             LLVMMetadataRef *Subscripts,
-                             unsigned NumSubscripts);
+LLVMMetadataRef LLVMDIBuilderCreateArrayType(
+    LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits,
+    LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts);
 
 /**
  * Create debugging information entry for a vector type.
@@ -680,11 +695,9 @@ LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size,
  * \param Subscripts   Subscripts.
  * \param NumSubscripts Number of subscripts.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateVectorType(LLVMDIBuilderRef Builder, uint64_t Size,
-                              uint32_t AlignInBits, LLVMMetadataRef Ty,
-                              LLVMMetadataRef *Subscripts,
-                              unsigned NumSubscripts);
+LLVMMetadataRef LLVMDIBuilderCreateVectorType(
+    LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits,
+    LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts);
 
 /**
  * Create a DWARF unspecified type.
@@ -692,9 +705,9 @@ LLVMDIBuilderCreateVectorType(LLVMDIBuilderRef Builder, uint64_t Size,
  * \param Name      The unspecified type's name.
  * \param NameLen   Length of type name.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder, const char *Name,
-                                   size_t NameLen);
+LLVMMetadataRef LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder,
+                                                   const char *Name,
+                                                   size_t NameLen);
 
 /**
  * Create debugging information entry for a basic
@@ -706,11 +719,11 @@ LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder, const char *Name,
  * \param Encoding    DWARF encoding code, e.g. \c LLVMDWARFTypeEncoding_float.
  * \param Flags       Flags to encode optional attribute like endianity
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Builder, const char *Name,
-                             size_t NameLen, uint64_t SizeInBits,
-                             LLVMDWARFTypeEncoding Encoding,
-                             LLVMDIFlags Flags);
+LLVMMetadataRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Builder,
+                                             const char *Name, size_t NameLen,
+                                             uint64_t SizeInBits,
+                                             LLVMDWARFTypeEncoding Encoding,
+                                             LLVMDIFlags Flags);
 
 /**
  * Create debugging information entry for a pointer.
@@ -722,10 +735,11 @@ LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Builder, const char *Name,
  * \param Name              Pointer type name. (optional)
  * \param NameLen           Length of pointer type name. (optional)
  */
-LLVMMetadataRef LLVMDIBuilderCreatePointerType(
-    LLVMDIBuilderRef Builder, LLVMMetadataRef PointeeTy,
-    uint64_t SizeInBits, uint32_t AlignInBits, unsigned AddressSpace,
-    const char *Name, size_t NameLen);
+LLVMMetadataRef
+LLVMDIBuilderCreatePointerType(LLVMDIBuilderRef Builder,
+                               LLVMMetadataRef PointeeTy, uint64_t SizeInBits,
+                               uint32_t AlignInBits, unsigned AddressSpace,
+                               const char *Name, size_t NameLen);
 
 /**
  * Create debugging information entry for a struct.
@@ -769,9 +783,9 @@ LLVMMetadataRef LLVMDIBuilderCreateStructType(
  */
 LLVMMetadataRef LLVMDIBuilderCreateMemberType(
     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
-    size_t NameLen, LLVMMetadataRef File, unsigned LineNo,
-    uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
-    LLVMDIFlags Flags, LLVMMetadataRef Ty);
+    size_t NameLen, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
+    uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags,
+    LLVMMetadataRef Ty);
 
 /**
  * Create debugging information entry for a
@@ -787,8 +801,7 @@ LLVMMetadataRef LLVMDIBuilderCreateMemberType(
  * \param ConstantVal  Const initializer of the member.
  * \param AlignInBits  Member alignment.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateStaticMemberType(
+LLVMMetadataRef LLVMDIBuilderCreateStaticMemberType(
     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
     size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
     LLVMMetadataRef Type, LLVMDIFlags Flags, LLVMValueRef ConstantVal,
@@ -803,13 +816,10 @@ LLVMDIBuilderCreateStaticMemberType(
  * \param AlignInBits  Alignment.
  * \param Flags        Flags.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateMemberPointerType(LLVMDIBuilderRef Builder,
-                                     LLVMMetadataRef PointeeType,
-                                     LLVMMetadataRef ClassType,
-                                     uint64_t SizeInBits,
-                                     uint32_t AlignInBits,
-                                     LLVMDIFlags Flags);
+LLVMMetadataRef LLVMDIBuilderCreateMemberPointerType(
+    LLVMDIBuilderRef Builder, LLVMMetadataRef PointeeType,
+    LLVMMetadataRef ClassType, uint64_t SizeInBits, uint32_t AlignInBits,
+    LLVMDIFlags Flags);
 /**
  * Create debugging information entry for Objective-C instance variable.
  * \param Builder      The DIBuilder.
@@ -824,13 +834,11 @@ LLVMDIBuilderCreateMemberPointerType(LLVMDIBuilderRef Builder,
  * \param Ty           Parent type.
  * \param PropertyNode Property associated with this ivar.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateObjCIVar(LLVMDIBuilderRef Builder,
-                            const char *Name, size_t NameLen,
-                            LLVMMetadataRef File, unsigned LineNo,
-                            uint64_t SizeInBits, uint32_t AlignInBits,
-                            uint64_t OffsetInBits, LLVMDIFlags Flags,
-                            LLVMMetadataRef Ty, LLVMMetadataRef PropertyNode);
+LLVMMetadataRef LLVMDIBuilderCreateObjCIVar(
+    LLVMDIBuilderRef Builder, const char *Name, size_t NameLen,
+    LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
+    uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags,
+    LLVMMetadataRef Ty, LLVMMetadataRef PropertyNode);
 
 /**
  * Create debugging information entry for Objective-C property.
@@ -846,23 +854,19 @@ LLVMDIBuilderCreateObjCIVar(LLVMDIBuilderRef Builder,
  * \param PropertyAttributes Objective C property attributes.
  * \param Ty                 Type.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
-                                const char *Name, size_t NameLen,
-                                LLVMMetadataRef File, unsigned LineNo,
-                                const char *GetterName, size_t GetterNameLen,
-                                const char *SetterName, size_t SetterNameLen,
-                                unsigned PropertyAttributes,
-                                LLVMMetadataRef Ty);
+LLVMMetadataRef LLVMDIBuilderCreateObjCProperty(
+    LLVMDIBuilderRef Builder, const char *Name, size_t NameLen,
+    LLVMMetadataRef File, unsigned LineNo, const char *GetterName,
+    size_t GetterNameLen, const char *SetterName, size_t SetterNameLen,
+    unsigned PropertyAttributes, LLVMMetadataRef Ty);
 
 /**
  * Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
  * \param Builder   The DIBuilder.
  * \param Type      The underlying type to which this pointer points.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
-                                     LLVMMetadataRef Type);
+LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
+                                                     LLVMMetadataRef Type);
 
 /**
  * Create debugging information entry for a qualified
@@ -872,9 +876,9 @@ LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
  *                    e.g. LLVMDWARFTypeQualifier_volatile_type
  * \param Type        Base Type.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag,
-                                 LLVMMetadataRef Type);
+LLVMMetadataRef LLVMDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder,
+                                                 unsigned Tag,
+                                                 LLVMMetadataRef Type);
 
 /**
  * Create debugging information entry for a c++
@@ -883,16 +887,15 @@ LLVMDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag,
  * \param Tag       Tag identifying type,
  * \param Type      Base Type.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateReferenceType(LLVMDIBuilderRef Builder, unsigned Tag,
-                                 LLVMMetadataRef Type);
+LLVMMetadataRef LLVMDIBuilderCreateReferenceType(LLVMDIBuilderRef Builder,
+                                                 unsigned Tag,
+                                                 LLVMMetadataRef Type);
 
 /**
  * Create C++11 nullptr type.
  * \param Builder   The DIBuilder.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder);
+LLVMMetadataRef LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder);
 
 /**
  * Create debugging information entry for a typedef.
@@ -920,10 +923,9 @@ LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
  * \param Flags         Flags to describe inheritance attribute, e.g. private
  */
 LLVMMetadataRef
-LLVMDIBuilderCreateInheritance(LLVMDIBuilderRef Builder,
-                               LLVMMetadataRef Ty, LLVMMetadataRef BaseTy,
-                               uint64_t BaseOffset, uint32_t VBPtrOffset,
-                               LLVMDIFlags Flags);
+LLVMDIBuilderCreateInheritance(LLVMDIBuilderRef Builder, LLVMMetadataRef Ty,
+                               LLVMMetadataRef BaseTy, uint64_t BaseOffset,
+                               uint32_t VBPtrOffset, LLVMDIFlags Flags);
 
 /**
  * Create a permanent forward-declared type.
@@ -942,8 +944,8 @@ LLVMDIBuilderCreateInheritance(LLVMDIBuilderRef Builder,
  * \param UniqueIdentifierLen Length of the unique identifier.
  */
 LLVMMetadataRef LLVMDIBuilderCreateForwardDecl(
-    LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
-    size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
+    LLVMDIBuilderRef Builder, unsigned Tag, const char *Name, size_t NameLen,
+    LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
     unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
     const char *UniqueIdentifier, size_t UniqueIdentifierLen);
 
@@ -964,10 +966,9 @@ LLVMMetadataRef LLVMDIBuilderCreateForwardDecl(
  * \param UniqueIdentifier    A unique identifier for the type.
  * \param UniqueIdentifierLen Length of the unique identifier.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateReplaceableCompositeType(
-    LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
-    size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
+LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType(
+    LLVMDIBuilderRef Builder, unsigned Tag, const char *Name, size_t NameLen,
+    LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
     unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
     LLVMDIFlags Flags, const char *UniqueIdentifier,
     size_t UniqueIdentifierLen);
@@ -986,15 +987,11 @@ LLVMDIBuilderCreateReplaceableCompositeType(
  * \param Flags               Flags to encode member attribute.
  * \param Type                Parent type.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateBitFieldMemberType(LLVMDIBuilderRef Builder,
-                                      LLVMMetadataRef Scope,
-                                      const char *Name, size_t NameLen,
-                                      LLVMMetadataRef File, unsigned LineNumber,
-                                      uint64_t SizeInBits,
-                                      uint64_t OffsetInBits,
-                                      uint64_t StorageOffsetInBits,
-                                      LLVMDIFlags Flags, LLVMMetadataRef Type);
+LLVMMetadataRef LLVMDIBuilderCreateBitFieldMemberType(
+    LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
+    uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits,
+    LLVMDIFlags Flags, LLVMMetadataRef Type);
 
 /**
  * Create debugging information entry for a class.
@@ -1018,23 +1015,22 @@ LLVMDIBuilderCreateBitFieldMemberType(LLVMDIBuilderRef Builder,
  * \param UniqueIdentifier    A unique identifier for the type.
  * \param UniqueIdentifierLen Length of the unique identifier.
  */
-LLVMMetadataRef LLVMDIBuilderCreateClassType(LLVMDIBuilderRef Builder,
-    LLVMMetadataRef Scope, const char *Name, size_t NameLen,
-    LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
-    uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags,
-    LLVMMetadataRef DerivedFrom,
-    LLVMMetadataRef *Elements, unsigned NumElements,
-    LLVMMetadataRef VTableHolder, LLVMMetadataRef TemplateParamsNode,
-    const char *UniqueIdentifier, size_t UniqueIdentifierLen);
+LLVMMetadataRef LLVMDIBuilderCreateClassType(
+    LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+    size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
+    uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
+    LLVMDIFlags Flags, LLVMMetadataRef DerivedFrom, LLVMMetadataRef *Elements,
+    unsigned NumElements, LLVMMetadataRef VTableHolder,
+    LLVMMetadataRef TemplateParamsNode, const char *UniqueIdentifier,
+    size_t UniqueIdentifierLen);
 
 /**
  * Create a uniqued DIType* clone with FlagArtificial set.
  * \param Builder     The DIBuilder.
  * \param Type        The underlying type.
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateArtificialType(LLVMDIBuilderRef Builder,
-                                  LLVMMetadataRef Type);
+LLVMMetadataRef LLVMDIBuilderCreateArtificialType(LLVMDIBuilderRef Builder,
+                                                  LLVMMetadataRef Type);
 
 /**
  * Get the name of this DIType.
@@ -1150,7 +1146,6 @@ LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression(
     unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
     LLVMMetadataRef Expr, LLVMMetadataRef Decl, uint32_t AlignInBits);
 
-
 /**
  * Get the dwarf::Tag of a DINode
  */
@@ -1165,13 +1160,13 @@ uint16_t LLVMGetDINodeTag(LLVMMetadataRef MD);
 LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE);
 
 /**
- * Retrieves the \c DIExpression associated with this global variable expression.
- * \param GVE    The global variable expression.
+ * Retrieves the \c DIExpression associated with this global variable
+ * expression. \param GVE    The global variable expression.
  *
  * @see llvm::DIGlobalVariableExpression::getExpression()
  */
-LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression(
-    LLVMMetadataRef GVE);
+LLVMMetadataRef
+LLVMDIGlobalVariableExpressionGetExpression(LLVMMetadataRef GVE);
 
 /**
  * Get the metadata of the file associated with a given variable.
@@ -1257,9 +1252,10 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
  * \param DebugLoc    Debug info location.
  * \param Instr       Instruction acting as a location for the new intrinsic.
  */
-LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
-  LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
-  LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
+LLVMValueRef
+LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
+                                 LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
+                                 LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
 
 /**
  * Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
@@ -1285,12 +1281,10 @@ LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
  * \param DebugLoc    Debug info location.
  * \param Instr       Instruction acting as a location for the new intrinsic.
  */
-LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder,
-                                               LLVMValueRef Val,
-                                               LLVMMetadataRef VarInfo,
-                                               LLVMMetadataRef Expr,
-                                               LLVMMetadataRef DebugLoc,
-                                               LLVMValueRef Instr);
+LLVMValueRef
+LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val,
+                                  LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
+                                  LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
 
 /**
  * Insert a new llvm.dbg.value intrinsic call at the end of the given basic
@@ -1303,12 +1297,9 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder,
  * \param DebugLoc    Debug info location.
  * \param Block       Basic block acting as a location for the new intrinsic.
  */
-LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(LLVMDIBuilderRef Builder,
-                                              LLVMValueRef Val,
-                                              LLVMMetadataRef VarInfo,
-                                              LLVMMetadataRef Expr,
-                                              LLVMMetadataRef DebugLoc,
-                                              LLVMBasicBlockRef Block);
+LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(
+    LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
+    LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
 
 /**
  * Create a new descriptor for a local auto variable.
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index d6d159ab8b9e83..8db747bbec23ab 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -55,31 +55,24 @@ void llvm::initializeCore(PassRegistry &Registry) {
   initializeVerifierLegacyPassPass(Registry);
 }
 
-void LLVMShutdown() {
-  llvm_shutdown();
-}
+void LLVMShutdown() { llvm_shutdown(); }
 
 /*===-- Version query -----------------------------------------------------===*/
 
 void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch) {
-    if (Major)
-        *Major = LLVM_VERSION_MAJOR;
-    if (Minor)
-        *Minor = LLVM_VERSION_MINOR;
-    if (Patch)
-        *Patch = LLVM_VERSION_PATCH;
+  if (Major)
+    *Major = LLVM_VERSION_MAJOR;
+  if (Minor)
+    *Minor = LLVM_VERSION_MINOR;
+  if (Patch)
+    *Patch = LLVM_VERSION_PATCH;
 }
 
 /*===-- Error handling ----------------------------------------------------===*/
 
-char *LLVMCreateMessage(const char *Message) {
-  return strdup(Message);
-}
-
-void LLVMDisposeMessage(char *Message) {
-  free(Message);
-}
+char *LLVMCreateMessage(const char *Message) { return strdup(Message); }
 
+void LLVMDisposeMessage(char *Message) { free(Message); }
 
 /*===-- Operations on contexts --------------------------------------------===*/
 
@@ -88,9 +81,7 @@ static LLVMContext &getGlobalContext() {
   return GlobalContext;
 }
 
-LLVMContextRef LLVMContextCreate() {
-  return wrap(new LLVMContext());
-}
+LLVMContextRef LLVMContextCreate() { return wrap(new LLVMContext()); }
 
 LLVMContextRef LLVMGetGlobalContext() { return wrap(&getGlobalContext()); }
 
@@ -115,7 +106,7 @@ void *LLVMContextGetDiagnosticContext(LLVMContextRef C) {
 void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
                                  void *OpaqueHandle) {
   auto YieldCallback =
-    LLVM_EXTENSION reinterpret_cast<LLVMContext::YieldCallbackTy>(Callback);
+      LLVM_EXTENSION reinterpret_cast<LLVMContext::YieldCallbackTy>(Callback);
   unwrap(C)->setYieldCallback(YieldCallback, OpaqueHandle);
 }
 
@@ -127,9 +118,7 @@ void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard) {
   unwrap(C)->setDiscardValueNames(Discard);
 }
 
-void LLVMContextDispose(LLVMContextRef C) {
-  delete unwrap(C);
-}
+void LLVMContextDispose(LLVMContextRef C) { delete unwrap(C); }
 
 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
                                   unsigned SLen) {
@@ -178,22 +167,20 @@ LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A) {
   return wrap(Attr.getValueAsType());
 }
 
-LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
-                                           const char *K, unsigned KLength,
-                                           const char *V, unsigned VLength) {
-  return wrap(Attribute::get(*unwrap(C), StringRef(K, KLength),
-                             StringRef(V, VLength)));
+LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, const char *K,
+                                           unsigned KLength, const char *V,
+                                           unsigned VLength) {
+  return wrap(
+      Attribute::get(*unwrap(C), StringRef(K, KLength), StringRef(V, VLength)));
 }
 
-const char *LLVMGetStringAttributeKind(LLVMAttributeRef A,
-                                       unsigned *Length) {
+const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length) {
   auto S = unwrap(A).getKindAsString();
   *Length = S.size();
   return S.data();
 }
 
-const char *LLVMGetStringAttributeValue(LLVMAttributeRef A,
-                                        unsigned *Length) {
+const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length) {
   auto S = unwrap(A).getValueAsString();
   *Length = S.size();
   return S.data();
@@ -224,24 +211,24 @@ char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI) {
 }
 
 LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI) {
-    LLVMDiagnosticSeverity severity;
-
-    switch(unwrap(DI)->getSeverity()) {
-    default:
-      severity = LLVMDSError;
-      break;
-    case DS_Warning:
-      severity = LLVMDSWarning;
-      break;
-    case DS_Remark:
-      severity = LLVMDSRemark;
-      break;
-    case DS_Note:
-      severity = LLVMDSNote;
-      break;
-    }
+  LLVMDiagnosticSeverity severity;
+
+  switch (unwrap(DI)->getSeverity()) {
+  default:
+    severity = LLVMDSError;
+    break;
+  case DS_Warning:
+    severity = LLVMDSWarning;
+    break;
+  case DS_Remark:
+    severity = LLVMDSRemark;
+    break;
+  case DS_Note:
+    severity = LLVMDSNote;
+    break;
+  }
 
-    return severity;
+  return severity;
 }
 
 /*===-- Operations on modules ---------------------------------------------===*/
@@ -255,9 +242,7 @@ LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
   return wrap(new Module(ModuleID, *unwrap(C)));
 }
 
-void LLVMDisposeModule(LLVMModuleRef M) {
-  delete unwrap(M);
-}
+void LLVMDisposeModule(LLVMModuleRef M) { delete unwrap(M); }
 
 const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len) {
   auto &Str = unwrap(M)->getModuleIdentifier();
@@ -293,7 +278,7 @@ void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr) {
 }
 
 /*--.. Target triple .......................................................--*/
-const char * LLVMGetTarget(LLVMModuleRef M) {
+const char *LLVMGetTarget(LLVMModuleRef M) {
   return unwrap(M)->getTargetTriple().c_str();
 }
 
@@ -392,16 +377,15 @@ LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,
   return MFE.Metadata;
 }
 
-LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
-                                  const char *Key, size_t KeyLen) {
+LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M, const char *Key,
+                                  size_t KeyLen) {
   return wrap(unwrap(M)->getModuleFlag({Key, KeyLen}));
 }
 
 void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
-                       const char *Key, size_t KeyLen,
-                       LLVMMetadataRef Val) {
-  unwrap(M)->addModuleFlag(map_to_llvmModFlagBehavior(Behavior),
-                           {Key, KeyLen}, unwrap(Val));
+                       const char *Key, size_t KeyLen, LLVMMetadataRef Val) {
+  unwrap(M)->addModuleFlag(map_to_llvmModFlagBehavior(Behavior), {Key, KeyLen},
+                           unwrap(Val));
 }
 
 /*--.. Printing modules ....................................................--*/
@@ -542,7 +526,6 @@ LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M) {
   return wrap(&unwrap(M)->getContext());
 }
 
-
 /*===-- Operations on types -----------------------------------------------===*/
 
 /*--.. Operations on all types (mostly) ....................................--*/
@@ -597,10 +580,7 @@ LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty) {
   llvm_unreachable("Unhandled TypeID.");
 }
 
-LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty)
-{
-    return unwrap(Ty)->isSized();
-}
+LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty) { return unwrap(Ty)->isSized(); }
 
 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty) {
   return wrap(&unwrap(Ty)->getContext());
@@ -626,32 +606,32 @@ char *LLVMPrintTypeToString(LLVMTypeRef Ty) {
 
 /*--.. Operations on integer types .........................................--*/
 
-LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C)  {
-  return (LLVMTypeRef) Type::getInt1Ty(*unwrap(C));
+LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C) {
+  return (LLVMTypeRef)Type::getInt1Ty(*unwrap(C));
 }
-LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C)  {
-  return (LLVMTypeRef) Type::getInt8Ty(*unwrap(C));
+LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C) {
+  return (LLVMTypeRef)Type::getInt8Ty(*unwrap(C));
 }
 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getInt16Ty(*unwrap(C));
+  return (LLVMTypeRef)Type::getInt16Ty(*unwrap(C));
 }
 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getInt32Ty(*unwrap(C));
+  return (LLVMTypeRef)Type::getInt32Ty(*unwrap(C));
 }
 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getInt64Ty(*unwrap(C));
+  return (LLVMTypeRef)Type::getInt64Ty(*unwrap(C));
 }
 LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getInt128Ty(*unwrap(C));
+  return (LLVMTypeRef)Type::getInt128Ty(*unwrap(C));
 }
 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits) {
   return wrap(IntegerType::get(*unwrap(C), NumBits));
 }
 
-LLVMTypeRef LLVMInt1Type(void)  {
+LLVMTypeRef LLVMInt1Type(void) {
   return LLVMInt1TypeInContext(LLVMGetGlobalContext());
 }
-LLVMTypeRef LLVMInt8Type(void)  {
+LLVMTypeRef LLVMInt8Type(void) {
   return LLVMInt8TypeInContext(LLVMGetGlobalContext());
 }
 LLVMTypeRef LLVMInt16Type(void) {
@@ -677,31 +657,31 @@ unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) {
 /*--.. Operations on real types ............................................--*/
 
 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getHalfTy(*unwrap(C));
+  return (LLVMTypeRef)Type::getHalfTy(*unwrap(C));
 }
 LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getBFloatTy(*unwrap(C));
+  return (LLVMTypeRef)Type::getBFloatTy(*unwrap(C));
 }
 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getFloatTy(*unwrap(C));
+  return (LLVMTypeRef)Type::getFloatTy(*unwrap(C));
 }
 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getDoubleTy(*unwrap(C));
+  return (LLVMTypeRef)Type::getDoubleTy(*unwrap(C));
 }
 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getX86_FP80Ty(*unwrap(C));
+  return (LLVMTypeRef)Type::getX86_FP80Ty(*unwrap(C));
 }
 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getFP128Ty(*unwrap(C));
+  return (LLVMTypeRef)Type::getFP128Ty(*unwrap(C));
 }
 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getPPC_FP128Ty(*unwrap(C));
+  return (LLVMTypeRef)Type::getPPC_FP128Ty(*unwrap(C));
 }
 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getX86_MMXTy(*unwrap(C));
+  return (LLVMTypeRef)Type::getX86_MMXTy(*unwrap(C));
 }
 LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getX86_AMXTy(*unwrap(C));
+  return (LLVMTypeRef)Type::getX86_AMXTy(*unwrap(C));
 }
 
 LLVMTypeRef LLVMHalfType(void) {
@@ -734,10 +714,9 @@ LLVMTypeRef LLVMX86AMXType(void) {
 
 /*--.. Operations on function types ........................................--*/
 
-LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
-                             LLVMTypeRef *ParamTypes, unsigned ParamCount,
-                             LLVMBool IsVarArg) {
-  ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
+LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes,
+                             unsigned ParamCount, LLVMBool IsVarArg) {
+  ArrayRef<Type *> Tys(unwrap(ParamTypes), ParamCount);
   return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0));
 }
 
@@ -762,24 +741,22 @@ void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest) {
 /*--.. Operations on struct types ..........................................--*/
 
 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
-                           unsigned ElementCount, LLVMBool Packed) {
-  ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
+                                    unsigned ElementCount, LLVMBool Packed) {
+  ArrayRef<Type *> Tys(unwrap(ElementTypes), ElementCount);
   return wrap(StructType::get(*unwrap(C), Tys, Packed != 0));
 }
 
-LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes,
-                           unsigned ElementCount, LLVMBool Packed) {
+LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
+                           LLVMBool Packed) {
   return LLVMStructTypeInContext(LLVMGetGlobalContext(), ElementTypes,
                                  ElementCount, Packed);
 }
 
-LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name)
-{
+LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name) {
   return wrap(StructType::create(*unwrap(C), Name));
 }
 
-const char *LLVMGetStructName(LLVMTypeRef Ty)
-{
+const char *LLVMGetStructName(LLVMTypeRef Ty) {
   StructType *Type = unwrap<StructType>(Ty);
   if (!Type->hasName())
     return nullptr;
@@ -788,7 +765,7 @@ const char *LLVMGetStructName(LLVMTypeRef Ty)
 
 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
                        unsigned ElementCount, LLVMBool Packed) {
-  ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
+  ArrayRef<Type *> Tys(unwrap(ElementTypes), ElementCount);
   unwrap<StructType>(StructTy)->setBody(Tys, Packed != 0);
 }
 
@@ -830,11 +807,11 @@ LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name) {
 /*--.. Operations on array, pointer, and vector types (sequence types) .....--*/
 
 void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr) {
-    int i = 0;
-    for (auto *T : unwrap(Tp)->subtypes()) {
-        Arr[i] = wrap(T);
-        i++;
-    }
+  int i = 0;
+  for (auto *T : unwrap(Tp)->subtypes()) {
+    Arr[i] = wrap(T);
+    i++;
+  }
 }
 
 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) {
@@ -849,9 +826,7 @@ LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace) {
   return wrap(PointerType::get(unwrap(ElementType), AddressSpace));
 }
 
-LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty) {
-  return true;
-}
+LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty) { return true; }
 
 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) {
   return wrap(FixedVectorType::get(unwrap(ElementType), ElementCount));
@@ -870,7 +845,7 @@ LLVMTypeRef LLVMGetElementType(LLVMTypeRef WrappedTy) {
 }
 
 unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp) {
-    return unwrap(Tp)->getNumContainedTypes();
+  return unwrap(Tp)->getNumContainedTypes();
 }
 
 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy) {
@@ -895,7 +870,7 @@ LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace) {
   return wrap(PointerType::get(*unwrap(C), AddressSpace));
 }
 
-LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C)  {
+LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C) {
   return wrap(Type::getVoidTy(*unwrap(C)));
 }
 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C) {
@@ -908,7 +883,7 @@ LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C) {
   return wrap(Type::getMetadataTy(*unwrap(C)));
 }
 
-LLVMTypeRef LLVMVoidType(void)  {
+LLVMTypeRef LLVMVoidType(void) {
   return LLVMVoidTypeInContext(LLVMGetGlobalContext());
 }
 LLVMTypeRef LLVMLabelType(void) {
@@ -935,10 +910,10 @@ LLVMTypeRef LLVMTypeOf(LLVMValueRef Val) {
 }
 
 LLVMValueKind LLVMGetValueKind(LLVMValueRef Val) {
-    switch(unwrap(Val)->getValueID()) {
+  switch (unwrap(Val)->getValueID()) {
 #define LLVM_C_API 1
-#define HANDLE_VALUE(Name) \
-  case Value::Name##Val: \
+#define HANDLE_VALUE(Name)                                                     \
+  case Value::Name##Val:                                                       \
     return LLVM##Name##ValueKind;
 #include "llvm/IR/Value.def"
   default:
@@ -968,7 +943,7 @@ void LLVMDumpValue(LLVMValueRef Val) {
   unwrap(Val)->print(errs(), /*IsForDebug=*/true);
 }
 
-char* LLVMPrintValueToString(LLVMValueRef Val) {
+char *LLVMPrintValueToString(LLVMValueRef Val) {
   std::string buf;
   raw_string_ostream os(buf);
 
@@ -1004,7 +979,7 @@ LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID) {
 static MDNode *extractMDNode(MetadataAsValue *MAV) {
   Metadata *MD = MAV->getMetadata();
   assert((isa<MDNode>(MD) || isa<ConstantAsMetadata>(MD)) &&
-      "Expected a metadata node or a canonicalized constant");
+         "Expected a metadata node or a canonicalized constant");
 
   if (MDNode *N = dyn_cast<MDNode>(MD))
     return N;
@@ -1031,8 +1006,8 @@ llvm_getMetadata(size_t *NumEntries,
   AccessMD(MVEs);
 
   LLVMOpaqueValueMetadataEntry *Result =
-  static_cast<LLVMOpaqueValueMetadataEntry *>(
-                                              safe_malloc(MVEs.size() * sizeof(LLVMOpaqueValueMetadataEntry)));
+      static_cast<LLVMOpaqueValueMetadataEntry *>(
+          safe_malloc(MVEs.size() * sizeof(LLVMOpaqueValueMetadataEntry)));
   for (unsigned i = 0; i < MVEs.size(); ++i) {
     const auto &ModuleFlag = MVEs[i];
     Result[i].Kind = ModuleFlag.first;
@@ -1053,9 +1028,9 @@ LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Value,
 
 /*--.. Conversion functions ................................................--*/
 
-#define LLVM_DEFINE_VALUE_CAST(name)                                       \
-  LLVMValueRef LLVMIsA##name(LLVMValueRef Val) {                           \
-    return wrap(static_cast<Value*>(dyn_cast_or_null<name>(unwrap(Val)))); \
+#define LLVM_DEFINE_VALUE_CAST(name)                                           \
+  LLVMValueRef LLVMIsA##name(LLVMValueRef Val) {                               \
+    return wrap(static_cast<Value *>(dyn_cast_or_null<name>(unwrap(Val))));    \
   }
 
 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DEFINE_VALUE_CAST)
@@ -1098,13 +1073,9 @@ LLVMUseRef LLVMGetNextUse(LLVMUseRef U) {
   return nullptr;
 }
 
-LLVMValueRef LLVMGetUser(LLVMUseRef U) {
-  return wrap(unwrap(U)->getUser());
-}
+LLVMValueRef LLVMGetUser(LLVMUseRef U) { return wrap(unwrap(U)->getUser()); }
 
-LLVMValueRef LLVMGetUsedValue(LLVMUseRef U) {
-  return wrap(unwrap(U)->get());
-}
+LLVMValueRef LLVMGetUsedValue(LLVMUseRef U) { return wrap(unwrap(U)->get()); }
 
 /*--.. Operations on Users .................................................--*/
 
@@ -1167,9 +1138,7 @@ LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty) {
   return wrap(PoisonValue::get(unwrap(Ty)));
 }
 
-LLVMBool LLVMIsConstant(LLVMValueRef Ty) {
-  return isa<Constant>(unwrap(Ty));
-}
+LLVMBool LLVMIsConstant(LLVMValueRef Ty) { return isa<Constant>(unwrap(Ty)); }
 
 LLVMBool LLVMIsNull(LLVMValueRef Val) {
   if (Constant *C = dyn_cast<Constant>(unwrap(Val)))
@@ -1177,9 +1146,7 @@ LLVMBool LLVMIsNull(LLVMValueRef Val) {
   return false;
 }
 
-LLVMBool LLVMIsUndef(LLVMValueRef Val) {
-  return isa<UndefValue>(unwrap(Val));
-}
+LLVMBool LLVMIsUndef(LLVMValueRef Val) { return isa<UndefValue>(unwrap(Val)); }
 
 LLVMBool LLVMIsPoison(LLVMValueRef Val) {
   return isa<PoisonValue>(unwrap(Val));
@@ -1198,7 +1165,8 @@ LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str,
 
 LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs,
                                      size_t Count) {
-  return wrap(MDNode::get(*unwrap(C), ArrayRef<Metadata*>(unwrap(MDs), Count)));
+  return wrap(
+      MDNode::get(*unwrap(C), ArrayRef<Metadata *>(unwrap(MDs), Count)));
 }
 
 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
@@ -1305,13 +1273,14 @@ LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NMD) {
   return wrap(&*--I);
 }
 
-LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
-                                        const char *Name, size_t NameLen) {
+LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M, const char *Name,
+                                        size_t NameLen) {
   return wrap(unwrap(M)->getNamedMetadata(StringRef(Name, NameLen)));
 }
 
 LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,
-                                                const char *Name, size_t NameLen) {
+                                                const char *Name,
+                                                size_t NameLen) {
   return wrap(unwrap(M)->getOrInsertNamedMetadata({Name, NameLen}));
 }
 
@@ -1354,7 +1323,7 @@ void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
   if (!N)
     return;
   LLVMContext &Context = unwrap(M)->getContext();
-  for (unsigned i=0;i<N->getNumOperands();i++)
+  for (unsigned i = 0; i < N->getNumOperands(); i++)
     Dest[i] = wrap(MetadataAsValue::get(Context, N->getOperand(i)));
 }
 
@@ -1369,7 +1338,8 @@ void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
 }
 
 const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length) {
-  if (!Length) return nullptr;
+  if (!Length)
+    return nullptr;
   StringRef S;
   if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
     if (const auto &DL = I->getDebugLoc()) {
@@ -1393,7 +1363,8 @@ const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length) {
 }
 
 const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length) {
-  if (!Length) return nullptr;
+  if (!Length)
+    return nullptr;
   StringRef S;
   if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
     if (const auto &DL = I->getDebugLoc()) {
@@ -1456,15 +1427,15 @@ LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
                                               unsigned NumWords,
                                               const uint64_t Words[]) {
-    IntegerType *Ty = unwrap<IntegerType>(IntTy);
-    return wrap(ConstantInt::get(
-        Ty->getContext(), APInt(Ty->getBitWidth(), ArrayRef(Words, NumWords))));
+  IntegerType *Ty = unwrap<IntegerType>(IntTy);
+  return wrap(ConstantInt::get(
+      Ty->getContext(), APInt(Ty->getBitWidth(), ArrayRef(Words, NumWords))));
 }
 
 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char Str[],
                                   uint8_t Radix) {
-  return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str),
-                               Radix));
+  return wrap(
+      ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str), Radix));
 }
 
 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char Str[],
@@ -1495,7 +1466,7 @@ long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal) {
 }
 
 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo) {
-  ConstantFP *cFP = unwrap<ConstantFP>(ConstantVal) ;
+  ConstantFP *cFP = unwrap<ConstantFP>(ConstantVal);
   Type *Ty = cFP->getType();
 
   if (Ty->isHalfTy() || Ty->isBFloatTy() || Ty->isFloatTy() ||
@@ -1506,7 +1477,8 @@ double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo) {
 
   bool APFLosesInfo;
   APFloat APF = cFP->getValueAPF();
-  APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &APFLosesInfo);
+  APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven,
+              &APFLosesInfo);
   *LosesInfo = APFLosesInfo;
   return APF.convertToDouble();
 }
@@ -1546,9 +1518,9 @@ const char *LLVMGetAsString(LLVMValueRef C, size_t *Length) {
   return Str.data();
 }
 
-LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
-                            LLVMValueRef *ConstantVals, unsigned Length) {
-  ArrayRef<Constant*> V(unwrap<Constant>(ConstantVals, Length), Length);
+LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals,
+                            unsigned Length) {
+  ArrayRef<Constant *> V(unwrap<Constant>(ConstantVals, Length), Length);
   return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
 }
 
@@ -1573,8 +1545,7 @@ LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
 }
 
 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
-                                  LLVMValueRef *ConstantVals,
-                                  unsigned Count) {
+                                  LLVMValueRef *ConstantVals, unsigned Count) {
   Constant **Elements = unwrap<Constant>(ConstantVals, Count);
   StructType *Ty = unwrap<StructType>(StructTy);
 
@@ -1588,24 +1559,27 @@ LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
 
 /*-- Opcode mapping */
 
-static LLVMOpcode map_to_llvmopcode(int opcode)
-{
-    switch (opcode) {
-      default: llvm_unreachable("Unhandled Opcode.");
-#define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
+static LLVMOpcode map_to_llvmopcode(int opcode) {
+  switch (opcode) {
+  default:
+    llvm_unreachable("Unhandled Opcode.");
+#define HANDLE_INST(num, opc, clas)                                            \
+  case num:                                                                    \
+    return LLVM##opc;
 #include "llvm/IR/Instruction.def"
 #undef HANDLE_INST
-    }
+  }
 }
 
-static int map_from_llvmopcode(LLVMOpcode code)
-{
-    switch (code) {
-#define HANDLE_INST(num, opc, clas) case LLVM##opc: return num;
+static int map_from_llvmopcode(LLVMOpcode code) {
+  switch (code) {
+#define HANDLE_INST(num, opc, clas)                                            \
+  case LLVM##opc:                                                              \
+    return num;
 #include "llvm/IR/Instruction.def"
 #undef HANDLE_INST
-    }
-    llvm_unreachable("Unhandled Opcode.");
+  }
+  llvm_unreachable("Unhandled Opcode.");
 }
 
 /*--.. Constant expressions ................................................--*/
@@ -1634,7 +1608,6 @@ LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal) {
   return wrap(ConstantExpr::getNUWNeg(unwrap<Constant>(ConstantVal)));
 }
 
-
 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal) {
   return wrap(ConstantExpr::getNot(unwrap<Constant>(ConstantVal)));
 }
@@ -1695,17 +1668,15 @@ LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
                                    unwrap<Constant>(RHSConstant)));
 }
 
-LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
-                           LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
-  return wrap(ConstantExpr::getICmp(Predicate,
-                                    unwrap<Constant>(LHSConstant),
+LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, LLVMValueRef LHSConstant,
+                           LLVMValueRef RHSConstant) {
+  return wrap(ConstantExpr::getICmp(Predicate, unwrap<Constant>(LHSConstant),
                                     unwrap<Constant>(RHSConstant)));
 }
 
 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
                            LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
-  return wrap(ConstantExpr::getFCmp(Predicate,
-                                    unwrap<Constant>(LHSConstant),
+  return wrap(ConstantExpr::getFCmp(Predicate, unwrap<Constant>(LHSConstant),
                                     unwrap<Constant>(RHSConstant)));
 }
 
@@ -1732,23 +1703,23 @@ LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
 }
 
 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
-  return wrap(ConstantExpr::getTrunc(unwrap<Constant>(ConstantVal),
-                                     unwrap(ToType)));
+  return wrap(
+      ConstantExpr::getTrunc(unwrap<Constant>(ConstantVal), unwrap(ToType)));
 }
 
 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
-  return wrap(ConstantExpr::getPtrToInt(unwrap<Constant>(ConstantVal),
-                                        unwrap(ToType)));
+  return wrap(
+      ConstantExpr::getPtrToInt(unwrap<Constant>(ConstantVal), unwrap(ToType)));
 }
 
 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
-  return wrap(ConstantExpr::getIntToPtr(unwrap<Constant>(ConstantVal),
-                                        unwrap(ToType)));
+  return wrap(
+      ConstantExpr::getIntToPtr(unwrap<Constant>(ConstantVal), unwrap(ToType)));
 }
 
 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
-  return wrap(ConstantExpr::getBitCast(unwrap<Constant>(ConstantVal),
-                                       unwrap(ToType)));
+  return wrap(
+      ConstantExpr::getBitCast(unwrap<Constant>(ConstantVal), unwrap(ToType)));
 }
 
 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal,
@@ -1778,9 +1749,9 @@ LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
                                     LLVMValueRef ElementValueConstant,
                                     LLVMValueRef IndexConstant) {
-  return wrap(ConstantExpr::getInsertElement(unwrap<Constant>(VectorConstant),
-                                         unwrap<Constant>(ElementValueConstant),
-                                             unwrap<Constant>(IndexConstant)));
+  return wrap(ConstantExpr::getInsertElement(
+      unwrap<Constant>(VectorConstant), unwrap<Constant>(ElementValueConstant),
+      unwrap<Constant>(IndexConstant)));
 }
 
 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
@@ -1868,11 +1839,6 @@ void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage) {
   case LLVMLinkOnceODRLinkage:
     GV->setLinkage(GlobalValue::LinkOnceODRLinkage);
     break;
-  case LLVMLinkOnceODRAutoHideLinkage:
-    LLVM_DEBUG(
-        errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no "
-                  "longer supported.");
-    break;
   case LLVMWeakAnyLinkage:
     GV->setLinkage(GlobalValue::WeakAnyLinkage);
     break;
@@ -1888,29 +1854,9 @@ void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage) {
   case LLVMPrivateLinkage:
     GV->setLinkage(GlobalValue::PrivateLinkage);
     break;
-  case LLVMLinkerPrivateLinkage:
-    GV->setLinkage(GlobalValue::PrivateLinkage);
-    break;
-  case LLVMLinkerPrivateWeakLinkage:
-    GV->setLinkage(GlobalValue::PrivateLinkage);
-    break;
-  case LLVMDLLImportLinkage:
-    LLVM_DEBUG(
-        errs()
-        << "LLVMSetLinkage(): LLVMDLLImportLinkage is no longer supported.");
-    break;
-  case LLVMDLLExportLinkage:
-    LLVM_DEBUG(
-        errs()
-        << "LLVMSetLinkage(): LLVMDLLExportLinkage is no longer supported.");
-    break;
   case LLVMExternalWeakLinkage:
     GV->setLinkage(GlobalValue::ExternalWeakLinkage);
     break;
-  case LLVMGhostLinkage:
-    LLVM_DEBUG(
-        errs() << "LLVMSetLinkage(): LLVMGhostLinkage is no longer supported.");
-    break;
   case LLVMCommonLinkage:
     GV->setLinkage(GlobalValue::CommonLinkage);
     break;
@@ -1929,12 +1875,12 @@ void LLVMSetSection(LLVMValueRef Global, const char *Section) {
 
 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global) {
   return static_cast<LLVMVisibility>(
-    unwrap<GlobalValue>(Global)->getVisibility());
+      unwrap<GlobalValue>(Global)->getVisibility());
 }
 
 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz) {
-  unwrap<GlobalValue>(Global)
-    ->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz));
+  unwrap<GlobalValue>(Global)->setVisibility(
+      static_cast<GlobalValue::VisibilityTypes>(Viz));
 }
 
 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global) {
@@ -2082,10 +2028,9 @@ LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name) {
 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
                                          const char *Name,
                                          unsigned AddressSpace) {
-  return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
-                                 GlobalValue::ExternalLinkage, nullptr, Name,
-                                 nullptr, GlobalVariable::NotThreadLocal,
-                                 AddressSpace));
+  return wrap(new GlobalVariable(
+      *unwrap(M), unwrap(Ty), false, GlobalValue::ExternalLinkage, nullptr,
+      Name, nullptr, GlobalVariable::NotThreadLocal, AddressSpace));
 }
 
 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name) {
@@ -2129,15 +2074,15 @@ void LLVMDeleteGlobal(LLVMValueRef GlobalVar) {
 }
 
 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar) {
-  GlobalVariable* GV = unwrap<GlobalVariable>(GlobalVar);
-  if ( !GV->hasInitializer() )
+  GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
+  if (!GV->hasInitializer())
     return nullptr;
   return wrap(GV->getInitializer());
 }
 
 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) {
-  unwrap<GlobalVariable>(GlobalVar)
-    ->setInitializer(unwrap<Constant>(ConstantVal));
+  unwrap<GlobalVariable>(GlobalVar)->setInitializer(
+      unwrap<Constant>(ConstantVal));
 }
 
 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar) {
@@ -2213,8 +2158,8 @@ LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy,
                                   unwrap<Constant>(Aliasee), unwrap(M)));
 }
 
-LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
-                                     const char *Name, size_t NameLen) {
+LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M, const char *Name,
+                                     size_t NameLen) {
   return wrap(unwrap(M)->getNamedAlias(StringRef(Name, NameLen)));
 }
 
@@ -2329,11 +2274,10 @@ static Intrinsic::ID llvm_map_to_intrinsic_id(unsigned ID) {
   return llvm::Intrinsic::ID(ID);
 }
 
-LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
-                                         unsigned ID,
+LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod, unsigned ID,
                                          LLVMTypeRef *ParamTypes,
                                          size_t ParamCount) {
-  ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
+  ArrayRef<Type *> Tys(unwrap(ParamTypes), ParamCount);
   auto IID = llvm_map_to_intrinsic_id(ID);
   return wrap(llvm::Intrinsic::getDeclaration(unwrap(Mod), IID, Tys));
 }
@@ -2348,7 +2292,7 @@ const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength) {
 LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
                                  LLVMTypeRef *ParamTypes, size_t ParamCount) {
   auto IID = llvm_map_to_intrinsic_id(ID);
-  ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
+  ArrayRef<Type *> Tys(unwrap(ParamTypes), ParamCount);
   return wrap(llvm::Intrinsic::getType(*unwrap(Ctx), IID, Tys));
 }
 
@@ -2357,7 +2301,7 @@ const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
                                             size_t ParamCount,
                                             size_t *NameLength) {
   auto IID = llvm_map_to_intrinsic_id(ID);
-  ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
+  ArrayRef<Type *> Tys(unwrap(ParamTypes), ParamCount);
   auto Str = llvm::Intrinsic::getNameNoUnnamedTypes(IID, Tys);
   *NameLength = Str.length();
   return strdup(Str.c_str());
@@ -2388,13 +2332,12 @@ unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn) {
 }
 
 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC) {
-  return unwrap<Function>(Fn)->setCallingConv(
-    static_cast<CallingConv::ID>(CC));
+  return unwrap<Function>(Fn)->setCallingConv(static_cast<CallingConv::ID>(CC));
 }
 
 const char *LLVMGetGC(LLVMValueRef Fn) {
   Function *F = unwrap<Function>(Fn);
-  return F->hasGC()? F->getGC().c_str() : nullptr;
+  return F->hasGC() ? F->getGC().c_str() : nullptr;
 }
 
 void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
@@ -2514,18 +2457,16 @@ void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
 
 /*--.. Operations on ifuncs ................................................--*/
 
-LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
-                                const char *Name, size_t NameLen,
-                                LLVMTypeRef Ty, unsigned AddrSpace,
-                                LLVMValueRef Resolver) {
-  return wrap(GlobalIFunc::create(unwrap(Ty), AddrSpace,
-                                  GlobalValue::ExternalLinkage,
-                                  StringRef(Name, NameLen),
-                                  unwrap<Constant>(Resolver), unwrap(M)));
+LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M, const char *Name,
+                                size_t NameLen, LLVMTypeRef Ty,
+                                unsigned AddrSpace, LLVMValueRef Resolver) {
+  return wrap(GlobalIFunc::create(
+      unwrap(Ty), AddrSpace, GlobalValue::ExternalLinkage,
+      StringRef(Name, NameLen), unwrap<Constant>(Resolver), unwrap(M)));
 }
 
-LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
-                                     const char *Name, size_t NameLen) {
+LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M, const char *Name,
+                                     size_t NameLen) {
   return wrap(unwrap(M)->getNamedIFunc(StringRef(Name, NameLen)));
 }
 
@@ -2608,7 +2549,7 @@ LLVMValueRef LLVMGetOperandBundleArgAtIndex(LLVMOperandBundleRef Bundle,
 /*--.. Operations on basic blocks ..........................................--*/
 
 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB) {
-  return wrap(static_cast<Value*>(unwrap(BB)));
+  return wrap(static_cast<Value *>(unwrap(BB)));
 }
 
 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val) {
@@ -2635,7 +2576,8 @@ unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef) {
   return unwrap<Function>(FnRef)->size();
 }
 
-void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs){
+void LLVMGetBasicBlocks(LLVMValueRef FnRef,
+                        LLVMBasicBlockRef *BasicBlocksRefs) {
   Function *Fn = unwrap<Function>(FnRef);
   for (BasicBlock &BB : *Fn)
     *BasicBlocksRefs++ = wrap(&BB);
@@ -2690,8 +2632,7 @@ void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
   CurBB->getParent()->insert(std::next(CurBB->getIterator()), ToInsert);
 }
 
-void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
-                                  LLVMBasicBlockRef BB) {
+void LLVMAppendExistingBasicBlock(LLVMValueRef Fn, LLVMBasicBlockRef BB) {
   unwrap<Function>(Fn)->insert(unwrap<Function>(Fn)->end(), unwrap(BB));
 }
 
@@ -2849,8 +2790,7 @@ void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
   unwrap<CallBase>(C)->addAttributeAtIndex(Idx, unwrap(A));
 }
 
-unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,
-                                       LLVMAttributeIndex Idx) {
+unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx) {
   auto *Call = unwrap<CallBase>(C);
   auto AS = Call->getAttributes().getAttributes(Idx);
   return AS.getNumAttributes();
@@ -3038,7 +2978,7 @@ unsigned LLVMGetNumIndices(LLVMValueRef Inst) {
   if (auto *IV = dyn_cast<InsertValueInst>(I))
     return IV->getNumIndices();
   llvm_unreachable(
-    "LLVMGetNumIndices applies only to extractvalue and insertvalue!");
+      "LLVMGetNumIndices applies only to extractvalue and insertvalue!");
 }
 
 const unsigned *LLVMGetIndices(LLVMValueRef Inst) {
@@ -3048,10 +2988,9 @@ const unsigned *LLVMGetIndices(LLVMValueRef Inst) {
   if (auto *IV = dyn_cast<InsertValueInst>(I))
     return IV->getIndices().data();
   llvm_unreachable(
-    "LLVMGetIndices applies only to extractvalue and insertvalue!");
+      "LLVMGetIndices applies only to extractvalue and insertvalue!");
 }
 
-
 /*===-- Instruction builders ----------------------------------------------===*/
 
 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C) {
@@ -3080,7 +3019,7 @@ void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block) {
 }
 
 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder) {
-   return wrap(unwrap(Builder)->GetInsertBlock());
+  return wrap(unwrap(Builder)->GetInsertBlock());
 }
 
 void LLVMClearInsertionPosition(LLVMBuilderRef Builder) {
@@ -3096,9 +3035,7 @@ void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
   unwrap(Builder)->Insert(unwrap<Instruction>(Instr), Name);
 }
 
-void LLVMDisposeBuilder(LLVMBuilderRef Builder) {
-  delete unwrap(Builder);
-}
+void LLVMDisposeBuilder(LLVMBuilderRef Builder) { delete unwrap(Builder); }
 
 /*--.. Metadata builders ...................................................--*/
 
@@ -3136,9 +3073,8 @@ void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst) {
 void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
                                     LLVMMetadataRef FPMathTag) {
 
-  unwrap(Builder)->setDefaultFPMathTag(FPMathTag
-                                       ? unwrap<MDNode>(FPMathTag)
-                                       : nullptr);
+  unwrap(Builder)->setDefaultFPMathTag(FPMathTag ? unwrap<MDNode>(FPMathTag)
+                                                 : nullptr);
 }
 
 LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder) {
@@ -3249,8 +3185,8 @@ LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
 
 LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
                                LLVMBasicBlockRef BB) {
-  return wrap(unwrap(B)->CreateCatchRet(unwrap<CatchPadInst>(CatchPad),
-                                        unwrap(BB)));
+  return wrap(
+      unwrap(B)->CreateCatchRet(unwrap<CatchPadInst>(CatchPad), unwrap(BB)));
 }
 
 LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
@@ -3311,8 +3247,8 @@ LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad) {
 }
 
 void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch) {
-  unwrap<CatchPadInst>(CatchPad)
-    ->setCatchSwitch(unwrap<CatchSwitchInst>(CatchSwitch));
+  unwrap<CatchPadInst>(CatchPad)->setCatchSwitch(
+      unwrap<CatchSwitchInst>(CatchSwitch));
 }
 
 /*--.. Funclets ...........................................................--*/
@@ -3365,18 +3301,18 @@ LLVMValueRef LLVMBuildAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
   return wrap(unwrap(B)->CreateAdd(unwrap(LHS), unwrap(RHS), Name));
 }
 
-LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
-                          const char *Name) {
+LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef B, LLVMValueRef LHS,
+                             LLVMValueRef RHS, const char *Name) {
   return wrap(unwrap(B)->CreateNSWAdd(unwrap(LHS), unwrap(RHS), Name));
 }
 
-LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
-                          const char *Name) {
+LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef B, LLVMValueRef LHS,
+                             LLVMValueRef RHS, const char *Name) {
   return wrap(unwrap(B)->CreateNUWAdd(unwrap(LHS), unwrap(RHS), Name));
 }
 
 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
-                          const char *Name) {
+                           const char *Name) {
   return wrap(unwrap(B)->CreateFAdd(unwrap(LHS), unwrap(RHS), Name));
 }
 
@@ -3385,18 +3321,18 @@ LLVMValueRef LLVMBuildSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
   return wrap(unwrap(B)->CreateSub(unwrap(LHS), unwrap(RHS), Name));
 }
 
-LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
-                          const char *Name) {
+LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef B, LLVMValueRef LHS,
+                             LLVMValueRef RHS, const char *Name) {
   return wrap(unwrap(B)->CreateNSWSub(unwrap(LHS), unwrap(RHS), Name));
 }
 
-LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
-                          const char *Name) {
+LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef B, LLVMValueRef LHS,
+                             LLVMValueRef RHS, const char *Name) {
   return wrap(unwrap(B)->CreateNUWSub(unwrap(LHS), unwrap(RHS), Name));
 }
 
 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
-                          const char *Name) {
+                           const char *Name) {
   return wrap(unwrap(B)->CreateFSub(unwrap(LHS), unwrap(RHS), Name));
 }
 
@@ -3405,18 +3341,18 @@ LLVMValueRef LLVMBuildMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
   return wrap(unwrap(B)->CreateMul(unwrap(LHS), unwrap(RHS), Name));
 }
 
-LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
-                          const char *Name) {
+LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef B, LLVMValueRef LHS,
+                             LLVMValueRef RHS, const char *Name) {
   return wrap(unwrap(B)->CreateNSWMul(unwrap(LHS), unwrap(RHS), Name));
 }
 
-LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
-                          const char *Name) {
+LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef B, LLVMValueRef LHS,
+                             LLVMValueRef RHS, const char *Name) {
   return wrap(unwrap(B)->CreateNUWMul(unwrap(LHS), unwrap(RHS), Name));
 }
 
 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
-                          const char *Name) {
+                           const char *Name) {
   return wrap(unwrap(B)->CreateFMul(unwrap(LHS), unwrap(RHS), Name));
 }
 
@@ -3490,11 +3426,11 @@ LLVMValueRef LLVMBuildXor(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,
   return wrap(unwrap(B)->CreateXor(unwrap(LHS), unwrap(RHS), Name));
 }
 
-LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
-                            LLVMValueRef LHS, LLVMValueRef RHS,
-                            const char *Name) {
-  return wrap(unwrap(B)->CreateBinOp(Instruction::BinaryOps(map_from_llvmopcode(Op)), unwrap(LHS),
-                                     unwrap(RHS), Name));
+LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS,
+                            LLVMValueRef RHS, const char *Name) {
+  return wrap(
+      unwrap(B)->CreateBinOp(Instruction::BinaryOps(map_from_llvmopcode(Op)),
+                             unwrap(LHS), unwrap(RHS), Name));
 }
 
 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name) {
@@ -3589,8 +3525,8 @@ void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint) {
 
 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty,
                              const char *Name) {
-  Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
-  Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
+  Type *ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
+  Constant *AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
   AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
   return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, nullptr,
                                       nullptr, Name));
@@ -3598,8 +3534,8 @@ LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty,
 
 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty,
                                   LLVMValueRef Val, const char *Name) {
-  Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
-  Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
+  Type *ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
+  Constant *AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
   AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
   return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, unwrap(Val),
                                       nullptr, Name));
@@ -3612,19 +3548,17 @@ LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,
                                       MaybeAlign(Align)));
 }
 
-LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B,
-                             LLVMValueRef Dst, unsigned DstAlign,
-                             LLVMValueRef Src, unsigned SrcAlign,
-                             LLVMValueRef Size) {
+LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst,
+                             unsigned DstAlign, LLVMValueRef Src,
+                             unsigned SrcAlign, LLVMValueRef Size) {
   return wrap(unwrap(B)->CreateMemCpy(unwrap(Dst), MaybeAlign(DstAlign),
                                       unwrap(Src), MaybeAlign(SrcAlign),
                                       unwrap(Size)));
 }
 
-LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B,
-                              LLVMValueRef Dst, unsigned DstAlign,
-                              LLVMValueRef Src, unsigned SrcAlign,
-                              LLVMValueRef Size) {
+LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B, LLVMValueRef Dst,
+                              unsigned DstAlign, LLVMValueRef Src,
+                              unsigned SrcAlign, LLVMValueRef Size) {
   return wrap(unwrap(B)->CreateMemMove(unwrap(Dst), MaybeAlign(DstAlign),
                                        unwrap(Src), MaybeAlign(SrcAlign),
                                        unwrap(Size)));
@@ -3656,15 +3590,20 @@ LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val,
 
 static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
   switch (Ordering) {
-    case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic;
-    case LLVMAtomicOrderingUnordered: return AtomicOrdering::Unordered;
-    case LLVMAtomicOrderingMonotonic: return AtomicOrdering::Monotonic;
-    case LLVMAtomicOrderingAcquire: return AtomicOrdering::Acquire;
-    case LLVMAtomicOrderingRelease: return AtomicOrdering::Release;
-    case LLVMAtomicOrderingAcquireRelease:
-      return AtomicOrdering::AcquireRelease;
-    case LLVMAtomicOrderingSequentiallyConsistent:
-      return AtomicOrdering::SequentiallyConsistent;
+  case LLVMAtomicOrderingNotAtomic:
+    return AtomicOrdering::NotAtomic;
+  case LLVMAtomicOrderingUnordered:
+    return AtomicOrdering::Unordered;
+  case LLVMAtomicOrderingMonotonic:
+    return AtomicOrdering::Monotonic;
+  case LLVMAtomicOrderingAcquire:
+    return AtomicOrdering::Acquire;
+  case LLVMAtomicOrderingRelease:
+    return AtomicOrdering::Release;
+  case LLVMAtomicOrderingAcquireRelease:
+    return AtomicOrdering::AcquireRelease;
+  case LLVMAtomicOrderingSequentiallyConsistent:
+    return AtomicOrdering::SequentiallyConsistent;
   }
 
   llvm_unreachable("Invalid LLVMAtomicOrdering value!");
@@ -3672,15 +3611,20 @@ static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
 
 static LLVMAtomicOrdering mapToLLVMOrdering(AtomicOrdering Ordering) {
   switch (Ordering) {
-    case AtomicOrdering::NotAtomic: return LLVMAtomicOrderingNotAtomic;
-    case AtomicOrdering::Unordered: return LLVMAtomicOrderingUnordered;
-    case AtomicOrdering::Monotonic: return LLVMAtomicOrderingMonotonic;
-    case AtomicOrdering::Acquire: return LLVMAtomicOrderingAcquire;
-    case AtomicOrdering::Release: return LLVMAtomicOrderingRelease;
-    case AtomicOrdering::AcquireRelease:
-      return LLVMAtomicOrderingAcquireRelease;
-    case AtomicOrdering::SequentiallyConsistent:
-      return LLVMAtomicOrderingSequentiallyConsistent;
+  case AtomicOrdering::NotAtomic:
+    return LLVMAtomicOrderingNotAtomic;
+  case AtomicOrdering::Unordered:
+    return LLVMAtomicOrderingUnordered;
+  case AtomicOrdering::Monotonic:
+    return LLVMAtomicOrderingMonotonic;
+  case AtomicOrdering::Acquire:
+    return LLVMAtomicOrderingAcquire;
+  case AtomicOrdering::Release:
+    return LLVMAtomicOrderingRelease;
+  case AtomicOrdering::AcquireRelease:
+    return LLVMAtomicOrderingAcquireRelease;
+  case AtomicOrdering::SequentiallyConsistent:
+    return LLVMAtomicOrderingSequentiallyConsistent;
   }
 
   llvm_unreachable("Invalid AtomicOrdering value!");
@@ -3688,21 +3632,36 @@ static LLVMAtomicOrdering mapToLLVMOrdering(AtomicOrdering Ordering) {
 
 static AtomicRMWInst::BinOp mapFromLLVMRMWBinOp(LLVMAtomicRMWBinOp BinOp) {
   switch (BinOp) {
-    case LLVMAtomicRMWBinOpXchg: return AtomicRMWInst::Xchg;
-    case LLVMAtomicRMWBinOpAdd: return AtomicRMWInst::Add;
-    case LLVMAtomicRMWBinOpSub: return AtomicRMWInst::Sub;
-    case LLVMAtomicRMWBinOpAnd: return AtomicRMWInst::And;
-    case LLVMAtomicRMWBinOpNand: return AtomicRMWInst::Nand;
-    case LLVMAtomicRMWBinOpOr: return AtomicRMWInst::Or;
-    case LLVMAtomicRMWBinOpXor: return AtomicRMWInst::Xor;
-    case LLVMAtomicRMWBinOpMax: return AtomicRMWInst::Max;
-    case LLVMAtomicRMWBinOpMin: return AtomicRMWInst::Min;
-    case LLVMAtomicRMWBinOpUMax: return AtomicRMWInst::UMax;
-    case LLVMAtomicRMWBinOpUMin: return AtomicRMWInst::UMin;
-    case LLVMAtomicRMWBinOpFAdd: return AtomicRMWInst::FAdd;
-    case LLVMAtomicRMWBinOpFSub: return AtomicRMWInst::FSub;
-    case LLVMAtomicRMWBinOpFMax: return AtomicRMWInst::FMax;
-    case LLVMAtomicRMWBinOpFMin: return AtomicRMWInst::FMin;
+  case LLVMAtomicRMWBinOpXchg:
+    return AtomicRMWInst::Xchg;
+  case LLVMAtomicRMWBinOpAdd:
+    return AtomicRMWInst::Add;
+  case LLVMAtomicRMWBinOpSub:
+    return AtomicRMWInst::Sub;
+  case LLVMAtomicRMWBinOpAnd:
+    return AtomicRMWInst::And;
+  case LLVMAtomicRMWBinOpNand:
+    return AtomicRMWInst::Nand;
+  case LLVMAtomicRMWBinOpOr:
+    return AtomicRMWInst::Or;
+  case LLVMAtomicRMWBinOpXor:
+    return AtomicRMWInst::Xor;
+  case LLVMAtomicRMWBinOpMax:
+    return AtomicRMWInst::Max;
+  case LLVMAtomicRMWBinOpMin:
+    return AtomicRMWInst::Min;
+  case LLVMAtomicRMWBinOpUMax:
+    return AtomicRMWInst::UMax;
+  case LLVMAtomicRMWBinOpUMin:
+    return AtomicRMWInst::UMin;
+  case LLVMAtomicRMWBinOpFAdd:
+    return AtomicRMWInst::FAdd;
+  case LLVMAtomicRMWBinOpFSub:
+    return AtomicRMWInst::FSub;
+  case LLVMAtomicRMWBinOpFMax:
+    return AtomicRMWInst::FMax;
+  case LLVMAtomicRMWBinOpFMin:
+    return AtomicRMWInst::FMin;
   }
 
   llvm_unreachable("Invalid LLVMAtomicRMWBinOp value!");
@@ -3710,22 +3669,38 @@ static AtomicRMWInst::BinOp mapFromLLVMRMWBinOp(LLVMAtomicRMWBinOp BinOp) {
 
 static LLVMAtomicRMWBinOp mapToLLVMRMWBinOp(AtomicRMWInst::BinOp BinOp) {
   switch (BinOp) {
-    case AtomicRMWInst::Xchg: return LLVMAtomicRMWBinOpXchg;
-    case AtomicRMWInst::Add: return LLVMAtomicRMWBinOpAdd;
-    case AtomicRMWInst::Sub: return LLVMAtomicRMWBinOpSub;
-    case AtomicRMWInst::And: return LLVMAtomicRMWBinOpAnd;
-    case AtomicRMWInst::Nand: return LLVMAtomicRMWBinOpNand;
-    case AtomicRMWInst::Or: return LLVMAtomicRMWBinOpOr;
-    case AtomicRMWInst::Xor: return LLVMAtomicRMWBinOpXor;
-    case AtomicRMWInst::Max: return LLVMAtomicRMWBinOpMax;
-    case AtomicRMWInst::Min: return LLVMAtomicRMWBinOpMin;
-    case AtomicRMWInst::UMax: return LLVMAtomicRMWBinOpUMax;
-    case AtomicRMWInst::UMin: return LLVMAtomicRMWBinOpUMin;
-    case AtomicRMWInst::FAdd: return LLVMAtomicRMWBinOpFAdd;
-    case AtomicRMWInst::FSub: return LLVMAtomicRMWBinOpFSub;
-    case AtomicRMWInst::FMax: return LLVMAtomicRMWBinOpFMax;
-    case AtomicRMWInst::FMin: return LLVMAtomicRMWBinOpFMin;
-    default: break;
+  case AtomicRMWInst::Xchg:
+    return LLVMAtomicRMWBinOpXchg;
+  case AtomicRMWInst::Add:
+    return LLVMAtomicRMWBinOpAdd;
+  case AtomicRMWInst::Sub:
+    return LLVMAtomicRMWBinOpSub;
+  case AtomicRMWInst::And:
+    return LLVMAtomicRMWBinOpAnd;
+  case AtomicRMWInst::Nand:
+    return LLVMAtomicRMWBinOpNand;
+  case AtomicRMWInst::Or:
+    return LLVMAtomicRMWBinOpOr;
+  case AtomicRMWInst::Xor:
+    return LLVMAtomicRMWBinOpXor;
+  case AtomicRMWInst::Max:
+    return LLVMAtomicRMWBinOpMax;
+  case AtomicRMWInst::Min:
+    return LLVMAtomicRMWBinOpMin;
+  case AtomicRMWInst::UMax:
+    return LLVMAtomicRMWBinOpUMax;
+  case AtomicRMWInst::UMin:
+    return LLVMAtomicRMWBinOpUMin;
+  case AtomicRMWInst::FAdd:
+    return LLVMAtomicRMWBinOpFAdd;
+  case AtomicRMWInst::FSub:
+    return LLVMAtomicRMWBinOpFSub;
+  case AtomicRMWInst::FMax:
+    return LLVMAtomicRMWBinOpFMax;
+  case AtomicRMWInst::FMin:
+    return LLVMAtomicRMWBinOpFMin;
+  default:
+    break;
   }
 
   llvm_unreachable("Invalid AtomicRMWBinOp value!");
@@ -3735,11 +3710,9 @@ static LLVMAtomicRMWBinOp mapToLLVMRMWBinOp(AtomicRMWInst::BinOp BinOp) {
 // "syncscope"?
 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering Ordering,
                             LLVMBool isSingleThread, const char *Name) {
-  return wrap(
-    unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering),
-                           isSingleThread ? SyncScope::SingleThread
-                                          : SyncScope::System,
-                           Name));
+  return wrap(unwrap(B)->CreateFence(
+      mapFromLLVMOrdering(Ordering),
+      isSingleThread ? SyncScope::SingleThread : SyncScope::System, Name));
 }
 
 LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
@@ -3903,31 +3876,33 @@ LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef B, LLVMValueRef Val,
 
 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef B, LLVMValueRef Val,
                                     LLVMTypeRef DestTy, const char *Name) {
-  return wrap(unwrap(B)->CreateAddrSpaceCast(unwrap(Val), unwrap(DestTy), Name));
+  return wrap(
+      unwrap(B)->CreateAddrSpaceCast(unwrap(Val), unwrap(DestTy), Name));
 }
 
 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val,
                                     LLVMTypeRef DestTy, const char *Name) {
-  return wrap(unwrap(B)->CreateZExtOrBitCast(unwrap(Val), unwrap(DestTy),
-                                             Name));
+  return wrap(
+      unwrap(B)->CreateZExtOrBitCast(unwrap(Val), unwrap(DestTy), Name));
 }
 
 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val,
                                     LLVMTypeRef DestTy, const char *Name) {
-  return wrap(unwrap(B)->CreateSExtOrBitCast(unwrap(Val), unwrap(DestTy),
-                                             Name));
+  return wrap(
+      unwrap(B)->CreateSExtOrBitCast(unwrap(Val), unwrap(DestTy), Name));
 }
 
 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef B, LLVMValueRef Val,
                                      LLVMTypeRef DestTy, const char *Name) {
-  return wrap(unwrap(B)->CreateTruncOrBitCast(unwrap(Val), unwrap(DestTy),
-                                              Name));
+  return wrap(
+      unwrap(B)->CreateTruncOrBitCast(unwrap(Val), unwrap(DestTy), Name));
 }
 
 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
                            LLVMTypeRef DestTy, const char *Name) {
-  return wrap(unwrap(B)->CreateCast(Instruction::CastOps(map_from_llvmopcode(Op)), unwrap(Val),
-                                    unwrap(DestTy), Name));
+  return wrap(
+      unwrap(B)->CreateCast(Instruction::CastOps(map_from_llvmopcode(Op)),
+                            unwrap(Val), unwrap(DestTy), Name));
 }
 
 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef B, LLVMValueRef Val,
@@ -3945,7 +3920,7 @@ LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef B, LLVMValueRef Val,
 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef B, LLVMValueRef Val,
                               LLVMTypeRef DestTy, const char *Name) {
   return wrap(unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy),
-                                       /*isSigned*/true, Name));
+                                       /*isSigned*/ true, Name));
 }
 
 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef B, LLVMValueRef Val,
@@ -4007,19 +3982,19 @@ LLVMBuildCallWithOperandBundles(LLVMBuilderRef B, LLVMTypeRef Ty,
 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef B, LLVMValueRef If,
                              LLVMValueRef Then, LLVMValueRef Else,
                              const char *Name) {
-  return wrap(unwrap(B)->CreateSelect(unwrap(If), unwrap(Then), unwrap(Else),
-                                      Name));
+  return wrap(
+      unwrap(B)->CreateSelect(unwrap(If), unwrap(Then), unwrap(Else), Name));
 }
 
-LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef B, LLVMValueRef List,
-                            LLVMTypeRef Ty, const char *Name) {
+LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef B, LLVMValueRef List, LLVMTypeRef Ty,
+                            const char *Name) {
   return wrap(unwrap(B)->CreateVAArg(unwrap(List), unwrap(Ty), Name));
 }
 
 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef B, LLVMValueRef VecVal,
-                                      LLVMValueRef Index, const char *Name) {
-  return wrap(unwrap(B)->CreateExtractElement(unwrap(VecVal), unwrap(Index),
-                                              Name));
+                                     LLVMValueRef Index, const char *Name) {
+  return wrap(
+      unwrap(B)->CreateExtractElement(unwrap(VecVal), unwrap(Index), Name));
 }
 
 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef B, LLVMValueRef VecVal,
@@ -4066,14 +4041,14 @@ LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef B, LLVMValueRef Val,
 LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef B, LLVMTypeRef ElemTy,
                                LLVMValueRef LHS, LLVMValueRef RHS,
                                const char *Name) {
-  return wrap(unwrap(B)->CreatePtrDiff(unwrap(ElemTy), unwrap(LHS),
-                                       unwrap(RHS), Name));
+  return wrap(
+      unwrap(B)->CreatePtrDiff(unwrap(ElemTy), unwrap(LHS), unwrap(RHS), Name));
 }
 
-LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,LLVMAtomicRMWBinOp op,
-                               LLVMValueRef PTR, LLVMValueRef Val,
-                               LLVMAtomicOrdering ordering,
-                               LLVMBool singleThread) {
+LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
+                                LLVMValueRef PTR, LLVMValueRef Val,
+                                LLVMAtomicOrdering ordering,
+                                LLVMBool singleThread) {
   AtomicRMWInst::BinOp intop = mapFromLLVMRMWBinOp(op);
   return wrap(unwrap(B)->CreateAtomicRMW(
       intop, unwrap(PTR), unwrap(Val), MaybeAlign(),
@@ -4120,7 +4095,7 @@ LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst) {
   else if (LoadInst *LI = dyn_cast<LoadInst>(P))
     return LI->getSyncScopeID() == SyncScope::SingleThread;
   return cast<AtomicCmpXchgInst>(P)->getSyncScopeID() ==
-             SyncScope::SingleThread;
+         SyncScope::SingleThread;
 }
 
 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool NewValue) {
@@ -4138,7 +4113,7 @@ void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool NewValue) {
   return cast<AtomicCmpXchgInst>(P)->setSyncScopeID(SSID);
 }
 
-LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst)  {
+LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst) {
   Value *P = unwrap(CmpXchgInst);
   return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getSuccessOrdering());
 }
@@ -4151,7 +4126,7 @@ void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
   return cast<AtomicCmpXchgInst>(P)->setSuccessOrdering(O);
 }
 
-LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst)  {
+LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst) {
   Value *P = unwrap(CmpXchgInst);
   return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getFailureOrdering());
 }
@@ -4171,17 +4146,12 @@ LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M) {
   return reinterpret_cast<LLVMModuleProviderRef>(M);
 }
 
-void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP) {
-  delete unwrap(MP);
-}
-
+void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP) { delete unwrap(MP); }
 
 /*===-- Memory buffers ----------------------------------------------------===*/
 
 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(
-    const char *Path,
-    LLVMMemoryBufferRef *OutMemBuf,
-    char **OutMessage) {
+    const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage) {
 
   ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr = MemoryBuffer::getFile(Path);
   if (std::error_code EC = MBOrErr.getError()) {
@@ -4204,24 +4174,21 @@ LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
 }
 
 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(
-    const char *InputData,
-    size_t InputDataLength,
-    const char *BufferName,
+    const char *InputData, size_t InputDataLength, const char *BufferName,
     LLVMBool RequiresNullTerminator) {
 
   return wrap(MemoryBuffer::getMemBuffer(StringRef(InputData, InputDataLength),
                                          StringRef(BufferName),
-                                         RequiresNullTerminator).release());
+                                         RequiresNullTerminator)
+                  .release());
 }
 
 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(
-    const char *InputData,
-    size_t InputDataLength,
-    const char *BufferName) {
+    const char *InputData, size_t InputDataLength, const char *BufferName) {
 
-  return wrap(
-      MemoryBuffer::getMemBufferCopy(StringRef(InputData, InputDataLength),
-                                     StringRef(BufferName)).release());
+  return wrap(MemoryBuffer::getMemBufferCopy(
+                  StringRef(InputData, InputDataLength), StringRef(BufferName))
+                  .release());
 }
 
 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf) {
@@ -4248,7 +4215,7 @@ LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M) {
 
 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef P) {
   return LLVMCreateFunctionPassManagerForModule(
-                                            reinterpret_cast<LLVMModuleRef>(P));
+      reinterpret_cast<LLVMModuleRef>(P));
 }
 
 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M) {
@@ -4267,19 +4234,12 @@ LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM) {
   return unwrap<legacy::FunctionPassManager>(FPM)->doFinalization();
 }
 
-void LLVMDisposePassManager(LLVMPassManagerRef PM) {
-  delete unwrap(PM);
-}
+void LLVMDisposePassManager(LLVMPassManagerRef PM) { delete unwrap(PM); }
 
 /*===-- Threading ------------------------------------------------------===*/
 
-LLVMBool LLVMStartMultithreaded() {
-  return LLVMIsMultithreaded();
-}
+LLVMBool LLVMStartMultithreaded() { return LLVMIsMultithreaded(); }
 
-void LLVMStopMultithreaded() {
-}
+void LLVMStopMultithreaded() {}
 
-LLVMBool LLVMIsMultithreaded() {
-  return llvm_is_multithreaded();
-}
+LLVMBool LLVMIsMultithreaded() { return llvm_is_multithreaded(); }
diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h
index 3393ec6f51cc03..f9ad07dd8605a1 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -12,6 +12,9 @@
 
 #include "mlir-c/IR.h"
 #include "mlir-c/Support.h"
+#include "llvm-c/Comdat.h"
+#include "llvm-c/Core.h"
+#include "llvm-c/DebugInfo.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -101,15 +104,15 @@ mlirLLVMStructTypeSetBody(MlirType structType, intptr_t nFieldTypes,
 
 /// Creates a LLVM CConv attribute.
 MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx,
-                                                      uint64_t cconv);
+                                                      LLVMCallConv cconv);
 
 /// Creates a LLVM Comdat attribute.
-MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx,
-                                                       uint64_t comdat);
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirLLVMComdatAttrGet(MlirContext ctx, LLVMComdatSelectionKind comdat);
 
 /// Creates a LLVM Linkage attribute.
-MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx,
-                                                        uint64_t linkage);
+MLIR_CAPI_EXPORTED MlirAttribute
+mlirLLVMLinkageAttrGet(MlirContext ctx, LLVMLinkage linkage);
 
 /// Creates a LLVM DINullType attribute.
 MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx);
@@ -126,7 +129,7 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIExpressionAttrGet(
 /// Creates a LLVM DIBasicType attribute.
 MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIBasicTypeAttrGet(
     MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits,
-    unsigned int encoding);
+    LLVMDWARFTypeEncoding encoding);
 
 /// Creates a LLVM DICompositeType attribute.
 MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompositeTypeAttrGet(
@@ -154,7 +157,7 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx,
 MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompileUnitAttrGet(
     MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage,
     MlirAttribute file, MlirAttribute producer, bool isOptimized,
-    uint64_t emissionKind);
+    LLVMDWARFEmissionKind emissionKind);
 
 /// Creates a LLVM DIFlags attribute.
 MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx,
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index 8c8902e95e88fb..2d99b86b2cd1e1 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -14,6 +14,7 @@
 #include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/Dialect/LLVMIR/LLVMTypes.h"
+#include "llvm-c/Core.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/SmallVectorExtras.h"
 
@@ -144,7 +145,8 @@ MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx) {
 MlirAttribute mlirLLVMDIBasicTypeAttrGet(MlirContext ctx, unsigned int tag,
                                          MlirAttribute name,
                                          uint64_t sizeInBits,
-                                         unsigned int encoding) {
+                                         LLVMDWARFTypeEncoding encoding) {
+
   return wrap(DIBasicTypeAttr::get(
       unwrap(ctx), tag, cast<StringAttr>(unwrap(name)), sizeInBits, encoding));
 }
@@ -183,15 +185,16 @@ mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType) {
   return wrap(cast<DIDerivedTypeAttr>(unwrap(diDerivedType)).getBaseType());
 }
 
-MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx, uint64_t cconv) {
+MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx, LLVMCallConv cconv) {
   return wrap(CConvAttr::get(unwrap(ctx), CConv(cconv)));
 }
 
-MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx, uint64_t comdat) {
+MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx,
+                                    LLVMComdatSelectionKind comdat) {
   return wrap(ComdatAttr::get(unwrap(ctx), comdat::Comdat(comdat)));
 }
 
-MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx, uint64_t linkage) {
+MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx, LLVMLinkage linkage) {
   return wrap(LinkageAttr::get(unwrap(ctx), linkage::Linkage(linkage)));
 }
 
@@ -206,7 +209,7 @@ MlirAttribute mlirLLVMDICompileUnitAttrGet(MlirContext ctx, MlirAttribute id,
                                            MlirAttribute file,
                                            MlirAttribute producer,
                                            bool isOptimized,
-                                           uint64_t emissionKind) {
+                                           LLVMDWARFEmissionKind emissionKind) {
   return wrap(DICompileUnitAttr::get(
       unwrap(ctx), cast<DistinctAttr>(unwrap(id)), sourceLanguage,
       cast<DIFileAttr>(unwrap(file)), cast<StringAttr>(unwrap(producer)),
diff --git a/mlir/test/CAPI/llvm.c b/mlir/test/CAPI/llvm.c
index 82e5dd5d1a8019..cb4407b1be8ab1 100644
--- a/mlir/test/CAPI/llvm.c
+++ b/mlir/test/CAPI/llvm.c
@@ -14,6 +14,8 @@
 #include "mlir-c/BuiltinTypes.h"
 #include "mlir-c/IR.h"
 #include "mlir-c/Support.h"
+#include "llvm-c/Core.h"
+#include "llvm-c/DebugInfo.h"
 
 #include <assert.h>
 #include <inttypes.h>
@@ -231,11 +233,11 @@ static void testLLVMAttributes(MlirContext ctx) {
   fprintf(stderr, "testLLVMAttributes\n");
 
   // CHECK: #llvm.linkage<internal>
-  mlirAttributeDump(mlirLLVMLinkageAttrGet(ctx, 0x1));
+  mlirAttributeDump(mlirLLVMLinkageAttrGet(ctx, LLVMInternalLinkage));
   // CHECK: #llvm.cconv<ccc>
-  mlirAttributeDump(mlirLLVMCConvAttrGet(ctx, 0x0));
+  mlirAttributeDump(mlirLLVMCConvAttrGet(ctx, LLVMCCallConv));
   // CHECK: #llvm<comdat any>
-  mlirAttributeDump(mlirLLVMComdatAttrGet(ctx, 0x0));
+  mlirAttributeDump(mlirLLVMComdatAttrGet(ctx, LLVMAnyComdatSelectionKind));
 }
 
 // CHECK-LABEL: testDebugInfoAttributes
@@ -250,9 +252,11 @@ static void testDebugInfoAttributes(MlirContext ctx) {
 
   // CHECK: #llvm.di_null_type
   mlirAttributeDump(mlirLLVMDINullTypeAttrGet(ctx));
+
   // CHECK: #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits =
-  // 64, encoding = DW_ATE_signed>
-  MlirAttribute di_type = mlirLLVMDIBasicTypeAttrGet(ctx, 0, foo, 64, 0x5);
+  // CHECK-SAME: 64, encoding = DW_ATE_signed>
+  MlirAttribute di_type =
+      mlirLLVMDIBasicTypeAttrGet(ctx, 0, foo, 64, LLVMDWARFSignedTypeEncoding);
   mlirAttributeDump(di_type);
 
   MlirAttribute file = mlirLLVMDIFileAttrGet(ctx, foo, bar);
@@ -261,102 +265,63 @@ static void testDebugInfoAttributes(MlirContext ctx) {
   mlirAttributeDump(file);
 
   MlirAttribute compile_unit =
-      mlirLLVMDICompileUnitAttrGet(ctx, id, 0x1C, file, foo, false, 0x1);
+      mlirLLVMDICompileUnitAttrGet(ctx, id, LLVMDWARFSourceLanguageC99, file,
+                                   foo, false, LLVMDWARFEmissionFull);
 
-  // CHECK: #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
-  // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
-  // false, emissionKind = Full>
+  // CHECK: #llvm.di_compile_unit<{{.*}}>
   mlirAttributeDump(compile_unit);
 
   MlirAttribute di_module = mlirLLVMDIModuleAttrGet(
       ctx, file, compile_unit, foo,
       mlirStringAttrGet(ctx, mlirStringRefCreateFromCString("")), bar, foo, 1,
       0);
-  // CHECK: #llvm.di_module<file = <"foo" in "bar">, scope =
-  // #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
-  // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
-  // false, emissionKind = Full>, name = "foo", configMacros = "", includePath =
-  // "bar", apinotes = "foo", line = 1>
+  // CHECK: #llvm.di_module<{{.*}}>
   mlirAttributeDump(di_module);
 
-  // CHECK: #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
-  // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
-  // false, emissionKind = Full>
+  // CHECK: #llvm.di_compile_unit<{{.*}}>
   mlirAttributeDump(mlirLLVMDIModuleAttrGetScope(di_module));
 
   // CHECK: 1 : i32
   mlirAttributeDump(mlirLLVMDIFlagsAttrGet(ctx, 0x1));
 
-  // CHECK: #llvm.di_lexical_block<scope = #llvm.di_compile_unit<id =
-  // distinct[0]<"foo">, sourceLanguage = DW_LANG_Rust, file = <"foo" in "bar">,
-  // producer = "foo", isOptimized = false, emissionKind = Full>, file = <"foo"
-  // in "bar">, line = 1, column = 2>
+  // CHECK: #llvm.di_lexical_block<{{.*}}>
   mlirAttributeDump(
       mlirLLVMDILexicalBlockAttrGet(ctx, compile_unit, file, 1, 2));
 
-  // CHECK: #llvm.di_lexical_block_file<scope = #llvm.di_compile_unit<id =
-  // distinct[0]<"foo">, sourceLanguage = DW_LANG_Rust, file = <"foo" in "bar">,
-  // producer = "foo", isOptimized = false, emissionKind = Full>, file = <"foo"
-  // in "bar">, discriminator = 3>
+  // CHECK: #llvm.di_lexical_block_file<{{.*}}>
   mlirAttributeDump(
       mlirLLVMDILexicalBlockFileAttrGet(ctx, compile_unit, file, 3));
 
-  // CHECK: #llvm.di_local_variable<scope = #llvm.di_compile_unit<id =
-  // distinct[0]<"foo">, sourceLanguage = DW_LANG_Rust, file = <"foo" in "bar">,
-  // producer = "foo", isOptimized = false, emissionKind = Full>, name = "foo",
-  // file = <"foo" in "bar">, line = 1, alignInBits = 8, type =
-  // #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits = 64,
-  // encoding = DW_ATE_signed>>
+  // CHECK: #llvm.di_local_variable<{{.*}}>
   mlirAttributeDump(mlirLLVMDILocalVariableAttrGet(ctx, compile_unit, foo, file,
                                                    1, 0, 8, di_type));
-  // CHECK: #llvm.di_derived_type<tag = DW_TAG_null, name = "bar", baseType =
-  // #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits = 64,
-  // encoding = DW_ATE_signed>, sizeInBits = 64, alignInBits = 8>
+  // CHECK: #llvm.di_derived_type<{{.*}}>
   mlirAttributeDump(
       mlirLLVMDIDerivedTypeAttrGet(ctx, 0, bar, di_type, 64, 8, 0));
 
-  // CHECK: #llvm.di_composite_type<tag = DW_TAG_null, name = "foo", file =
-  // <"foo" in "bar">, line = 1, scope = #llvm.di_compile_unit<id =
-  // distinct[0]<"foo">, sourceLanguage = DW_LANG_Rust, file = <"foo" in "bar">,
-  // producer = "foo", isOptimized = false, emissionKind = Full>, baseType =
-  // #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits = 64,
-  // encoding = DW_ATE_signed>, sizeInBits = 64, alignInBits = 8, elements =
-  // #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits = 64,
-  // encoding = DW_ATE_signed>>
+  // CHECK: #llvm.di_composite_type<{{.*}}>
   mlirAttributeDump(mlirLLVMDICompositeTypeAttrGet(
       ctx, 0, foo, file, 1, compile_unit, di_type, 0, 64, 8, 1, &di_type));
 
   MlirAttribute subroutine_type =
       mlirLLVMDISubroutineTypeAttrGet(ctx, 0x0, 1, &di_type);
 
-  // CHECK: #llvm.di_subroutine_type<types = #llvm.di_basic_type<tag =
-  // DW_TAG_null, name = "foo", sizeInBits = 64, encoding = DW_ATE_signed>>
+  // CHECK: #llvm.di_subroutine_type<{{.*}}>
   mlirAttributeDump(subroutine_type);
 
   MlirAttribute di_subprogram =
       mlirLLVMDISubprogramAttrGet(ctx, id, compile_unit, compile_unit, foo, bar,
                                   file, 1, 2, 0, subroutine_type);
-  // CHECK: #llvm.di_subprogram<id = distinct[0]<"foo">, compileUnit = <id =
-  // distinct[0]<"foo">, sourceLanguage = DW_LANG_Rust, file = <"foo" in "bar">,
-  // producer = "foo", isOptimized = false, emissionKind = Full>, scope =
-  // #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
-  // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
-  // false, emissionKind = Full>, name = "foo", linkageName = "bar", file =
-  // <"foo" in "bar">, line = 1, scopeLine = 2, subprogramFlags = , type =
-  // <types = #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits =
-  // 64, encoding = DW_ATE_signed>>>
+  // CHECK: #llvm.di_subprogram<{{.*}}>
   mlirAttributeDump(di_subprogram);
 
-  // CHECK: #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
-  // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
-  // false, emissionKind = Full>
+  // CHECK: #llvm.di_compile_unit<{{.*}}>
   mlirAttributeDump(mlirLLVMDISubprogramAttrGetScope(di_subprogram));
 
-  // CHECK: #llvm.di_file<"foo" in "bar">
+  // CHECK: #llvm.di_file<{{.*}}>
   mlirAttributeDump(mlirLLVMDISubprogramAttrGetFile(di_subprogram));
 
-  // CHECK: #llvm.di_subroutine_type<types = #llvm.di_basic_type<tag =
-  // DW_TAG_null, name = "foo", sizeInBits = 64, encoding = DW_ATE_signed>>
+  // CHECK: #llvm.di_subroutine_type<{{.*}}>
   mlirAttributeDump(mlirLLVMDISubprogramAttrGetType(di_subprogram));
 
   MlirAttribute expression_elem =



More information about the Mlir-commits mailing list