amd/llvm: Reorder LLVM headers
authorJames Park <16356-jpark37@users.noreply.gitlab.freedesktop.org>
Wed, 5 Aug 2020 16:59:25 +0000 (09:59 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 5 Aug 2020 17:15:18 +0000 (17:15 +0000)
LLVM uses __declspec(restrict) which breaks because Mesa define restrict
as __restrict. Move the LLVM headerse up to dodge the macro.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6180>

src/amd/llvm/ac_llvm_helper.cpp

index 779085b7e7893666d4b70157c88c6e08efd2d174..1174b34b638383258f8a932d4bbeab2469318675 100644 (file)
 
 #include <cstring>
 
-#include "ac_binary.h"
-#include "ac_llvm_util.h"
-#include "ac_llvm_build.h"
-
-#include "util/macros.h"
-
 #include <llvm-c/Core.h>
 #include <llvm/Target/TargetMachine.h>
 #include <llvm/IR/IRBuilder.h>
 
 #include <llvm/IR/LegacyPassManager.h>
 
+/* DO NOT REORDER THE HEADERS
+ * The LLVM headers need to all be included before any Mesa header,
+ * as they use the `restrict` keyword in ways that are incompatible
+ * with our #define in include/c99_compat.h
+ */
+
+#include "ac_binary.h"
+#include "ac_llvm_util.h"
+#include "ac_llvm_build.h"
+
+#include "util/macros.h"
+
 void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
 {
    llvm::Argument *A = llvm::unwrap<llvm::Argument>(val);