Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bfd4155
[VPlan] Don't apply predication discount to non-originally-predicated…
lukel97 Nov 10, 2025
e2a2c03
[DebugInfo] Add Verifier check for incorrectly-scoped retainedNodes (…
dzhidzhoev Nov 10, 2025
28d9f99
Remove unused standard headers: <string>, <optional>, <numeric>, <tup…
serge-sans-paille Nov 10, 2025
2705951
[X86] 2012-01-10-UndefExceptionEdge.ll - regenerate test checks (#167…
RKSimon Nov 10, 2025
309729e
[C2y] Claim nonconformance to WG14 N3348 (#166966)
AaronBallman Nov 10, 2025
342e28f
[clang][DebugInfo] Attach `DISubprogram` to additional call variants …
jryans Nov 10, 2025
f22d588
[mlir] Dialect Conversion: Fix expensive pattern check in no-rollback…
timnoack Nov 10, 2025
be84705
[HLSL][SPIRV] Add error test for unpackhalf2x16 (#166969)
tcorringham Nov 10, 2025
bba40ab
[MLIR][XeGPU] Decouple `inst_data` and `lane_layout` in propagation (…
akroviakov Nov 10, 2025
5b20453
[CodeGenPrepare] sinkCmpExpression - don't sink larger than legal int…
RKSimon Nov 10, 2025
a5d4ba7
[clang][doc] Document and prefer __asm as mangled name attribute (#16…
tambry Nov 10, 2025
1553f90
[MLIR][XeGPU][TransformOps] Add get_desc_op (#166801)
tkarna Nov 10, 2025
71cdd40
Allow avx512 bw masked intrinsics to be used in constexpr (#162871)
GrumpyPigSkin Nov 10, 2025
94a7006
[MLIR][XeGPU][TransformOps] Add set_op_layout_attr op (#166854)
tkarna Nov 10, 2025
69c8756
[NFC][PowerPC] Pre-commit adding test case: use millicode for memmove…
diggerlin Nov 10, 2025
c17a839
[OMPIRBuilder] Fix addrspace of internal critical section lock (#166459)
sarnex Nov 10, 2025
99a5e7b
[mlir][NFC] Split registerAndParseCLIOptions() in mlir-opt (#166538)
andrey-golubev Nov 10, 2025
2681497
[SPIRV] Allow multiple FuncParamAttr decoration on the same id. (#166…
maarquitos14 Nov 10, 2025
2d381bf
[MLIR][Python] add/fix docstrings in IRCore (#167063)
makslevental Nov 10, 2025
cd68056
[BOLT] Simplify RAState helpers (NFCI) (#162820)
bgergely0 Nov 10, 2025
51815b1
[Clang][ASTImporter] Implement AST import for CXXParenListInitExpr, S…
ganenkokb-yandex Nov 10, 2025
9625cf6
[BAZEL] Add missing dependency on /llvm:Support from XeGPUTransformOp…
WillFroom Nov 10, 2025
741ba82
AMDGPU: Add baseline test for known bits of AssertNoFPClass (#167288)
arsenm Nov 10, 2025
726c049
AMDGPU: Add baseline test for nofpclass on call results (#167263)
arsenm Nov 10, 2025
54053cf
AMDGPU: Add baseline tests for copysign with known signmask input (#1…
arsenm Nov 10, 2025
b9e22cc
[Flang][driver] Do not emit -latomic on link line on Windows (#164648)
mjklemm Nov 10, 2025
38cade7
[PGO][Offload] Fix missing names bug in GPU PGO (#166444)
EthanLuisMcDonough Nov 10, 2025
0d7c0b2
merge main into amd-staging
ronlieb Nov 10, 2025
26b4ac0
Revert "[OMPIRBuilder] Fix addrspace of internal critical section loc…
ronlieb Nov 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions bolt/include/bolt/Core/MCPlusBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1371,20 +1371,13 @@ class MCPlusBuilder {
/// Return true if \p Inst has RestoreState annotation.
bool hasRestoreState(const MCInst &Inst) const;

/// Stores RA Signed annotation on \p Inst.
void setRASigned(MCInst &Inst) const;
/// Sets kRASigned or kRAUnsigned annotation on \p Inst.
/// Fails if \p Inst has either annotation already set.
void setRAState(MCInst &Inst, bool State) const;

/// Return true if \p Inst has Signed RA annotation.
bool isRASigned(const MCInst &Inst) const;

/// Stores RA Unsigned annotation on \p Inst.
void setRAUnsigned(MCInst &Inst) const;

/// Return true if \p Inst has Unsigned RA annotation.
bool isRAUnsigned(const MCInst &Inst) const;

/// Return true if \p Inst doesn't have any annotation related to RA state.
bool isRAStateUnknown(const MCInst &Inst) const;
/// Return true if \p Inst has kRASigned annotation, false if it has
/// kRAUnsigned annotation, and std::nullopt if neither annotation is set.
std::optional<bool> getRAState(const MCInst &Inst) const;

/// Return true if the instruction is a call with an exception handling info.
virtual bool isInvoke(const MCInst &Inst) const {
Expand Down
27 changes: 11 additions & 16 deletions bolt/lib/Core/MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,21 @@ bool MCPlusBuilder::hasRestoreState(const MCInst &Inst) const {
return hasAnnotation(Inst, MCAnnotation::kRestoreState);
}

void MCPlusBuilder::setRASigned(MCInst &Inst) const {
void MCPlusBuilder::setRAState(MCInst &Inst, bool State) const {
assert(!hasAnnotation(Inst, MCAnnotation::kRASigned));
setAnnotationOpValue(Inst, MCAnnotation::kRASigned, true);
}

bool MCPlusBuilder::isRASigned(const MCInst &Inst) const {
return hasAnnotation(Inst, MCAnnotation::kRASigned);
}

void MCPlusBuilder::setRAUnsigned(MCInst &Inst) const {
assert(!hasAnnotation(Inst, MCAnnotation::kRAUnsigned));
setAnnotationOpValue(Inst, MCAnnotation::kRAUnsigned, true);
if (State)
setAnnotationOpValue(Inst, MCAnnotation::kRASigned, true);
else
setAnnotationOpValue(Inst, MCAnnotation::kRAUnsigned, true);
}

bool MCPlusBuilder::isRAUnsigned(const MCInst &Inst) const {
return hasAnnotation(Inst, MCAnnotation::kRAUnsigned);
}

bool MCPlusBuilder::isRAStateUnknown(const MCInst &Inst) const {
return !(isRAUnsigned(Inst) || isRASigned(Inst));
std::optional<bool> MCPlusBuilder::getRAState(const MCInst &Inst) const {
if (hasAnnotation(Inst, MCAnnotation::kRASigned))
return true;
if (hasAnnotation(Inst, MCAnnotation::kRAUnsigned))
return false;
return std::nullopt;
}

std::optional<MCLandingPad> MCPlusBuilder::getEHInfo(const MCInst &Inst) const {
Expand Down
53 changes: 39 additions & 14 deletions bolt/lib/Passes/InsertNegateRAStatePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ using namespace llvm;
namespace llvm {
namespace bolt {

static bool PassFailed = false;

void InsertNegateRAState::runOnFunction(BinaryFunction &BF) {
if (PassFailed)
return;

BinaryContext &BC = BF.getBinaryContext();

if (BF.getState() == BinaryFunction::State::Empty)
Expand All @@ -39,26 +44,31 @@ void InsertNegateRAState::runOnFunction(BinaryFunction &BF) {
for (FunctionFragment &FF : BF.getLayout().fragments()) {
coverFunctionFragmentStart(BF, FF);
bool FirstIter = true;
MCInst PrevInst;
bool PrevRAState = false;
// As this pass runs after function splitting, we should only check
// consecutive instructions inside FunctionFragments.
for (BinaryBasicBlock *BB : FF) {
for (auto It = BB->begin(); It != BB->end(); ++It) {
MCInst &Inst = *It;
if (BC.MIB->isCFI(Inst))
continue;
auto RAState = BC.MIB->getRAState(Inst);
if (!RAState) {
BC.errs() << "BOLT-ERROR: unknown RAState after inferUnknownStates "
<< " in function " << BF.getPrintName() << "\n";
PassFailed = true;
return;
}
if (!FirstIter) {
// Consecutive instructions with different RAState means we need to
// add a OpNegateRAState.
if ((BC.MIB->isRASigned(PrevInst) && BC.MIB->isRAUnsigned(Inst)) ||
(BC.MIB->isRAUnsigned(PrevInst) && BC.MIB->isRASigned(Inst))) {
if (*RAState != PrevRAState)
It = BF.addCFIInstruction(
BB, It, MCCFIInstruction::createNegateRAState(nullptr));
}
} else {
FirstIter = false;
}
PrevInst = *It;
PrevRAState = *RAState;
}
}
}
Expand All @@ -81,10 +91,17 @@ void InsertNegateRAState::coverFunctionFragmentStart(BinaryFunction &BF,
});
// If a function is already split in the input, the first FF can also start
// with Signed state. This covers that scenario as well.
if (BC.MIB->isRASigned(*((*FirstNonEmpty)->begin()))) {
BF.addCFIInstruction(*FirstNonEmpty, (*FirstNonEmpty)->begin(),
MCCFIInstruction::createNegateRAState(nullptr));
auto II = (*FirstNonEmpty)->getFirstNonPseudo();
auto RAState = BC.MIB->getRAState(*II);
if (!RAState) {
BC.errs() << "BOLT-ERROR: unknown RAState after inferUnknownStates "
<< " in function " << BF.getPrintName() << "\n";
PassFailed = true;
return;
}
if (*RAState)
BF.addCFIInstruction(*FirstNonEmpty, II,
MCCFIInstruction::createNegateRAState(nullptr));
}

void InsertNegateRAState::inferUnknownStates(BinaryFunction &BF) {
Expand All @@ -96,15 +113,21 @@ void InsertNegateRAState::inferUnknownStates(BinaryFunction &BF) {
if (BC.MIB->isCFI(Inst))
continue;

if (!FirstIter && BC.MIB->isRAStateUnknown(Inst)) {
if (BC.MIB->isRASigned(PrevInst) || BC.MIB->isPSignOnLR(PrevInst)) {
BC.MIB->setRASigned(Inst);
} else if (BC.MIB->isRAUnsigned(PrevInst) ||
BC.MIB->isPAuthOnLR(PrevInst)) {
BC.MIB->setRAUnsigned(Inst);
auto RAState = BC.MIB->getRAState(Inst);
if (!FirstIter && !RAState) {
if (BC.MIB->isPSignOnLR(PrevInst))
RAState = true;
else if (BC.MIB->isPAuthOnLR(PrevInst))
RAState = false;
else {
auto PrevRAState = BC.MIB->getRAState(PrevInst);
RAState = PrevRAState ? *PrevRAState : false;
}
BC.MIB->setRAState(Inst, *RAState);
} else {
FirstIter = false;
if (!RAState)
BC.MIB->setRAState(Inst, BF.getInitialRAState());
}
PrevInst = Inst;
}
Expand Down Expand Up @@ -135,6 +158,8 @@ Error InsertNegateRAState::runOnFunctions(BinaryContext &BC) {
<< " functions "
<< format("(%.2lf%%).\n", (100.0 * FunctionsModified) /
BC.getBinaryFunctions().size());
if (PassFailed)
return createFatalBOLTError("");
return Error::success();
}

Expand Down
12 changes: 2 additions & 10 deletions bolt/lib/Passes/MarkRAStates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ bool MarkRAStates::runOnFunction(BinaryFunction &BF) {
BF.setIgnored();
return false;
}
// The signing instruction itself is unsigned, the next will be
// signed.
BC.MIB->setRAUnsigned(Inst);
} else if (BC.MIB->isPAuthOnLR(Inst)) {
if (!RAState) {
// RA authenticating instructions should only follow signed RA state.
Expand All @@ -86,15 +83,10 @@ bool MarkRAStates::runOnFunction(BinaryFunction &BF) {
BF.setIgnored();
return false;
}
// The authenticating instruction itself is signed, but the next will be
// unsigned.
BC.MIB->setRASigned(Inst);
} else if (RAState) {
BC.MIB->setRASigned(Inst);
} else {
BC.MIB->setRAUnsigned(Inst);
}

BC.MIB->setRAState(Inst, RAState);

// Updating RAState. All updates are valid from the next instruction.
// Because the same instruction can have remember and restore, the order
// here is relevant. This is the reason to loop over Annotations instead
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
}

def AsmLabel : InheritableAttr {
let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm__">];
let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm">, CustomKeyword<"__asm__">];
let Args = [
// Label specifies the mangled name for the decl.
StringArgument<"Label">, ];
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -4295,17 +4295,17 @@ used by other languages. (This prefix is also added to the standard Itanium
C++ ABI prefix on "mangled" symbol names, so that e.g. on such targets the true
symbol name for a C++ variable declared as ``int cppvar;`` would be
``__Z6cppvar``; note the two underscores.) This prefix is *not* added to the
symbol names specified by the ``asm`` attribute; programmers wishing to match a
C symbol name must compensate for this.
symbol names specified by the ``__asm`` attribute; programmers wishing to match
a C symbol name must compensate for this.

For example, consider the following C code:

.. code-block:: c

int var1 asm("altvar") = 1; // "altvar" in symbol table.
int var1 __asm("altvar") = 1; // "altvar" in symbol table.
int var2 = 1; // "_var2" in symbol table.

void func1(void) asm("altfunc");
void func1(void) __asm("altfunc");
void func1(void) {} // "altfunc" in symbol table.
void func2(void) {} // "_func2" in symbol table.

Expand Down
48 changes: 48 additions & 0 deletions clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ namespace clang {
ExpectedStmt VisitCXXFoldExpr(CXXFoldExpr *E);
ExpectedStmt VisitRequiresExpr(RequiresExpr* E);
ExpectedStmt VisitConceptSpecializationExpr(ConceptSpecializationExpr* E);
ExpectedStmt
VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr *E);
ExpectedStmt VisitPseudoObjectExpr(PseudoObjectExpr *E);
ExpectedStmt VisitCXXParenListInitExpr(CXXParenListInitExpr *E);

// Helper for chaining together multiple imports. If an error is detected,
// subsequent imports will return default constructed nodes, so that failure
Expand Down Expand Up @@ -9273,6 +9277,50 @@ ASTNodeImporter::VisitConceptSpecializationExpr(ConceptSpecializationExpr *E) {
const_cast<ImplicitConceptSpecializationDecl *>(CSD), &Satisfaction);
}

ExpectedStmt ASTNodeImporter::VisitSubstNonTypeTemplateParmPackExpr(
SubstNonTypeTemplateParmPackExpr *E) {
Error Err = Error::success();
auto ToType = importChecked(Err, E->getType());
auto ToPackLoc = importChecked(Err, E->getParameterPackLocation());
auto ToArgPack = importChecked(Err, E->getArgumentPack());
auto ToAssociatedDecl = importChecked(Err, E->getAssociatedDecl());
if (Err)
return std::move(Err);

return new (Importer.getToContext()) SubstNonTypeTemplateParmPackExpr(
ToType, E->getValueKind(), ToPackLoc, ToArgPack, ToAssociatedDecl,
E->getIndex(), E->getFinal());
}

ExpectedStmt ASTNodeImporter::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
SmallVector<Expr *, 4> ToSemantics(E->getNumSemanticExprs());
if (Error Err = ImportContainerChecked(E->semantics(), ToSemantics))
return std::move(Err);
auto ToSyntOrErr = import(E->getSyntacticForm());
if (!ToSyntOrErr)
return ToSyntOrErr.takeError();
return PseudoObjectExpr::Create(Importer.getToContext(), *ToSyntOrErr,
ToSemantics, E->getResultExprIndex());
}

ExpectedStmt
ASTNodeImporter::VisitCXXParenListInitExpr(CXXParenListInitExpr *E) {
Error Err = Error::success();
auto ToType = importChecked(Err, E->getType());
auto ToInitLoc = importChecked(Err, E->getInitLoc());
auto ToBeginLoc = importChecked(Err, E->getBeginLoc());
auto ToEndLoc = importChecked(Err, E->getEndLoc());
if (Err)
return std::move(Err);

SmallVector<Expr *, 4> ToArgs(E->getInitExprs().size());
if (Error Err = ImportContainerChecked(E->getInitExprs(), ToArgs))
return std::move(Err);
return CXXParenListInitExpr::Create(Importer.getToContext(), ToArgs, ToType,
E->getUserSpecifiedInitExprs().size(),
ToInitLoc, ToBeginLoc, ToEndLoc);
}

Error ASTNodeImporter::ImportOverriddenMethods(CXXMethodDecl *ToMethod,
CXXMethodDecl *FromMethod) {
Error ImportErrors = Error::success();
Expand Down
19 changes: 19 additions & 0 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "llvm/IR/Attributes.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
Expand Down Expand Up @@ -6289,6 +6290,24 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
pushDestroy(QualType::DK_nontrivial_c_struct, Ret.getAggregateAddress(),
RetTy);

// Generate function declaration DISuprogram in order to be used
// in debug info about call sites.
if (CGDebugInfo *DI = getDebugInfo()) {
// Ensure call site info would actually be emitted before collecting
// further callee info.
if (CalleeDecl && !CalleeDecl->hasAttr<NoDebugAttr>() &&
DI->getCallSiteRelatedAttrs() != llvm::DINode::FlagZero) {
CodeGenFunction CalleeCGF(CGM);
const GlobalDecl &CalleeGlobalDecl =
Callee.getAbstractInfo().getCalleeDecl();
CalleeCGF.CurGD = CalleeGlobalDecl;
FunctionArgList Args;
QualType ResTy = CalleeCGF.BuildFunctionArgList(CalleeGlobalDecl, Args);
DI->EmitFuncDeclForCallSite(
CI, DI->getFunctionType(CalleeDecl, ResTy, Args), CalleeGlobalDecl);
}
}

return Ret;
}

Expand Down
8 changes: 6 additions & 2 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5019,7 +5019,7 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,

void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
QualType CalleeType,
const FunctionDecl *CalleeDecl) {
GlobalDecl CalleeGlobalDecl) {
if (!CallOrInvoke)
return;
auto *Func = dyn_cast<llvm::Function>(CallOrInvoke->getCalledOperand());
Expand All @@ -5028,6 +5028,9 @@ void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
if (Func->getSubprogram())
return;

const FunctionDecl *CalleeDecl =
cast<FunctionDecl>(CalleeGlobalDecl.getDecl());

// Do not emit a declaration subprogram for a function with nodebug
// attribute, or if call site info isn't required.
if (CalleeDecl->hasAttr<NoDebugAttr>() ||
Expand All @@ -5038,7 +5041,8 @@ void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
// create the one describing the function in order to have complete
// call site debug info.
if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined())
EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType, Func);
EmitFunctionDecl(CalleeGlobalDecl, CalleeDecl->getLocation(), CalleeType,
Func);
}

void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) {
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/CodeGen/CGDebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ class CGDebugInfo {
/// This is needed for call site debug info.
void EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
QualType CalleeType,
const FunctionDecl *CalleeDecl);
GlobalDecl CalleeGlobalDecl);

/// Constructs the debug code for exiting a function.
void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn);
Expand Down Expand Up @@ -686,6 +686,10 @@ class CGDebugInfo {
/// Emit symbol for debugger that holds the pointer to the vtable.
void emitVTableSymbol(llvm::GlobalVariable *VTable, const CXXRecordDecl *RD);

/// Return flags which enable debug info emission for call sites, provided
/// that it is supported and enabled.
llvm::DINode::DIFlags getCallSiteRelatedAttrs() const;

private:
/// Amend \p I's DebugLoc with \p Group (its source atom group) and \p
/// Rank (lower nonzero rank is higher precedence). Does nothing if \p I
Expand Down Expand Up @@ -864,10 +868,6 @@ class CGDebugInfo {
StringRef LinkageName, llvm::dwarf::MemorySpace MS,
llvm::GlobalVariable *Var, llvm::DIScope *DContext);

/// Return flags which enable debug info emission for call sites, provided
/// that it is supported and enabled.
llvm::DINode::DIFlags getCallSiteRelatedAttrs() const;

/// Get the printing policy for producing names for debug info.
PrintingPolicy getPrintingPolicy() const;

Expand Down
Loading