Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Use ArrayRef; style
  • Loading branch information
speednoisemovement committed Apr 8, 2024
commit 90db989814f94a4da8f34bd09c3838c91a0d0679
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/AsmPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ class AsmPrinter : public MachineFunctionPass {
virtual void emitFunctionHeaderComment();

/// This method emits prefix-like data before the current function.
void emitFunctionPrefix(const SmallVector<const Constant *, 1> &Prefix);
void emitFunctionPrefix(ArrayRef<const Constant *> Prefix);

/// Emit a blob of inline asm to the output streamer.
void
Expand Down
18 changes: 7 additions & 11 deletions llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,21 +927,18 @@ void AsmPrinter::emitDebugValue(const MCExpr *Value, unsigned Size) const {

void AsmPrinter::emitFunctionHeaderComment() {}

void AsmPrinter::emitFunctionPrefix(
const SmallVector<const Constant *, 1> &Prefix) {
void AsmPrinter::emitFunctionPrefix(ArrayRef<const Constant *> Prefix) {
const Function &F = MF->getFunction();
if (!MAI->hasSubsectionsViaSymbols()) {
for (auto &C : Prefix) {
for (auto &C : Prefix)
emitGlobalConstant(F.getParent()->getDataLayout(), C);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
return;
}
// Preserving prefix data on platforms which use subsections-via-symbols
// is a bit tricky. Here we introduce a symbol for the prefix data
// Preserving prefix-like data on platforms which use subsections-via-symbols
// is a bit tricky. Here we introduce a symbol for the prefix-like data
// and use the .alt_entry attribute to mark the function's real entry point
// as an alternative entry point to the prefix-data symbol.
MCSymbol *PrefixSym = OutContext.createLinkerPrivateTempSymbol();
OutStreamer->emitLabel(PrefixSym);
// as an alternative entry point to the symbol that precedes the function..
OutStreamer->emitLabel(OutContext.createLinkerPrivateTempSymbol());

for (auto &C : Prefix) {
emitGlobalConstant(F.getParent()->getDataLayout(), C);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Expand Down Expand Up @@ -990,9 +987,8 @@ void AsmPrinter::emitFunctionHeader() {
OutStreamer->emitSymbolAttribute(CurrentFnSym, MCSA_Cold);

// Emit the prefix data.
if (F.hasPrefixData()) {
if (F.hasPrefixData())
emitFunctionPrefix({F.getPrefixData()});
}

// Emit KCFI type information before patchable-function-prefix nops.
emitKCFITypeId(*MF);
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/AArch64/func-sanitizer.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
; CHECK-NEXT: // %bb.0:
; CHECK-NEXT: ret

; MACHO: ltmp0
; MACHO: ltmp0:
; MACHO-NEXT: .long 3238382334 ; 0xc105cafe
; MACHO-NEXT: .long 42 ; 0x2a
; MACHO-NEXT: .alt_entry __Z3funv
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/func-sanitizer.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
; CHECK-NEXT: # %bb.0:
; CHECK-NEXT: retq

; MACHO: ltmp0
; MACHO: ltmp0:
; MACHO-NEXT: .long 3238382334 ## 0xc105cafe
; MACHO-NEXT: .long 42 ## 0x2a
; MACHO-NEXT: .alt_entry __Z3funv
Expand Down