Skip to content

Commit

Permalink
Integrate LLVM at llvm/llvm-project@9d24f9437944
Browse files Browse the repository at this point in the history
Updates LLVM usage to match
[9d24f9437944](llvm/llvm-project@9d24f9437944)

PiperOrigin-RevId: 728265165
  • Loading branch information
HEIR Team authored and copybara-github committed Feb 18, 2025
1 parent 8684abf commit 479baf4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 65 deletions.
2 changes: 1 addition & 1 deletion bazel/import_llvm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load(

def import_llvm(name):
"""Imports LLVM."""
LLVM_COMMIT = "34cf04b59b8d94c8eeb9929ec2cd3d63631af86f"
LLVM_COMMIT = "9d24f943794420e512512eb9329341355e9289f8"

new_git_repository(
name = name,
Expand Down
12 changes: 6 additions & 6 deletions lib/Pipelines/PipelineRegistration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ namespace mlir::heir {
void tosaToLinalg(OpPassManager &manager) {
manager.addNestedPass<FuncOp>(createTosaToLinalgNamed());
manager.addNestedPass<FuncOp>(createTosaToLinalg());
manager.addNestedPass<FuncOp>(createTosaToArith(true, false));
manager.addNestedPass<FuncOp>(createTosaToTensor());
manager.addNestedPass<FuncOp>(createTosaToArithPass({true, false}));
manager.addNestedPass<FuncOp>(createTosaToTensorPass());
manager.addPass(bufferization::createEmptyTensorToAllocTensorPass());
manager.addNestedPass<FuncOp>(createLinalgDetensorizePass());
manager.addPass(createConvertTensorToLinalgPass());
Expand All @@ -60,7 +60,7 @@ void oneShotBufferize(OpPassManager &manager) {
manager.addPass(bufferization::createBufferDeallocationSimplificationPass());
manager.addPass(bufferization::createLowerDeallocationsPass());
manager.addPass(createCSEPass());
manager.addPass(mlir::createBufferizationToMemRefPass());
manager.addPass(mlir::createConvertBufferizationToMemRefPass());
manager.addPass(createCanonicalizerPass());
}

Expand Down Expand Up @@ -114,7 +114,7 @@ void polynomialToLLVMPipelineBuilder(OpPassManager &manager) {
// But lowering to loops also re-introduces affine.apply, so re-lower that
manager.addNestedPass<FuncOp>(createConvertLinalgToLoopsPass());
manager.addPass(createLowerAffinePass());
manager.addPass(createBufferizationToMemRefPass());
manager.addPass(createConvertBufferizationToMemRefPass());

// Cleanup
manager.addPass(createCanonicalizerPass());
Expand All @@ -124,7 +124,7 @@ void polynomialToLLVMPipelineBuilder(OpPassManager &manager) {

// ToLLVM
manager.addPass(arith::createArithExpandOpsPass());
manager.addPass(createConvertSCFToCFPass());
manager.addPass(createSCFToControlFlowPass());
manager.addNestedPass<FuncOp>(memref::createExpandStridedMetadataPass());
manager.addPass(createConvertToLLVMPass());

Expand Down Expand Up @@ -161,7 +161,7 @@ void basicMLIRToLLVMPipelineBuilder(OpPassManager &manager) {

// ToLLVM
manager.addPass(arith::createArithExpandOpsPass());
manager.addPass(createConvertSCFToCFPass());
manager.addPass(createSCFToControlFlowPass());
manager.addNestedPass<FuncOp>(memref::createExpandStridedMetadataPass());
manager.addPass(createConvertToLLVMPass());

Expand Down
77 changes: 20 additions & 57 deletions patches/llvm.patch
Original file line number Diff line number Diff line change
@@ -1,61 +1,24 @@
Auto generated patch. Do not edit or delete it, even if empty.
diff -ruN --strip-trailing-cr a/libcxx/src/iostream.cpp b/libcxx/src/iostream.cpp
--- a/libcxx/src/iostream.cpp
+++ b/libcxx/src/iostream.cpp
@@ -18,8 +18,8 @@
diff -ruN --strip-trailing-cr a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl
--- a/utils/bazel/llvm-project-overlay/llvm/config.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl
@@ -47,6 +47,7 @@

template <class StreamT, class BufferT>
union stream_data {
- stream_data() {}
- ~stream_data() {}
+ constexpr stream_data() {}
+ constexpr ~stream_data() {}
struct {
// The stream has to be the first element, since that's referenced by the stream declarations in <iostream>
StreamT stream;
@@ -38,13 +38,19 @@
#define CHAR_MANGLING_wchar_t "_W"
#define CHAR_MANGLING(CharT) CHAR_MANGLING_##CharT
linux_defines = posix_defines + [
"_GNU_SOURCE",
+ "HAVE_GETAUXVAL=1",
"HAVE_MALLINFO=1",
"HAVE_SBRK=1",
"HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC=1",
diff -ruN --strip-trailing-cr a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
--- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
+++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
@@ -296,7 +296,7 @@

+#ifdef _LIBCPP_COMPILER_CLANG_BASED
+# define STRING_DATA_CONSTINIT constinit
+#else
+# define STRING_DATA_CONSTINIT
+#endif
+
#ifdef _LIBCPP_ABI_MICROSOFT
# define STREAM(StreamT, BufferT, CharT, var) \
- stream_data<StreamT<CharT>, BufferT<CharT>> var __asm__( \
+ STRING_DATA_CONSTINIT stream_data<StreamT<CharT>, BufferT<CharT>> var __asm__( \
"?" #var "@" ABI_NAMESPACE_STR "@std@@3V?$" #StreamT \
"@" CHAR_MANGLING(CharT) "U?$char_traits@" CHAR_MANGLING(CharT) "@" ABI_NAMESPACE_STR "@std@@@12@A")
#else
-# define STREAM(StreamT, BufferT, CharT, var) stream_data<StreamT<CharT>, BufferT<CharT>> var
+# define STREAM(StreamT, BufferT, CharT, var) STRING_DATA_CONSTINIT stream_data<StreamT<CharT>, BufferT<CharT>> var
#endif
/* HAVE_PROC_PID_RUSAGE defined in Bazel */

// These definitions and the declarations in <iostream> technically cause ODR violations, since they have different
diff -ruN --strip-trailing-cr a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/ios_Init.global.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/ios_Init.global.pass.cpp
--- a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/ios_Init.global.pass.cpp
+++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/ios_Init.global.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <iostream>
+
+// FIXME: Remove after issue https://github.com/llvm/llvm-project/issues/127348 resolved.
+extern "C" const char* __asan_default_options() { return "check_initialization_order=true:strict_init_order=true"; }
+
+// Test that ios used from globals constructors doesn't trigger Asan initialization-order-fiasco.
+
+struct Global {
+ Global() { std::cout << "Hello!"; }
+} global;
+
+int main(int, char**) { return 0; }
-#define HAVE_GETAUXVAL 1
+/* HAVE_GETAUXVAL defined in Bazel */

/* Directly provide definitions here behind platform preprocessor definitions.
* The preprocessor conditions are sufficient to handle all of the configuration
2 changes: 1 addition & 1 deletion tools/heir-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int main(int argc, char **argv) {
registerPass(
[]() -> std::unique_ptr<Pass> { return createConvertFuncToLLVMPass(); });
registerPass(
[]() -> std::unique_ptr<Pass> { return createConvertSCFToCFPass(); });
[]() -> std::unique_ptr<Pass> { return createSCFToControlFlowPass(); });
registerPass([]() -> std::unique_ptr<Pass> {
return createFinalizeMemRefToLLVMConversionPass();
});
Expand Down

0 comments on commit 479baf4

Please sign in to comment.