[LLD][COFF] Fix out-of-bounds write when filling gaps with INT3 in code sections (#180411)
When merging `.bss` into a code section (e.g., `/MERGE:.bss=.text`), the
INT3 gap-filling loop in `writeSections()` would write past the output
buffer. This happens because `.bss` chunks have `hasData=false`, so they
contribute to `VirtualSize` but not `SizeOfRawData`. The loop was using
chunk RVAs without checking if they exceeded the raw data region.
This caused a crash on Windows with `/FILEALIGN:1` (access violation
0xC0000005). The tight alignment leaves no slack in the mapped buffer,
so the overflow immediately hits unmapped memory.
The fix bounds all memset operations to `rawSize` and exits early when
encountering chunks beyond the raw data boundary.
Fixes #180406
[Verifier] Make verifier fail when global variable size exceeds address space size (#179625)
When a global variable has a size that exceeds the size of the address
space it resides in, the verifier should fail as the variable can
neither be materialized nor fully accessed. This patch adds a check to
the verifier to enforce it.
---------
Signed-off-by: Steffen Holst Larsen <HolstLarsen.Steffen at amd.com>
Co-authored-by: Steffen Holst Larsen <HolstLarsen.Steffen at amd.com>
[libc++] Only make comparators transparent in __tree if they don't cause a conversion (#179453)
We're currently unwrapping `less<T>` even if the `key_type` isn't `T`.
This causes the removal of an implicit conversion to `const T&` if the
types mismatch. Making `less<T>` transparent in that case changes
overload resolution and makes it fail potentially.
Fixes #179319
[clang][bytecode] Only reject function types in Pointer::toRValue() (#180722)
No test because I'm not sure how to reproduce this, but this patch fixes
`CodeGen/ptrauth-qualifier-function.c`.
For function pointer types and function reference types, we use
`Pointer`s these days, so we _can_ return them.
[SPIRV] Add a `SPIRVTypeInst` type with some guardrails
Currently `SPIRVType` is an alias of `MachineInstr`:
```cpp
using SPIRVType = const MachineInstr;
```
Consider the function below from the backend:
```cpp
inline Register getTypeReg(MachineRegisterInfo *MRI, Register OpReg) {
SPIRVType *TypeInst = MRI->getVRegDef(OpReg);
return TypeInst && TypeInst->getOpcode() ==
SPIRV::OpFunctionParameter
? TypeInst->getOperand(1).getReg()
: OpReg;
}
```
[10 lines not shown]
[SPIRV] Add a `SPIRVTypeInst` type with some guardrails
Currently `SPIRVType` is an alias of `MachineInstr`:
```cpp
using SPIRVType = const MachineInstr;
```
Consider the function below from the backend:
```cpp
inline Register getTypeReg(MachineRegisterInfo *MRI, Register OpReg) {
SPIRVType *TypeInst = MRI->getVRegDef(OpReg);
return TypeInst && TypeInst->getOpcode() ==
SPIRV::OpFunctionParameter
? TypeInst->getOperand(1).getReg()
: OpReg;
}
```
[10 lines not shown]
[NFC][analyzer] Get rid of imaginary friends (of classes) (#180188)
These NodeBuilder classes were deleted from the codebase in 2011
(fifteen years ago!) by 3eae33412d18c4a4a4a8592898b3e65ad5946a89 so
don't declare them as friends.
[cross-project-tests][lldb] Further relax llvm::Expected test assertions
Fixes following error on macOS:
```
CHECK-NEXT: (llvm::SmallVector<int, 2>) value = size=2 {
^
<stdin>:41:65: note: scanning from here
(llvm::Expected<llvm::SmallVector<int, 2> &>) ExpectedVecRef = {
^
<stdin>:42:31: note: possible intended match here
(std::__1::reference_wrapper<llvm::SmallVector<int, 2> >::type) value = size=2 {
```
[libc++] Prepare for PR #134330 by migrating to std::__static_fancy_pointer_cast (#180546)
To reduce the noise in #134330 for `libcxx/include/__tree`, we migrate
from certain `static_cast` to `std::__static_fancy_pointer_cast` in this
separate patch.
This change is needed to properly work with fancy pointers like
`min_pointer` during constant evaluation for `std::map`
Co-authored-by: Joseph Huber <huberjn at outlook.com>
[Flang][OpenMP] Fix crash with character types in declare_reduction (#178038)
Fixes #177501
This PR fixes a compilation crash when using character types in OpenMP
REDUCTION clauses with declare_reduction directives.
The problem was that character types weren't being handled properly
during OpenMP lowering. Specifically:
- Missing character length parameters in hlfir.declare operations
- Incorrect type wrapping for by-ref reductions
- Missing special case handling for boxed/unboxed character types
The fix ensures character types are treated similarly to derived types
throughout the reduction pipeline, since fir::isa_trivial() excludes
them.
Added a regression test to verify the fix works for both allocatable and
non-allocatable character reductions.
[2 lines not shown]
[SPIRV] Add a `SPIRVTypeInst` type with some guardrails
Currently `SPIRVType` is an alias of `MachineInstr`:
```cpp
using SPIRVType = const MachineInstr;
```
Consider the function below from the backend:
```cpp
inline Register getTypeReg(MachineRegisterInfo *MRI, Register OpReg) {
SPIRVType *TypeInst = MRI->getVRegDef(OpReg);
return TypeInst && TypeInst->getOpcode() ==
SPIRV::OpFunctionParameter
? TypeInst->getOperand(1).getReg()
: OpReg;
}
```
[10 lines not shown]