From 12af9c833797b579cde97b2378cb3a3153edbed4 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Wed, 13 Dec 2023 13:32:03 -0800 Subject: [RISCV] Extract a utility for computing bounds on VLMAX [nfc] Simplifying an upcoming change... --- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 31 +++++++++++++++++++---------- llvm/lib/Target/RISCV/RISCVISelLowering.h | 8 +++++++- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index c0462dc..a75bbb4 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -2624,6 +2624,25 @@ SDValue RISCVTargetLowering::computeVLMax(MVT VecVT, const SDLoc &DL, VecVT.getVectorElementCount()); } +std::pair +RISCVTargetLowering::computeVLMAXBounds(MVT VecVT, + const RISCVSubtarget &Subtarget) { + assert(VecVT.isScalableVector() && "Expected scalable vector"); + + unsigned EltSize = VecVT.getScalarSizeInBits(); + unsigned MinSize = VecVT.getSizeInBits().getKnownMinValue(); + + unsigned VectorBitsMax = Subtarget.getRealMaxVLen(); + unsigned MaxVLMAX = + RISCVTargetLowering::computeVLMAX(VectorBitsMax, EltSize, MinSize); + + unsigned VectorBitsMin = Subtarget.getRealMinVLen(); + unsigned MinVLMAX = + RISCVTargetLowering::computeVLMAX(VectorBitsMin, EltSize, MinSize); + + return std::make_pair(MinVLMAX, MaxVLMAX); +} + // The state of RVV BUILD_VECTOR and VECTOR_SHUFFLE lowering is that very few // of either is (currently) supported. This can get us into an infinite loop // where we try to lower a BUILD_VECTOR as a VECTOR_SHUFFLE as a BUILD_VECTOR @@ -8123,16 +8142,8 @@ static SDValue lowerVectorIntrinsicScalars(SDValue Op, SelectionDAG &DAG, // Optimize for constant AVL if (isa(AVL)) { - unsigned EltSize = VT.getScalarSizeInBits(); - unsigned MinSize = VT.getSizeInBits().getKnownMinValue(); - - unsigned VectorBitsMax = Subtarget.getRealMaxVLen(); - unsigned MaxVLMAX = - RISCVTargetLowering::computeVLMAX(VectorBitsMax, EltSize, MinSize); - - unsigned VectorBitsMin = Subtarget.getRealMinVLen(); - unsigned MinVLMAX = - RISCVTargetLowering::computeVLMAX(VectorBitsMin, EltSize, MinSize); + const auto [MinVLMAX, MaxVLMAX] = + RISCVTargetLowering::computeVLMAXBounds(VT, Subtarget); uint64_t AVLInt = cast(AVL)->getZExtValue(); if (AVLInt <= MinVLMAX) { diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h b/llvm/lib/Target/RISCV/RISCVISelLowering.h index ae798cc..41a2dc5 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.h +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h @@ -744,7 +744,13 @@ public: // The following equations have been reordered to prevent loss of precision // when calculating fractional LMUL. return ((VectorBits / EltSize) * MinSize) / RISCV::RVVBitsPerBlock; - }; + } + + // Return inclusive (low, high) bounds on the value of VLMAX for the + // given scalable container type given known bounds on VLEN. + static std::pair + computeVLMAXBounds(MVT ContainerVT, const RISCVSubtarget &Subtarget); + static unsigned getRegClassIDForLMUL(RISCVII::VLMUL LMul); static unsigned getSubregIndexByMVT(MVT VT, unsigned Index); static unsigned getRegClassIDForVecVT(MVT VT); -- cgit v1.1 From e065841cb06d78ae1d6863fac156a5e91f464ec7 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Wed, 13 Dec 2023 13:42:24 -0800 Subject: [asan] Install `pthread_atfork` (#75290) This prevents deadlocks in forked process if parent had more then one running threads. --- compiler-rt/lib/asan/asan_fuchsia.cpp | 2 ++ compiler-rt/lib/asan/asan_internal.h | 1 + compiler-rt/lib/asan/asan_posix.cpp | 24 ++++++++++++++++++++++ compiler-rt/lib/asan/asan_rtl.cpp | 2 ++ compiler-rt/lib/asan/asan_win.cpp | 2 ++ .../TestCases/Posix/fork_threaded.c | 2 +- 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/asan/asan_fuchsia.cpp b/compiler-rt/lib/asan/asan_fuchsia.cpp index 2b15504..12625e9 100644 --- a/compiler-rt/lib/asan/asan_fuchsia.cpp +++ b/compiler-rt/lib/asan/asan_fuchsia.cpp @@ -240,6 +240,8 @@ void FlushUnneededASanShadowMemory(uptr p, uptr size) { // So this doesn't install any atexit hook like on other platforms. void InstallAtExitCheckLeaks() {} +void InstallAtForkHandler() {} + } // namespace __asan namespace __lsan { diff --git a/compiler-rt/lib/asan/asan_internal.h b/compiler-rt/lib/asan/asan_internal.h index 5b97e77..2944ebe 100644 --- a/compiler-rt/lib/asan/asan_internal.h +++ b/compiler-rt/lib/asan/asan_internal.h @@ -126,6 +126,7 @@ void *AsanDlSymNext(const char *sym); bool HandleDlopenInit(); void InstallAtExitCheckLeaks(); +void InstallAtForkHandler(); #define ASAN_ON_ERROR() \ if (&__asan_on_error) \ diff --git a/compiler-rt/lib/asan/asan_posix.cpp b/compiler-rt/lib/asan/asan_posix.cpp index e1f6664..206551b 100644 --- a/compiler-rt/lib/asan/asan_posix.cpp +++ b/compiler-rt/lib/asan/asan_posix.cpp @@ -148,6 +148,30 @@ void PlatformTSDDtor(void *tsd) { } #endif +void InstallAtForkHandler() { + auto before = []() { + if (CAN_SANITIZE_LEAKS) { + __lsan::LockGlobal(); + } + // `_lsan` functions defined regardless of `CAN_SANITIZE_LEAKS` and lock the + // stuff we need. + __lsan::LockThreads(); + __lsan::LockAllocator(); + StackDepotLockAll(); + }; + auto after = []() { + StackDepotUnlockAll(); + // `_lsan` functions defined regardless of `CAN_SANITIZE_LEAKS` and unlock + // the stuff we need. + __lsan::UnlockAllocator(); + __lsan::UnlockThreads(); + if (CAN_SANITIZE_LEAKS) { + __lsan::UnlockGlobal(); + } + }; + pthread_atfork(before, after, after); +} + void InstallAtExitCheckLeaks() { if (CAN_SANITIZE_LEAKS) { if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) { diff --git a/compiler-rt/lib/asan/asan_rtl.cpp b/compiler-rt/lib/asan/asan_rtl.cpp index b28f9f1..a61deed 100644 --- a/compiler-rt/lib/asan/asan_rtl.cpp +++ b/compiler-rt/lib/asan/asan_rtl.cpp @@ -493,6 +493,8 @@ static bool AsanInitInternal() { InstallAtExitCheckLeaks(); } + InstallAtForkHandler(); + #if CAN_SANITIZE_UB __ubsan::InitAsPlugin(); #endif diff --git a/compiler-rt/lib/asan/asan_win.cpp b/compiler-rt/lib/asan/asan_win.cpp index d5a30f4..f16ce67 100644 --- a/compiler-rt/lib/asan/asan_win.cpp +++ b/compiler-rt/lib/asan/asan_win.cpp @@ -203,6 +203,8 @@ void InitializePlatformInterceptors() { void InstallAtExitCheckLeaks() {} +void InstallAtForkHandler() {} + void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { UNIMPLEMENTED(); } diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c index 7592269..673d353 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c @@ -1,6 +1,6 @@ // RUN: %clang -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t -// UNSUPPORTED: asan, hwasan +// UNSUPPORTED: hwasan // The test uses pthread barriers which are not available on Darwin. // UNSUPPORTED: darwin -- cgit v1.1 From c64334fb30f8a8087c218b6d7ec954ad47b33947 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Wed, 13 Dec 2023 13:44:37 -0800 Subject: [X86][FastISel] Support medium code model in more places (#75375) The medium code model is basically identical to the small code model except that large objects cannot be referenced with 32-bit offsets. --- llvm/lib/Target/X86/X86FastISel.cpp | 18 ++++++--- llvm/test/CodeGen/X86/fast-isel-constpool.ll | 1 + .../CodeGen/X86/fast-isel-medium-code-model.ll | 44 ++++++++++++++++++++++ 3 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 llvm/test/CodeGen/X86/fast-isel-medium-code-model.ll diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index bdc9d1d..425c52d 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -711,7 +711,8 @@ bool X86FastISel::handleConstantAddresses(const Value *V, X86AddressMode &AM) { // Handle constant address. if (const GlobalValue *GV = dyn_cast(V)) { // Can't handle alternate code models yet. - if (TM.getCodeModel() != CodeModel::Small) + if (TM.getCodeModel() != CodeModel::Small && + TM.getCodeModel() != CodeModel::Medium) return false; // Can't handle large objects yet. @@ -1050,7 +1051,8 @@ bool X86FastISel::X86SelectCallAddress(const Value *V, X86AddressMode &AM) { // Handle constant address. if (const GlobalValue *GV = dyn_cast(V)) { // Can't handle alternate code models yet. - if (TM.getCodeModel() != CodeModel::Small) + if (TM.getCodeModel() != CodeModel::Small && + TM.getCodeModel() != CodeModel::Medium) return false; // RIP-relative addresses can't have additional register operands. @@ -3774,7 +3776,8 @@ unsigned X86FastISel::X86MaterializeFP(const ConstantFP *CFP, MVT VT) { // Can't handle alternate code models yet. CodeModel::Model CM = TM.getCodeModel(); - if (CM != CodeModel::Small && CM != CodeModel::Large) + if (CM != CodeModel::Small && CM != CodeModel::Medium && + CM != CodeModel::Large) return 0; // Get opcode and regclass of the output for the given load instruction. @@ -3812,7 +3815,7 @@ unsigned X86FastISel::X86MaterializeFP(const ConstantFP *CFP, MVT VT) { PICBase = getInstrInfo()->getGlobalBaseReg(FuncInfo.MF); else if (OpFlag == X86II::MO_GOTOFF) PICBase = getInstrInfo()->getGlobalBaseReg(FuncInfo.MF); - else if (Subtarget->is64Bit() && TM.getCodeModel() == CodeModel::Small) + else if (Subtarget->is64Bit() && TM.getCodeModel() != CodeModel::Large) PICBase = X86::RIP; // Create the load from the constant pool. @@ -3842,8 +3845,11 @@ unsigned X86FastISel::X86MaterializeFP(const ConstantFP *CFP, MVT VT) { } unsigned X86FastISel::X86MaterializeGV(const GlobalValue *GV, MVT VT) { - // Can't handle alternate code models yet. - if (TM.getCodeModel() != CodeModel::Small) + // Can't handle large GlobalValues yet. + if (TM.getCodeModel() != CodeModel::Small && + TM.getCodeModel() != CodeModel::Medium) + return 0; + if (!isa(GV) || TM.isLargeGlobalObject(cast(GV))) return 0; // Materialize addresses with LEA/MOV instructions. diff --git a/llvm/test/CodeGen/X86/fast-isel-constpool.ll b/llvm/test/CodeGen/X86/fast-isel-constpool.ll index 9f70fd5..9e4cbb6 100644 --- a/llvm/test/CodeGen/X86/fast-isel-constpool.ll +++ b/llvm/test/CodeGen/X86/fast-isel-constpool.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=small < %s | FileCheck %s +; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=medium < %s | FileCheck %s ; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=large < %s | FileCheck %s --check-prefix=LARGE ; RUN: llc -mtriple=x86_64 -fast-isel -code-model=large -relocation-model=pic < %s | FileCheck %s --check-prefix=LARGE_PIC ; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=small -mattr=avx < %s | FileCheck %s --check-prefix=AVX diff --git a/llvm/test/CodeGen/X86/fast-isel-medium-code-model.ll b/llvm/test/CodeGen/X86/fast-isel-medium-code-model.ll new file mode 100644 index 0000000..4aa230a --- /dev/null +++ b/llvm/test/CodeGen/X86/fast-isel-medium-code-model.ll @@ -0,0 +1,44 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=x86_64-linux-gnu -fast-isel -fast-isel-abort=3 -code-model=medium -large-data-threshold=5 < %s | FileCheck %s +; RUN: llc -mtriple=x86_64-linux-gnu -fast-isel -code-model=medium -large-data-threshold=3 < %s -o /dev/null \ +; RUN: -pass-remarks-output=- -pass-remarks-filter=sdagisel | FileCheck %s --check-prefix=FALLBACK --implicit-check-not=missed + +declare void @foo() + +define void @call_foo() { +; CHECK-LABEL: call_foo: +; CHECK: # %bb.0: +; CHECK-NEXT: pushq %rax +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: callq foo@PLT +; CHECK-NEXT: popq %rax +; CHECK-NEXT: .cfi_def_cfa_offset 8 +; CHECK-NEXT: retq + call void @foo() + ret void +} + +@g = internal global i32 42 + +; FALLBACK: FastISel missed terminator +; FALLBACK: in function: g_addr + +define ptr @g_addr() { +; CHECK-LABEL: g_addr: +; CHECK: # %bb.0: +; CHECK-NEXT: movabsq $g, %rax +; CHECK-NEXT: retq + ret ptr @g +} + +; FALLBACK: FastISel missed +; FALLBACK: in function: load_g + +define i32 @load_g() { +; CHECK-LABEL: load_g: +; CHECK: # %bb.0: +; CHECK-NEXT: movl g, %eax +; CHECK-NEXT: retq + %i = load i32, ptr @g + ret i32 %i +} -- cgit v1.1 From 2a9d8caf29ca2b2cf4758db31c64fd20cb5eb3bf Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 13 Dec 2023 13:49:03 -0800 Subject: Revert "[MLIR] Fuse locations of merged constants (#74670)" This reverts commit 87e2e89019ec4405fa47c3b4585be4e67473b590. and its follow-ups 0d1490f09f23bf204b714c3c6ba5e0aaf4eeed9a (#75218) and 6fe3cd54670cae52dae92a38a6d28f450fe8f321 (#75312). We observed significant OOM/timeout issues due to #74670 to quite a few services including google-research/swirl-lm. The follow-up #75218 and #75312 do not address the issue. Perhaps this is worth more investigation. --- mlir/include/mlir/Transforms/FoldUtils.h | 12 +--- mlir/lib/Transforms/Utils/FoldUtils.cpp | 79 +---------------------- mlir/test/Transforms/canonicalize-debuginfo.mlir | 41 ------------ mlir/test/Transforms/constant-fold-debuginfo.mlir | 34 ---------- 4 files changed, 2 insertions(+), 164 deletions(-) delete mode 100644 mlir/test/Transforms/canonicalize-debuginfo.mlir delete mode 100644 mlir/test/Transforms/constant-fold-debuginfo.mlir diff --git a/mlir/include/mlir/Transforms/FoldUtils.h b/mlir/include/mlir/Transforms/FoldUtils.h index 28fa18c..2600da3 100644 --- a/mlir/include/mlir/Transforms/FoldUtils.h +++ b/mlir/include/mlir/Transforms/FoldUtils.h @@ -33,8 +33,7 @@ class Value; class OperationFolder { public: OperationFolder(MLIRContext *ctx, OpBuilder::Listener *listener = nullptr) - : fusedLocationTag(StringAttr::get(ctx, "CSE")), interfaces(ctx), - rewriter(ctx, listener) {} + : interfaces(ctx), rewriter(ctx, listener) {} /// Tries to perform folding on the given `op`, including unifying /// deduplicated constants. If successful, replaces `op`'s uses with @@ -96,15 +95,6 @@ private: Dialect *dialect, Attribute value, Type type, Location loc); - // Fuse `foldedLocation` into the Location of `retainedOp`. This will result - // in `retainedOp` having a FusedLoc with `fusedLocationTag` to help trace the - // source of the fusion. If `retainedOp` already had a FusedLoc with the same - // tag, `foldedLocation` will simply be appended to it. - void appendFoldedLocation(Operation *retainedOp, Location foldedLocation); - - /// Tag for annotating fused locations as a result of merging constants. - StringAttr fusedLocationTag; - /// A mapping between an insertion region and the constants that have been /// created within it. DenseMap foldScopes; diff --git a/mlir/lib/Transforms/Utils/FoldUtils.cpp b/mlir/lib/Transforms/Utils/FoldUtils.cpp index 136c4d2..90ee5ba 100644 --- a/mlir/lib/Transforms/Utils/FoldUtils.cpp +++ b/mlir/lib/Transforms/Utils/FoldUtils.cpp @@ -141,7 +141,6 @@ bool OperationFolder::insertKnownConstant(Operation *op, Attribute constValue) { // If there is an existing constant, replace `op`. if (folderConstOp) { notifyRemoval(op); - appendFoldedLocation(folderConstOp, op->getLoc()); rewriter.replaceOp(op, folderConstOp->getResults()); return false; } @@ -295,10 +294,8 @@ OperationFolder::tryGetOrCreateConstant(ConstantMap &uniquedConstants, // Check if an existing mapping already exists. auto constKey = std::make_tuple(dialect, value, type); Operation *&constOp = uniquedConstants[constKey]; - if (constOp) { - appendFoldedLocation(constOp, loc); + if (constOp) return constOp; - } // If one doesn't exist, try to materialize one. if (!(constOp = materializeConstant(dialect, rewriter, value, type, loc))) @@ -319,7 +316,6 @@ OperationFolder::tryGetOrCreateConstant(ConstantMap &uniquedConstants, // materialized operation in favor of the existing one. if (auto *existingOp = uniquedConstants.lookup(newKey)) { notifyRemoval(constOp); - appendFoldedLocation(existingOp, constOp->getLoc()); rewriter.eraseOp(constOp); referencedDialects[existingOp].push_back(dialect); return constOp = existingOp; @@ -330,76 +326,3 @@ OperationFolder::tryGetOrCreateConstant(ConstantMap &uniquedConstants, auto newIt = uniquedConstants.insert({newKey, constOp}); return newIt.first->second; } - -/// Helper that flattens nested fused locations to a single fused location. -/// Fused locations nested under non-fused locations are not flattened, and -/// calling this on non-fused locations is a no-op as a result. -/// -/// Fused locations are only flattened into parent fused locations if the -/// child fused location has no metadata, or if the metadata of the parent and -/// child fused locations are the same---this to avoid breaking cases where -/// metadata matter. -static Location FlattenFusedLocationRecursively(const Location loc) { - auto fusedLoc = dyn_cast(loc); - if (!fusedLoc) - return loc; - - SetVector flattenedLocs; - Attribute metadata = fusedLoc.getMetadata(); - ArrayRef unflattenedLocs = fusedLoc.getLocations(); - bool hasAnyNestedLocChanged = false; - - for (const Location &unflattenedLoc : unflattenedLocs) { - Location flattenedLoc = FlattenFusedLocationRecursively(unflattenedLoc); - - auto flattenedFusedLoc = dyn_cast(flattenedLoc); - if (flattenedFusedLoc && (!flattenedFusedLoc.getMetadata() || - flattenedFusedLoc.getMetadata() == metadata)) { - hasAnyNestedLocChanged = true; - ArrayRef nestedLocations = flattenedFusedLoc.getLocations(); - flattenedLocs.insert(nestedLocations.begin(), nestedLocations.end()); - } else { - if (flattenedLoc != unflattenedLoc) - hasAnyNestedLocChanged = true; - - flattenedLocs.insert(flattenedLoc); - } - } - - if (!hasAnyNestedLocChanged && - unflattenedLocs.size() == flattenedLocs.size()) { - return loc; - } - - return FusedLoc::get(loc->getContext(), flattenedLocs.takeVector(), - fusedLoc.getMetadata()); -} - -void OperationFolder::appendFoldedLocation(Operation *retainedOp, - Location foldedLocation) { - // Append into existing fused location if it has the same tag. - if (auto existingFusedLoc = - dyn_cast>(retainedOp->getLoc())) { - StringAttr existingMetadata = existingFusedLoc.getMetadata(); - if (existingMetadata == fusedLocationTag) { - ArrayRef existingLocations = existingFusedLoc.getLocations(); - SetVector locations(existingLocations.begin(), - existingLocations.end()); - locations.insert(foldedLocation); - Location newFusedLoc = FusedLoc::get( - retainedOp->getContext(), locations.takeVector(), existingMetadata); - retainedOp->setLoc(FlattenFusedLocationRecursively(newFusedLoc)); - return; - } - } - - // Create a new fusedloc with retainedOp's loc and foldedLocation. - // If they're already equal, no need to fuse. - if (retainedOp->getLoc() == foldedLocation) - return; - - Location newFusedLoc = - FusedLoc::get(retainedOp->getContext(), - {retainedOp->getLoc(), foldedLocation}, fusedLocationTag); - retainedOp->setLoc(FlattenFusedLocationRecursively(newFusedLoc)); -} diff --git a/mlir/test/Transforms/canonicalize-debuginfo.mlir b/mlir/test/Transforms/canonicalize-debuginfo.mlir deleted file mode 100644 index 217cc29..0000000 --- a/mlir/test/Transforms/canonicalize-debuginfo.mlir +++ /dev/null @@ -1,41 +0,0 @@ -// RUN: mlir-opt %s -pass-pipeline='builtin.module(func.func(canonicalize{test-convergence}))' -split-input-file -mlir-print-debuginfo | FileCheck %s - -// CHECK-LABEL: func @merge_constants -func.func @merge_constants() -> (index, index, index, index, index, index, index) { - // CHECK-NEXT: arith.constant 42 : index loc(#[[FusedLoc:.*]]) - %0 = arith.constant 42 : index loc("merge_constants":0:0) - %1 = arith.constant 42 : index loc("merge_constants":1:0) - %2 = arith.constant 42 : index loc("merge_constants":2:0) - %3 = arith.constant 42 : index loc("merge_constants":2:0) // repeated loc - %4 = arith.constant 43 : index loc(fused<"some_label">["merge_constants":3:0]) - %5 = arith.constant 43 : index loc(fused<"some_label">["merge_constants":3:0]) - %6 = arith.constant 43 : index loc(fused<"some_other_label">["merge_constants":3:0]) - return %0, %1, %2, %3, %4, %5, %6 : index, index, index, index, index, index, index -} - -// CHECK-DAG: #[[LocConst0:.*]] = loc("merge_constants":0:0) -// CHECK-DAG: #[[LocConst1:.*]] = loc("merge_constants":1:0) -// CHECK-DAG: #[[LocConst2:.*]] = loc("merge_constants":2:0) -// CHECK-DAG: #[[LocConst3:.*]] = loc("merge_constants":3:0) -// CHECK-DAG: #[[FusedLoc_CSE_1:.*]] = loc(fused<"CSE">[#[[LocConst0]], #[[LocConst1]], #[[LocConst2]]]) -// CHECK-DAG: #[[FusedLoc_Some_Label:.*]] = loc(fused<"some_label">[#[[LocConst3]]]) -// CHECK-DAG: #[[FusedLoc_Some_Other_Label:.*]] = loc(fused<"some_other_label">[#[[LocConst3]]]) -// CHECK-DAG: #[[FusedLoc_CSE_2:.*]] = loc(fused<"CSE">[#[[FusedLoc_Some_Label]], #[[FusedLoc_Some_Other_Label]]]) - -// ----- - -// CHECK-LABEL: func @hoist_constant -func.func @hoist_constant(%arg0: memref<8xi32>) { - // CHECK-NEXT: arith.constant 42 : i32 loc(#[[FusedLoc:.*]]) - affine.for %arg1 = 0 to 8 { - %0 = arith.constant 42 : i32 loc("hoist_constant":0:0) - %1 = arith.constant 42 : i32 loc("hoist_constant":1:0) - memref.store %0, %arg0[%arg1] : memref<8xi32> - memref.store %1, %arg0[%arg1] : memref<8xi32> - } - return -} - -// CHECK-DAG: #[[LocConst0:.*]] = loc("hoist_constant":0:0) -// CHECK-DAG: #[[LocConst1:.*]] = loc("hoist_constant":1:0) -// CHECK: #[[FusedLoc]] = loc(fused<"CSE">[#[[LocConst0]], #[[LocConst1]]]) diff --git a/mlir/test/Transforms/constant-fold-debuginfo.mlir b/mlir/test/Transforms/constant-fold-debuginfo.mlir deleted file mode 100644 index 79a25f8..0000000 --- a/mlir/test/Transforms/constant-fold-debuginfo.mlir +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: mlir-opt %s -split-input-file -test-constant-fold -mlir-print-debuginfo | FileCheck %s - -// CHECK-LABEL: func @fold_and_merge -func.func @fold_and_merge() -> (i32, i32) { - %0 = arith.constant 1 : i32 - %1 = arith.constant 5 : i32 - - // CHECK-NEXT: [[C:%.+]] = arith.constant 6 : i32 loc(#[[FusedLoc:.*]]) - %2 = arith.addi %0, %1 : i32 loc("fold_and_merge":0:0) - - %3 = arith.constant 6 : i32 loc("fold_and_merge":1:0) - - return %2, %3: i32, i32 -} - -// CHECK-DAG: #[[LocConst0:.*]] = loc("fold_and_merge":0:0) -// CHECK-DAG: #[[LocConst1:.*]] = loc("fold_and_merge":1:0) -// CHECK: #[[FusedLoc]] = loc(fused<"CSE">[#[[LocConst1]], #[[LocConst0]]]) - -// ----- - -// CHECK-LABEL: func @materialize_different_dialect -func.func @materialize_different_dialect() -> (f32, f32) { - // CHECK: arith.constant 1.{{0*}}e+00 : f32 loc(#[[FusedLoc:.*]]) - %0 = arith.constant -1.0 : f32 - %1 = math.absf %0 : f32 loc("materialize_different_dialect":0:0) - %2 = arith.constant 1.0 : f32 loc("materialize_different_dialect":1:0) - - return %1, %2: f32, f32 -} - -// CHECK-DAG: #[[LocConst0:.*]] = loc("materialize_different_dialect":0:0) -// CHECK-DAG: #[[LocConst1:.*]] = loc("materialize_different_dialect":1:0) -// CHECK: #[[FusedLoc]] = loc(fused<"CSE">[#[[LocConst1]], #[[LocConst0]]]) -- cgit v1.1 From c3fa4b788f4427c483a08eeb8ccec2cb1ed83d32 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 13 Dec 2023 14:00:06 -0800 Subject: [clang-format] Fix a bug in git-clang-format.bat (#75268) Pass the fully-qualified path name (less the file extension) of git-clang-format.bat to py so that it can be run from anywhere. Fixes #75265. --- clang/tools/clang-format/git-clang-format.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/tools/clang-format/git-clang-format.bat b/clang/tools/clang-format/git-clang-format.bat index d4bc517..9965cd4 100644 --- a/clang/tools/clang-format/git-clang-format.bat +++ b/clang/tools/clang-format/git-clang-format.bat @@ -1 +1 @@ -py -3 git-clang-format %* +py -3 %~pn0 %* -- cgit v1.1 From eabf7ec3f3d4688ea0f9da24038462362837d7ff Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Wed, 13 Dec 2023 14:04:20 -0800 Subject: [GlobalISel] Fix misaligned read after #74429 --- llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h b/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h index 7330892..724f39634 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h @@ -690,7 +690,9 @@ protected: bool isObviouslySafeToFold(MachineInstr &MI, MachineInstr &IntoMI) const; template static Ty readBytesAs(const uint8_t *MatchTable) { - return *reinterpret_cast(MatchTable); + Ty res; + memcpy(&res, MatchTable, sizeof(res)); + return res; } }; -- cgit v1.1 From 8bea83b8f5adae8abc5d6a6695c756a616201aa7 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Wed, 13 Dec 2023 14:10:28 -0800 Subject: [NFC][GlobalISel] Fix case of local variable --- llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h b/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h index 724f39634..694d3d80 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h @@ -690,9 +690,9 @@ protected: bool isObviouslySafeToFold(MachineInstr &MI, MachineInstr &IntoMI) const; template static Ty readBytesAs(const uint8_t *MatchTable) { - Ty res; - memcpy(&res, MatchTable, sizeof(res)); - return res; + Ty Ret; + memcpy(&Ret, MatchTable, sizeof(Ret)); + return Ret; } }; -- cgit v1.1