[llvm-branch-commits] [llvm] [CodeGen][StaticDataSplitter]Support constant pool partitioning (PR #129781)

2025-03-29 Thread Mingming Liu via llvm-branch-commits

https://github.com/mingmingl-llvm edited 
https://github.com/llvm/llvm-project/pull/129781
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [MC, COFF] .safeseh: avoid changeSection (#132624) (PR #133591)

2025-03-29 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay approved this pull request.


https://github.com/llvm/llvm-project/pull/133591
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [MC, COFF] .safeseh: avoid changeSection (#132624) (PR #133591)

2025-03-29 Thread via llvm-branch-commits

github-actions[bot] wrote:

@MaskRay (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/133591
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 5ba1949 - [MC, COFF] .safeseh: avoid changeSection (#132624)

2025-03-29 Thread via llvm-branch-commits

Author: Fangrui Song
Date: 2025-03-29T17:37:09Z
New Revision: 5ba194972878531b527f7370b509829a8e251949

URL: 
https://github.com/llvm/llvm-project/commit/5ba194972878531b527f7370b509829a8e251949
DIFF: 
https://github.com/llvm/llvm-project/commit/5ba194972878531b527f7370b509829a8e251949.diff

LOG: [MC,COFF] .safeseh: avoid changeSection (#132624)

The directive temporarily switches to the .sxdata section to emit data,
and then calls `insert`, which makes `CurFrag` out of sync of the
current section. Call push/switch/pop instead.

Related to #132464

(cherry picked from commit ece72e2731350d9840c6446db9276b04d593cc23)

Added: 


Modified: 
llvm/lib/MC/MCWinCOFFStreamer.cpp
llvm/test/CodeGen/X86/win32-eh.ll

Removed: 




diff  --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp 
b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 8fd46bc8b0255..3720d6e26fe46 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -299,7 +299,8 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
 return;
 
   MCSection *SXData = getContext().getObjectFileInfo()->getSXDataSection();
-  changeSection(SXData);
+  pushSection();
+  switchSection(SXData);
   SXData->ensureMinAlignment(Align(4));
 
   insert(getContext().allocFragment(Symbol));
@@ -310,6 +311,7 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
   // function. Go ahead and oblige it here.
   CSymbol->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION
<< COFF::SCT_COMPLEX_TYPE_SHIFT);
+  popSection();
 }
 
 void MCWinCOFFStreamer::emitCOFFSymbolIndex(MCSymbol const *Symbol) {

diff  --git a/llvm/test/CodeGen/X86/win32-eh.ll 
b/llvm/test/CodeGen/X86/win32-eh.ll
index 82dc4beaf972b..d3d19ede546d6 100644
--- a/llvm/test/CodeGen/X86/win32-eh.ll
+++ b/llvm/test/CodeGen/X86/win32-eh.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple=i686-pc-windows-msvc -filetype=obj < %s -o %t
 
 declare void @may_throw_or_crash()
 declare i32 @_except_handler3(...)
@@ -208,6 +209,14 @@ catch:
 ; CHECK-NEXT:  .long   0
 ; CHECK-NEXT:  .long   1
 
+; CHECK-LABEL: inlineasm:
+; CHECK: .safeseh my_handler
+define i32 @inlineasm() {
+entry:
+  call void asm sideeffect ".safeseh my_handler", 
"~{dirflag},~{fpsr},~{flags}"()
+  ret i32 0
+}
+
 ; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
 ; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
 ; CHECK-NEXT: jmp  ___CxxFrameHandler3 # TAILCALL



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [KeyInstr][LoopUnswitch] Remap cloned instructions' atoms (PR #133491)

2025-03-29 Thread Orlando Cazalet-Hyams via llvm-branch-commits

https://github.com/OCHyams created 
https://github.com/llvm/llvm-project/pull/133491

None

>From 1f03a5db32a0abf8627870dec8b5e6224a0ff8e9 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Wed, 26 Mar 2025 16:26:08 +
Subject: [PATCH] [KeyInstr][LoopUnswitch] Remap cloned instructions' atoms

---
 .../Transforms/Scalar/SimpleLoopUnswitch.cpp  |   4 +
 .../KeyInstructions/Generic/loop-unswitch.ll  | 137 ++
 2 files changed, 141 insertions(+)
 create mode 100644 llvm/test/DebugInfo/KeyInstructions/Generic/loop-unswitch.ll

diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp 
b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 4f7956514b7b5..e0b403a18a718 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -297,6 +297,10 @@ static void buildPartialInvariantUnswitchConditionalBranch(
   for (auto *Val : reverse(ToDuplicate)) {
 Instruction *Inst = cast(Val);
 Instruction *NewInst = Inst->clone();
+
+if (const DebugLoc &DL = Inst->getDebugLoc())
+  mapAtomInstance(DL, VMap);
+
 NewInst->insertInto(&BB, BB.end());
 RemapInstruction(NewInst, VMap,
  RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
diff --git a/llvm/test/DebugInfo/KeyInstructions/Generic/loop-unswitch.ll 
b/llvm/test/DebugInfo/KeyInstructions/Generic/loop-unswitch.ll
new file mode 100644
index 0..9d696e78b2639
--- /dev/null
+++ b/llvm/test/DebugInfo/KeyInstructions/Generic/loop-unswitch.ll
@@ -0,0 +1,137 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5
+; RUN: opt %s -S --passes="loop-mssa(simple-loop-unswitch)" -o - \
+; RUN: | FileCheck %s
+
+;; The important thing here is that the instructions duplicated from
+;; LOOP_HEADER into ENTRY, and those duplicated from LOOP_LATCH into
+;; LOOP_LATCH_US, get remapped atom numbers.
+
+define i32 @partial_unswitch_true_successor_hoist_invariant(ptr %ptr, i32 %N) 
!dbg !5 {
+; CHECK-LABEL: define i32 @partial_unswitch_true_successor_hoist_invariant(
+; CHECK-SAME: ptr [[PTR:%.*]], i32 [[N:%.*]]) !dbg [[DBG5:![0-9]+]] {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:[[TMP0:%.*]] = getelementptr i32, ptr [[PTR]], i64 1, !dbg 
[[DBG8:![0-9]+]]
+; CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4, !dbg 
[[DBG9:![0-9]+]]
+; CHECK-NEXT:[[TMP2:%.*]] = icmp eq i32 [[TMP1]], 100, !dbg 
[[DBG10:![0-9]+]]
+; CHECK-NEXT:br i1 [[TMP2]], label %[[ENTRY_SPLIT_US:.*]], label 
%[[ENTRY_SPLIT:.*]]
+; CHECK:   [[ENTRY_SPLIT_US]]:
+; CHECK-NEXT:br label %[[LOOP_HEADER_US:.*]], !dbg [[DBG11:![0-9]+]]
+; CHECK:   [[LOOP_HEADER_US]]:
+; CHECK-NEXT:[[IV_US:%.*]] = phi i32 [ 0, %[[ENTRY_SPLIT_US]] ], [ 
[[IV_NEXT_US:%.*]], %[[LOOP_LATCH_US:.*]] ], !dbg [[DBG12:![0-9]+]]
+; CHECK-NEXT:br label %[[NOCLOBBER_US:.*]], !dbg [[DBG13:![0-9]+]]
+; CHECK:   [[NOCLOBBER_US]]:
+; CHECK-NEXT:br label %[[LOOP_LATCH_US]], !dbg [[DBG14:![0-9]+]]
+; CHECK:   [[LOOP_LATCH_US]]:
+; CHECK-NEXT:[[C_US:%.*]] = icmp ult i32 [[IV_US]], [[N]], !dbg 
[[DBG15:![0-9]+]]
+; CHECK-NEXT:[[IV_NEXT_US]] = add i32 [[IV_US]], 1, !dbg [[DBG16:![0-9]+]]
+; CHECK-NEXT:br i1 [[C_US]], label %[[LOOP_HEADER_US]], label 
%[[EXIT_SPLIT_US:.*]], !dbg [[DBG17:![0-9]+]]
+; CHECK:   [[EXIT_SPLIT_US]]:
+; CHECK-NEXT:br label %[[EXIT:.*]], !dbg [[DBG18:![0-9]+]]
+; CHECK:   [[ENTRY_SPLIT]]:
+; CHECK-NEXT:br label %[[LOOP_HEADER:.*]], !dbg [[DBG19:![0-9]+]]
+; CHECK:   [[LOOP_HEADER]]:
+; CHECK-NEXT:[[IV:%.*]] = phi i32 [ 0, %[[ENTRY_SPLIT]] ], [ 
[[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ], !dbg [[DBG20:![0-9]+]]
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr i32, ptr [[PTR]], i64 1, !dbg 
[[DBG21:![0-9]+]]
+; CHECK-NEXT:[[LV:%.*]] = load i32, ptr [[GEP]], align 4, !dbg 
[[DBG22:![0-9]+]]
+; CHECK-NEXT:[[SC:%.*]] = icmp eq i32 [[LV]], 100, !dbg [[DBG23:![0-9]+]]
+; CHECK-NEXT:br i1 [[SC]], label %[[NOCLOBBER:.*]], label %[[CLOBBER:.*]], 
!dbg [[DBG24:![0-9]+]]
+; CHECK:   [[NOCLOBBER]]:
+; CHECK-NEXT:br label %[[LOOP_LATCH]], !dbg [[DBG25:![0-9]+]]
+; CHECK:   [[CLOBBER]]:
+; CHECK-NEXT:call void @clobber(), !dbg [[DBG26:![0-9]+]]
+; CHECK-NEXT:br label %[[LOOP_LATCH]], !dbg [[DBG27:![0-9]+]]
+; CHECK:   [[LOOP_LATCH]]:
+; CHECK-NEXT:[[C:%.*]] = icmp ult i32 [[IV]], [[N]], !dbg [[DBG28:![0-9]+]]
+; CHECK-NEXT:[[IV_NEXT]] = add i32 [[IV]], 1, !dbg [[DBG29:![0-9]+]]
+; CHECK-NEXT:br i1 [[C]], label %[[LOOP_HEADER]], label 
%[[EXIT_SPLIT:.*]], !dbg [[DBG30:![0-9]+]], !llvm.loop [[LOOP31:![0-9]+]]
+; CHECK:   [[EXIT_SPLIT]]:
+; CHECK-NEXT:br label %[[EXIT]], !dbg [[DBG33:![0-9]+]]
+; CHECK:   [[EXIT]]:
+; CHECK-NEXT:ret i32 10, !dbg [[DBG33]]
+;
+entry:
+  br label %loop.header, !dbg !8
+
+loop.header:  ; preds = %loop.latch, %entry
+  %iv = phi i32 [ 0, %entry ], [ %iv.next, %lo

[llvm-branch-commits] [llvm] release/20.x: [MC, COFF] .safeseh: avoid changeSection (#132624) (PR #133591)

2025-03-29 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/133591
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-03-29 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Peter Collingbourne (pcc)


Changes

Pointer field protection is a use-after-free vulnerability
mitigation that works by changing how data structures' pointer
fields are stored in memory. For more information, see the RFC:
https://discourse.llvm.org/t/rfc-structure-protection-a-family-of-uaf-mitigation-techniques/8

TODO:
- Fix test failure.
- Add more tests.
- Add documentation.


---

Patch is 82.31 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/133538.diff


52 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+22) 
- (modified) clang/include/clang/Basic/Attr.td (+6) 
- (modified) clang/include/clang/Basic/Features.def (+3) 
- (modified) clang/include/clang/Basic/LangOptions.def (+3) 
- (modified) clang/include/clang/Basic/LangOptions.h (+11) 
- (modified) clang/include/clang/Basic/TokenKinds.def (+1) 
- (modified) clang/include/clang/Driver/Options.td (+6) 
- (modified) clang/lib/AST/ASTContext.cpp (+95) 
- (modified) clang/lib/AST/ExprConstant.cpp (+1) 
- (modified) clang/lib/AST/Type.cpp (+3-1) 
- (modified) clang/lib/AST/TypePrinter.cpp (+3) 
- (modified) clang/lib/CodeGen/CGCall.cpp (+108-6) 
- (modified) clang/lib/CodeGen/CGClass.cpp (+45-7) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+7-1) 
- (modified) clang/lib/CodeGen/CGExprAgg.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGExprCXX.cpp (+10) 
- (modified) clang/lib/CodeGen/CGExprConstant.cpp (+38-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+38-5) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+6-2) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+39) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+7) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1) 
- (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+1) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+4) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+8) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+5) 
- (added) clang/test/CodeGen/pfp-attribute-disable.cpp (+33) 
- (added) clang/test/CodeGen/pfp-load-store.cpp (+40) 
- (added) clang/test/CodeGen/pfp-memcpy.cpp (+19) 
- (added) clang/test/CodeGen/pfp-null-init.cpp (+16) 
- (added) clang/test/CodeGen/pfp-struct-gep.cpp (+25) 
- (modified) clang/test/CodeGenCXX/trivial_abi.cpp (+1-3) 
- (modified) libcxx/include/__config (+23) 
- (modified) libcxx/include/__functional/function.h (+1-1) 
- (modified) libcxx/include/__memory/shared_ptr.h (+2-2) 
- (modified) libcxx/include/__memory/unique_ptr.h (+2-2) 
- (modified) libcxx/include/__tree (+1-1) 
- (modified) libcxx/include/__type_traits/is_trivially_relocatable.h (+6-2) 
- (modified) libcxx/include/__vector/vector.h (+1-1) 
- (modified) libcxx/include/typeinfo (+1-1) 
- (modified) libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp (+9) 
- (modified) libcxxabi/include/__cxxabi_config.h (+10) 
- (modified) libcxxabi/src/private_typeinfo.h (+3-3) 
- (modified) llvm/include/llvm/Analysis/PtrUseVisitor.h (+15) 
- (modified) llvm/include/llvm/IR/Intrinsics.td (+23) 
- (modified) llvm/include/llvm/Transforms/Utils/Local.h (+2) 
- (modified) llvm/lib/Analysis/PtrUseVisitor.cpp (+2-1) 
- (modified) llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp (+246) 
- (modified) llvm/lib/Target/AArch64/AArch64InstrFormats.td (+3) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp (+2-4) 
- (modified) llvm/lib/Transforms/Scalar/SROA.cpp (+35-5) 
- (modified) llvm/lib/Transforms/Utils/SimplifyCFG.cpp (+20-5) 


``diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index af8c49e99a7ce..abba83e1ff9c4 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -183,6 +183,12 @@ struct TypeInfoChars {
   }
 };
 
+struct PFPField {
+  CharUnits structOffset;
+  CharUnits offset;
+  FieldDecl *field;
+};
+
 /// Holds long-lived AST nodes (such as types and decls) that can be
 /// referred to throughout the semantic analysis of a file.
 class ASTContext : public RefCountedBase {
@@ -3618,6 +3624,22 @@ OPT_LIST(V)
 
   StringRef getCUIDHash() const;
 
+  bool isPFPStruct(const RecordDecl *rec) const;
+  void findPFPFields(QualType Ty, CharUnits Offset,
+ std::vector &Fields, bool IncludeVBases) const;
+  bool hasPFPFields(QualType ty) const;
+  bool isPFPField(const FieldDecl *field) const;
+
+  /// Returns whether this record's PFP fields (if any) are trivially
+  /// relocatable (i.e. may be memcpy'd). This may also return true if the
+  /// record does not have any PFP fields, so it may be necessary for the 
caller
+  /// to check for PFP fields, e.g. by calling hasPFPFields().
+  bool arePFPFieldsTriviallyRelocatable(const RecordDecl *RD) const;
+
+  llvm::SetVector PFPFieldsWithEvaluatedOffset;
+  void recordMemberDataPointerEvaluation(const ValueDecl *VD);
+  void recordOffsetOfEvaluation(const OffsetOfExpr *E);
+
 private:
   /// All OMPTraitIn

[llvm-branch-commits] [llvm] llvm-reduce: Fix losing fast math flags in operands-to-args (PR #133421)

2025-03-29 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

### Merge activity

* **Mar 29, 5:10 AM EDT**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/133421).


https://github.com/llvm/llvm-project/pull/133421
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [llvm] [ctxprof] root autodetection mechanism (PR #133147)

2025-03-29 Thread Mircea Trofin via llvm-branch-commits

https://github.com/mtrofin updated 
https://github.com/llvm/llvm-project/pull/133147

>From e2b4b9ce7cb0f9b7d39142d419f59de8d60ec71c Mon Sep 17 00:00:00 2001
From: Mircea Trofin 
Date: Mon, 24 Mar 2025 12:01:10 -0700
Subject: [PATCH] RootAutodetect

---
 compiler-rt/lib/ctx_profile/CMakeLists.txt|   2 +-
 .../lib/ctx_profile/CtxInstrContextNode.h |   1 +
 .../lib/ctx_profile/CtxInstrProfiling.cpp | 119 +++
 .../lib/ctx_profile/CtxInstrProfiling.h   |   2 +-
 .../lib/ctx_profile/RootAutoDetector.cpp  |  83 
 .../lib/ctx_profile/RootAutoDetector.h|  31 +++
 .../TestCases/autodetect-roots.cpp| 188 ++
 .../TestCases/generate-context.cpp|   5 +-
 .../llvm/ProfileData/CtxInstrContextNode.h|   1 +
 .../Instrumentation/PGOCtxProfLowering.cpp|  26 ++-
 .../PGOProfile/ctx-instrumentation.ll |  20 +-
 11 files changed, 416 insertions(+), 62 deletions(-)
 create mode 100644 compiler-rt/test/ctx_profile/TestCases/autodetect-roots.cpp

diff --git a/compiler-rt/lib/ctx_profile/CMakeLists.txt 
b/compiler-rt/lib/ctx_profile/CMakeLists.txt
index bb606449c61b1..446ebc96408dd 100644
--- a/compiler-rt/lib/ctx_profile/CMakeLists.txt
+++ b/compiler-rt/lib/ctx_profile/CMakeLists.txt
@@ -27,7 +27,7 @@ endif()
 add_compiler_rt_runtime(clang_rt.ctx_profile
   STATIC
   ARCHS ${CTX_PROFILE_SUPPORTED_ARCH}
-  OBJECT_LIBS RTSanitizerCommon RTSanitizerCommonLibc
+  OBJECT_LIBS RTSanitizerCommon RTSanitizerCommonLibc 
RTSanitizerCommonSymbolizer
   CFLAGS ${EXTRA_FLAGS}
   SOURCES ${CTX_PROFILE_SOURCES}
   ADDITIONAL_HEADERS ${CTX_PROFILE_HEADERS}
diff --git a/compiler-rt/lib/ctx_profile/CtxInstrContextNode.h 
b/compiler-rt/lib/ctx_profile/CtxInstrContextNode.h
index a42bf9ebb01ea..aa052bc7eea6c 100644
--- a/compiler-rt/lib/ctx_profile/CtxInstrContextNode.h
+++ b/compiler-rt/lib/ctx_profile/CtxInstrContextNode.h
@@ -127,6 +127,7 @@ class ContextNode final {
 /// MUTEXDECL takes one parameter, the name of a field that is a mutex.
 #define CTXPROF_FUNCTION_DATA(PTRDECL, VOLATILE_PTRDECL, MUTEXDECL)
\
   PTRDECL(FunctionData, Next)  
\
+  PTRDECL(void, EntryAddress)  
\
   VOLATILE_PTRDECL(ContextRoot, CtxRoot)   
\
   VOLATILE_PTRDECL(ContextNode, FlatCtx)   
\
   MUTEXDECL(Mutex)
diff --git a/compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp 
b/compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp
index da291e0bbabdd..09ed607cde3aa 100644
--- a/compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp
+++ b/compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "CtxInstrProfiling.h"
+#include "RootAutoDetector.h"
 #include "sanitizer_common/sanitizer_allocator_internal.h"
 #include "sanitizer_common/sanitizer_atomic.h"
 #include "sanitizer_common/sanitizer_atomic_clang.h"
@@ -43,6 +44,12 @@ Arena *FlatCtxArena = nullptr;
 __thread bool IsUnderContext = false;
 __sanitizer::atomic_uint8_t ProfilingStarted = {};
 
+__sanitizer::atomic_uintptr_t RootDetector = {};
+RootAutoDetector *getRootDetector() {
+  return reinterpret_cast(
+  __sanitizer::atomic_load_relaxed(&RootDetector));
+}
+
 // utility to taint a pointer by setting the LSB. There is an assumption
 // throughout that the addresses of contexts are even (really, they should be
 // align(8), but "even"-ness is the minimum assumption)
@@ -201,7 +208,7 @@ ContextNode *getCallsiteSlow(GUID Guid, ContextNode 
**InsertionPoint,
   return Ret;
 }
 
-ContextNode *getFlatProfile(FunctionData &Data, GUID Guid,
+ContextNode *getFlatProfile(FunctionData &Data, void *Callee, GUID Guid,
 uint32_t NumCounters) {
   if (ContextNode *Existing = Data.FlatCtx)
 return Existing;
@@ -232,6 +239,7 @@ ContextNode *getFlatProfile(FunctionData &Data, GUID Guid,
 auto *Ret = allocContextNode(AllocBuff, Guid, NumCounters, 0);
 Data.FlatCtx = Ret;
 
+Data.EntryAddress = Callee;
 Data.Next = reinterpret_cast(
 __sanitizer::atomic_load_relaxed(&AllFunctionsData));
 while (!__sanitizer::atomic_compare_exchange_strong(
@@ -277,8 +285,29 @@ ContextRoot *FunctionData::getOrAllocateContextRoot() {
   return Root;
 }
 
-ContextNode *getUnhandledContext(FunctionData &Data, GUID Guid,
- uint32_t NumCounters) {
+ContextNode *tryStartContextGivenRoot(ContextRoot *Root, GUID Guid,
+  uint32_t Counters, uint32_t Callsites)
+SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
+  IsUnderContext = true;
+  __sanitizer::atomic_fetch_add(&Root->TotalEntries, 1,
+__sanitizer::memory_order_relaxed);
+
+  if (!Root->FirstMemBlock) {
+setupContext(Root, Guid, Counters, Callsites);
+  }
+  if (Root->Taken.TryL

[llvm-branch-commits] [clang] 943b432 - release/20.x: [clang][docs] Move -Wnontrivial-memcall to added flags. (#132367)

2025-03-29 Thread via llvm-branch-commits

Author: R-Goc
Date: 2025-03-28T23:27:50-07:00
New Revision: 943b43250b5580b73a4932032270e4478b118dcf

URL: 
https://github.com/llvm/llvm-project/commit/943b43250b5580b73a4932032270e4478b118dcf
DIFF: 
https://github.com/llvm/llvm-project/commit/943b43250b5580b73a4932032270e4478b118dcf.diff

LOG: release/20.x: [clang][docs] Move -Wnontrivial-memcall to added flags. 
(#132367)

-Wnon-trivial-memcall was incorrectly added to modified flags instead of
added flags. This commit moves it to the added compiler flags.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c921ac3518f01..f4befc242f28b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -545,6 +545,11 @@ New Compiler Flags
 - The ``-Warray-compare-cxx26`` warning has been added to warn about array 
comparison
   starting from C++26, this warning is enabled as an error by default.
 
+- The ``-Wnontrivial-memcall`` warning has been added to warn about
+  passing non-trivially-copyable destination parameter to ``memcpy``,
+  ``memset`` and similar functions for which it is a documented undefined
+  behavior. It is implied by ``-Wnontrivial-memaccess``
+
 - clang-cl and clang-dxc now support 
``-fdiagnostics-color=[auto|never|always]``
   in addition to ``-f[no-]color-diagnostics``.
 
@@ -576,11 +581,6 @@ Modified Compiler Flags
   to utilize these vector libraries. The behavior for all other vector function
   libraries remains unchanged.
 
-- The ``-Wnontrivial-memcall`` warning has been added to warn about
-  passing non-trivially-copyable destination parameter to ``memcpy``,
-  ``memset`` and similar functions for which it is a documented undefined
-  behavior. It is implied by ``-Wnontrivial-memaccess``
-
 - Added ``-fmodules-reduced-bmi`` flag corresponding to
   ``-fexperimental-modules-reduced-bmi`` flag. The ``-fmodules-reduced-bmi`` 
flag
   is intended to be enabled by default in the future.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [mlir] [CI] Add rich build information for github workflows (PR #133197)

2025-03-29 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/133197

>From 121d1e0f2bbc88e68c92d4859a4dce3686bd4467 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Thu, 27 Mar 2025 20:01:57 +
Subject: [PATCH 1/3] testing

Created using spr 1.3.4
---
 mlir/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 9e786154a2b40..1903757b18f35 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -1,4 +1,5 @@
 # MLIR project.
+# Test comment.
 cmake_minimum_required(VERSION 3.20.0)
 set(LLVM_SUBPROJECT_TITLE "MLIR")
 

>From 56fb9262c91f8ea334ada6796f0d2f66ca43631a Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 29 Mar 2025 06:00:39 +
Subject: [PATCH 2/3] more testing

Created using spr 1.3.4
---
 .ci/monolithic-linux.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh
index 4b6e56b4a4eda..a979e4896c368 100755
--- a/.ci/monolithic-linux.sh
+++ b/.ci/monolithic-linux.sh
@@ -35,12 +35,14 @@ function at-exit {
   ccache --print-stats > artifacts/ccache_stats.txt
 
   # If building fails there will be no results files.
+  echo "running in exit" >> $GITHUB_STEP_SUMMARY
   shopt -s nullglob
   if command -v buildkite-agent 2>&1 >/dev/null
   then
 python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_buildkite.py ":linux: 
Linux x64 Test Results" \
   "linux-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
   else
+echo "got to else" >> $GITHUB_STEP_SUMMARY
 python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":linux: 
Linux x64 Test Results" \
   $retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
   fi

>From 5d42e93860de1d82353c192bfaa2dd90965042d7 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 29 Mar 2025 06:18:59 +
Subject: [PATCH 3/3] fix issues

Created using spr 1.3.4
---
 .ci/generate_test_report_github.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.ci/generate_test_report_github.py 
b/.ci/generate_test_report_github.py
index d4b2677c1ba93..d8b035f03737c 100644
--- a/.ci/generate_test_report_github.py
+++ b/.ci/generate_test_report_github.py
@@ -7,7 +7,7 @@
 
 import generate_test_report_lib
 
-if __name__ == "__main___":
+if __name__ == "__main__":
 parser = argparse.ArgumentParser()
 parser.add_argument(
 "title", help="Title of the test report, without Markdown formatting."

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] llvm-reduce: Make run-ir-passes error more consistent (PR #133564)

2025-03-29 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

### Merge activity

* **Mar 29, 3:06 AM EDT**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/133564).


https://github.com/llvm/llvm-project/pull/133564
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] llvm-reduce: Fix losing call metadata in operands-to-args (PR #133422)

2025-03-29 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

### Merge activity

* **Mar 29, 5:10 AM EDT**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/133422).


https://github.com/llvm/llvm-project/pull/133422
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang][docs] Move -Wnontrivial-memcall to added flags. (PR #132367)

2025-03-29 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/132367
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] c75fc17 - Revert "[NFC] LLVM reduce: fix unused variable (#133584)"

2025-03-29 Thread via llvm-branch-commits

Author: Tim Gymnich
Date: 2025-03-29T14:59:42+01:00
New Revision: c75fc17210790ab0bac897f90d89facb99032dfa

URL: 
https://github.com/llvm/llvm-project/commit/c75fc17210790ab0bac897f90d89facb99032dfa
DIFF: 
https://github.com/llvm/llvm-project/commit/c75fc17210790ab0bac897f90d89facb99032dfa.diff

LOG: Revert "[NFC] LLVM reduce: fix unused variable (#133584)"

This reverts commit 9451617d563d3b0f43d86b25fd1b6a6528d0afc2.

Added: 


Modified: 
llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp

Removed: 




diff  --git a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp 
b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
index 85a9cac124c0e..6b1958e24c932 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
@@ -109,7 +109,7 @@ static void replaceFunctionCalls(Function *OldF, Function 
*NewF) {
 NewCI->setAttributes(CI->getAttributes());
 
 if (auto *FPOp = dyn_cast(NewCI))
-  FPOp->setFastMathFlags(CI->getFastMathFlags());
+  NewCI->setFastMathFlags(CI->getFastMathFlags());
 
 NewCI->copyMetadata(*CI);
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [mlir] [polly] [CI] Add rich build information for github workflows (PR #133197)

2025-03-29 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/133197

>From 121d1e0f2bbc88e68c92d4859a4dce3686bd4467 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Thu, 27 Mar 2025 20:01:57 +
Subject: [PATCH 1/5] testing

Created using spr 1.3.4
---
 mlir/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 9e786154a2b40..1903757b18f35 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -1,4 +1,5 @@
 # MLIR project.
+# Test comment.
 cmake_minimum_required(VERSION 3.20.0)
 set(LLVM_SUBPROJECT_TITLE "MLIR")
 

>From 56fb9262c91f8ea334ada6796f0d2f66ca43631a Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 29 Mar 2025 06:00:39 +
Subject: [PATCH 2/5] more testing

Created using spr 1.3.4
---
 .ci/monolithic-linux.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh
index 4b6e56b4a4eda..a979e4896c368 100755
--- a/.ci/monolithic-linux.sh
+++ b/.ci/monolithic-linux.sh
@@ -35,12 +35,14 @@ function at-exit {
   ccache --print-stats > artifacts/ccache_stats.txt
 
   # If building fails there will be no results files.
+  echo "running in exit" >> $GITHUB_STEP_SUMMARY
   shopt -s nullglob
   if command -v buildkite-agent 2>&1 >/dev/null
   then
 python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_buildkite.py ":linux: 
Linux x64 Test Results" \
   "linux-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
   else
+echo "got to else" >> $GITHUB_STEP_SUMMARY
 python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":linux: 
Linux x64 Test Results" \
   $retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
   fi

>From 5d42e93860de1d82353c192bfaa2dd90965042d7 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 29 Mar 2025 06:18:59 +
Subject: [PATCH 3/5] fix issues

Created using spr 1.3.4
---
 .ci/generate_test_report_github.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.ci/generate_test_report_github.py 
b/.ci/generate_test_report_github.py
index d4b2677c1ba93..d8b035f03737c 100644
--- a/.ci/generate_test_report_github.py
+++ b/.ci/generate_test_report_github.py
@@ -7,7 +7,7 @@
 
 import generate_test_report_lib
 
-if __name__ == "__main___":
+if __name__ == "__main__":
 parser = argparse.ArgumentParser()
 parser.add_argument(
 "title", help="Title of the test report, without Markdown formatting."

>From 9a1d7c587ac702c34c1e4ba9379ddbfd2af51182 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 29 Mar 2025 06:26:08 +
Subject: [PATCH 4/5] remove some testing stuff

Created using spr 1.3.4
---
 .ci/generate_test_report_github.py | 2 +-
 .ci/monolithic-linux.sh| 2 --
 .github/workflows/premerge.yaml| 2 --
 3 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/.ci/generate_test_report_github.py 
b/.ci/generate_test_report_github.py
index d8b035f03737c..5f88513e92a69 100644
--- a/.ci/generate_test_report_github.py
+++ b/.ci/generate_test_report_github.py
@@ -16,7 +16,7 @@
 parser.add_argument("junit_files", help="Paths to JUnit report files.", 
nargs="*")
 args = parser.parse_args()
 
-report, style = generate_test_report_lib.generate_report_from_files(
+report, _ = generate_test_report_lib.generate_report_from_files(
 args.title, args.return_code, args.junit_files, None
 )
 
diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh
index a979e4896c368..4b6e56b4a4eda 100755
--- a/.ci/monolithic-linux.sh
+++ b/.ci/monolithic-linux.sh
@@ -35,14 +35,12 @@ function at-exit {
   ccache --print-stats > artifacts/ccache_stats.txt
 
   # If building fails there will be no results files.
-  echo "running in exit" >> $GITHUB_STEP_SUMMARY
   shopt -s nullglob
   if command -v buildkite-agent 2>&1 >/dev/null
   then
 python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_buildkite.py ":linux: 
Linux x64 Test Results" \
   "linux-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
   else
-echo "got to else" >> $GITHUB_STEP_SUMMARY
 python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py ":linux: 
Linux x64 Test Results" \
   $retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
   fi
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 8431f6abeed04..e4f0ccf35067b 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -61,8 +61,6 @@ jobs:
   echo "Building runtimes: ${runtimes_to_build}"
   echo "Running runtimes checks targets: ${runtimes_check_targets}"
 
-  echo "testing" >> $GITHUB_STEP_SUMMARY
-
   export CC=/opt/llvm/bin/clang
   export CXX=/opt/llvm/bin/clang++
 

>From 0805ec9b5eed53188b324996572068623efb1b94 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 29 Mar 2025 06:47:18 +
Subject: [PATCH 5/5] remove all testing

Created using spr

[llvm-branch-commits] [RISCV] Replace @plt/@gotpcrel in data directives with %pltpcrel %gotpcrel (PR #132569)

2025-03-29 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/132569


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [RISCV] Replace @plt/@gotpcrel in data directives with %pltpcrel %gotpcrel (PR #132569)

2025-03-29 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/132569


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [MC, COFF] .safeseh: avoid changeSection (#132624) (PR #133591)

2025-03-29 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/133591
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [MC, COFF] .safeseh: avoid changeSection (#132624) (PR #133591)

2025-03-29 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/133591

Backport ece72e2731350d9840c6446db9276b04d593cc23

Requested by: @MaskRay

>From 217753243b286ff4787549ad8bd913965897d0d2 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Tue, 25 Mar 2025 21:17:37 -0700
Subject: [PATCH] [MC,COFF] .safeseh: avoid changeSection (#132624)

The directive temporarily switches to the .sxdata section to emit data,
and then calls `insert`, which makes `CurFrag` out of sync of the
current section. Call push/switch/pop instead.

Related to #132464

(cherry picked from commit ece72e2731350d9840c6446db9276b04d593cc23)
---
 llvm/lib/MC/MCWinCOFFStreamer.cpp | 4 +++-
 llvm/test/CodeGen/X86/win32-eh.ll | 9 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp 
b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 8fd46bc8b0255..3720d6e26fe46 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -299,7 +299,8 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
 return;
 
   MCSection *SXData = getContext().getObjectFileInfo()->getSXDataSection();
-  changeSection(SXData);
+  pushSection();
+  switchSection(SXData);
   SXData->ensureMinAlignment(Align(4));
 
   insert(getContext().allocFragment(Symbol));
@@ -310,6 +311,7 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
   // function. Go ahead and oblige it here.
   CSymbol->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION
<< COFF::SCT_COMPLEX_TYPE_SHIFT);
+  popSection();
 }
 
 void MCWinCOFFStreamer::emitCOFFSymbolIndex(MCSymbol const *Symbol) {
diff --git a/llvm/test/CodeGen/X86/win32-eh.ll 
b/llvm/test/CodeGen/X86/win32-eh.ll
index 82dc4beaf972b..d3d19ede546d6 100644
--- a/llvm/test/CodeGen/X86/win32-eh.ll
+++ b/llvm/test/CodeGen/X86/win32-eh.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple=i686-pc-windows-msvc -filetype=obj < %s -o %t
 
 declare void @may_throw_or_crash()
 declare i32 @_except_handler3(...)
@@ -208,6 +209,14 @@ catch:
 ; CHECK-NEXT:  .long   0
 ; CHECK-NEXT:  .long   1
 
+; CHECK-LABEL: inlineasm:
+; CHECK: .safeseh my_handler
+define i32 @inlineasm() {
+entry:
+  call void asm sideeffect ".safeseh my_handler", 
"~{dirflag},~{fpsr},~{flags}"()
+  ret i32 0
+}
+
 ; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
 ; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
 ; CHECK-NEXT: jmp  ___CxxFrameHandler3 # TAILCALL

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [MC, COFF] .safeseh: avoid changeSection (#132624) (PR #133591)

2025-03-29 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: None (llvmbot)


Changes

Backport ece72e2731350d9840c6446db9276b04d593cc23

Requested by: @MaskRay

---
Full diff: https://github.com/llvm/llvm-project/pull/133591.diff


2 Files Affected:

- (modified) llvm/lib/MC/MCWinCOFFStreamer.cpp (+3-1) 
- (modified) llvm/test/CodeGen/X86/win32-eh.ll (+9) 


``diff
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp 
b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 8fd46bc8b0255..3720d6e26fe46 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -299,7 +299,8 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
 return;
 
   MCSection *SXData = getContext().getObjectFileInfo()->getSXDataSection();
-  changeSection(SXData);
+  pushSection();
+  switchSection(SXData);
   SXData->ensureMinAlignment(Align(4));
 
   insert(getContext().allocFragment(Symbol));
@@ -310,6 +311,7 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
   // function. Go ahead and oblige it here.
   CSymbol->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION
<< COFF::SCT_COMPLEX_TYPE_SHIFT);
+  popSection();
 }
 
 void MCWinCOFFStreamer::emitCOFFSymbolIndex(MCSymbol const *Symbol) {
diff --git a/llvm/test/CodeGen/X86/win32-eh.ll 
b/llvm/test/CodeGen/X86/win32-eh.ll
index 82dc4beaf972b..d3d19ede546d6 100644
--- a/llvm/test/CodeGen/X86/win32-eh.ll
+++ b/llvm/test/CodeGen/X86/win32-eh.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple=i686-pc-windows-msvc -filetype=obj < %s -o %t
 
 declare void @may_throw_or_crash()
 declare i32 @_except_handler3(...)
@@ -208,6 +209,14 @@ catch:
 ; CHECK-NEXT:  .long   0
 ; CHECK-NEXT:  .long   1
 
+; CHECK-LABEL: inlineasm:
+; CHECK: .safeseh my_handler
+define i32 @inlineasm() {
+entry:
+  call void asm sideeffect ".safeseh my_handler", 
"~{dirflag},~{fpsr},~{flags}"()
+  ret i32 0
+}
+
 ; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
 ; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
 ; CHECK-NEXT: jmp  ___CxxFrameHandler3 # TAILCALL

``




https://github.com/llvm/llvm-project/pull/133591
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [MC, COFF] .safeseh: avoid changeSection (#132624) (PR #133591)

2025-03-29 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: None (llvmbot)


Changes

Backport ece72e2731350d9840c6446db9276b04d593cc23

Requested by: @MaskRay

---
Full diff: https://github.com/llvm/llvm-project/pull/133591.diff


2 Files Affected:

- (modified) llvm/lib/MC/MCWinCOFFStreamer.cpp (+3-1) 
- (modified) llvm/test/CodeGen/X86/win32-eh.ll (+9) 


``diff
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp 
b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 8fd46bc8b0255..3720d6e26fe46 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -299,7 +299,8 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
 return;
 
   MCSection *SXData = getContext().getObjectFileInfo()->getSXDataSection();
-  changeSection(SXData);
+  pushSection();
+  switchSection(SXData);
   SXData->ensureMinAlignment(Align(4));
 
   insert(getContext().allocFragment(Symbol));
@@ -310,6 +311,7 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
   // function. Go ahead and oblige it here.
   CSymbol->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION
<< COFF::SCT_COMPLEX_TYPE_SHIFT);
+  popSection();
 }
 
 void MCWinCOFFStreamer::emitCOFFSymbolIndex(MCSymbol const *Symbol) {
diff --git a/llvm/test/CodeGen/X86/win32-eh.ll 
b/llvm/test/CodeGen/X86/win32-eh.ll
index 82dc4beaf972b..d3d19ede546d6 100644
--- a/llvm/test/CodeGen/X86/win32-eh.ll
+++ b/llvm/test/CodeGen/X86/win32-eh.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple=i686-pc-windows-msvc -filetype=obj < %s -o %t
 
 declare void @may_throw_or_crash()
 declare i32 @_except_handler3(...)
@@ -208,6 +209,14 @@ catch:
 ; CHECK-NEXT:  .long   0
 ; CHECK-NEXT:  .long   1
 
+; CHECK-LABEL: inlineasm:
+; CHECK: .safeseh my_handler
+define i32 @inlineasm() {
+entry:
+  call void asm sideeffect ".safeseh my_handler", 
"~{dirflag},~{fpsr},~{flags}"()
+  ret i32 0
+}
+
 ; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
 ; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
 ; CHECK-NEXT: jmp  ___CxxFrameHandler3 # TAILCALL

``




https://github.com/llvm/llvm-project/pull/133591
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [MC, COFF] .safeseh: avoid changeSection (#132624) (PR #133591)

2025-03-29 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/133591

>From 1a82d705b3a4a692663736b59917d3e8389342e4 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Tue, 25 Mar 2025 21:17:37 -0700
Subject: [PATCH] [MC,COFF] .safeseh: avoid changeSection (#132624)

The directive temporarily switches to the .sxdata section to emit data,
and then calls `insert`, which makes `CurFrag` out of sync of the
current section. Call push/switch/pop instead.

Related to #132464

(cherry picked from commit ece72e2731350d9840c6446db9276b04d593cc23)
---
 llvm/lib/MC/MCWinCOFFStreamer.cpp | 4 +++-
 llvm/test/CodeGen/X86/win32-eh.ll | 9 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp 
b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 8fd46bc8b0255..3720d6e26fe46 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -299,7 +299,8 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
 return;
 
   MCSection *SXData = getContext().getObjectFileInfo()->getSXDataSection();
-  changeSection(SXData);
+  pushSection();
+  switchSection(SXData);
   SXData->ensureMinAlignment(Align(4));
 
   insert(getContext().allocFragment(Symbol));
@@ -310,6 +311,7 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
   // function. Go ahead and oblige it here.
   CSymbol->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION
<< COFF::SCT_COMPLEX_TYPE_SHIFT);
+  popSection();
 }
 
 void MCWinCOFFStreamer::emitCOFFSymbolIndex(MCSymbol const *Symbol) {
diff --git a/llvm/test/CodeGen/X86/win32-eh.ll 
b/llvm/test/CodeGen/X86/win32-eh.ll
index 82dc4beaf972b..d3d19ede546d6 100644
--- a/llvm/test/CodeGen/X86/win32-eh.ll
+++ b/llvm/test/CodeGen/X86/win32-eh.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple=i686-pc-windows-msvc -filetype=obj < %s -o %t
 
 declare void @may_throw_or_crash()
 declare i32 @_except_handler3(...)
@@ -208,6 +209,14 @@ catch:
 ; CHECK-NEXT:  .long   0
 ; CHECK-NEXT:  .long   1
 
+; CHECK-LABEL: inlineasm:
+; CHECK: .safeseh my_handler
+define i32 @inlineasm() {
+entry:
+  call void asm sideeffect ".safeseh my_handler", 
"~{dirflag},~{fpsr},~{flags}"()
+  ret i32 0
+}
+
 ; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
 ; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
 ; CHECK-NEXT: jmp  ___CxxFrameHandler3 # TAILCALL

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [MC, COFF] .safeseh: avoid changeSection (#132624) (PR #133591)

2025-03-29 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/133591

>From 5ba194972878531b527f7370b509829a8e251949 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Tue, 25 Mar 2025 21:17:37 -0700
Subject: [PATCH] [MC,COFF] .safeseh: avoid changeSection (#132624)

The directive temporarily switches to the .sxdata section to emit data,
and then calls `insert`, which makes `CurFrag` out of sync of the
current section. Call push/switch/pop instead.

Related to #132464

(cherry picked from commit ece72e2731350d9840c6446db9276b04d593cc23)
---
 llvm/lib/MC/MCWinCOFFStreamer.cpp | 4 +++-
 llvm/test/CodeGen/X86/win32-eh.ll | 9 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp 
b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 8fd46bc8b0255..3720d6e26fe46 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -299,7 +299,8 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
 return;
 
   MCSection *SXData = getContext().getObjectFileInfo()->getSXDataSection();
-  changeSection(SXData);
+  pushSection();
+  switchSection(SXData);
   SXData->ensureMinAlignment(Align(4));
 
   insert(getContext().allocFragment(Symbol));
@@ -310,6 +311,7 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const 
*Symbol) {
   // function. Go ahead and oblige it here.
   CSymbol->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION
<< COFF::SCT_COMPLEX_TYPE_SHIFT);
+  popSection();
 }
 
 void MCWinCOFFStreamer::emitCOFFSymbolIndex(MCSymbol const *Symbol) {
diff --git a/llvm/test/CodeGen/X86/win32-eh.ll 
b/llvm/test/CodeGen/X86/win32-eh.ll
index 82dc4beaf972b..d3d19ede546d6 100644
--- a/llvm/test/CodeGen/X86/win32-eh.ll
+++ b/llvm/test/CodeGen/X86/win32-eh.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple=i686-pc-windows-msvc -filetype=obj < %s -o %t
 
 declare void @may_throw_or_crash()
 declare i32 @_except_handler3(...)
@@ -208,6 +209,14 @@ catch:
 ; CHECK-NEXT:  .long   0
 ; CHECK-NEXT:  .long   1
 
+; CHECK-LABEL: inlineasm:
+; CHECK: .safeseh my_handler
+define i32 @inlineasm() {
+entry:
+  call void asm sideeffect ".safeseh my_handler", 
"~{dirflag},~{fpsr},~{flags}"()
+  ret i32 0
+}
+
 ; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3:
 ; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax
 ; CHECK-NEXT: jmp  ___CxxFrameHandler3 # TAILCALL

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits