Skip to content

Commit 138a126

Browse files
author
git apple-llvm automerger
committed
Merge commit '5f08fb4d72f6' from llvm.org/main into next
2 parents 2dbcdc6 + 5f08fb4 commit 138a126

File tree

21 files changed

+5779
-5647
lines changed

21 files changed

+5779
-5647
lines changed

llvm/docs/LangRef.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31022,6 +31022,37 @@ This intrinsic does nothing, but optimizers must consider it a use of its single
3102231022
operand and should try to preserve the intrinsic and its position in the
3102331023
function.
3102431024

31025+
.. _llvm_reloc_none:
31026+
31027+
'``llvm.reloc.none``' Intrinsic
31028+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31029+
31030+
Syntax:
31031+
"""""""
31032+
31033+
::
31034+
31035+
declare void @llvm.reloc.none(metadata !<name_str>)
31036+
31037+
Overview:
31038+
"""""""""
31039+
31040+
The ``llvm.reloc.none`` intrinsic emits a no-op relocation against a given
31041+
operand symbol. This can bring the symbol definition into the link without
31042+
emitting any code or data to the binary for that purpose.
31043+
31044+
Arguments:
31045+
""""""""""
31046+
31047+
The ``llvm.reloc.none`` intrinsic takes the symbol as a metadata string
31048+
argument.
31049+
31050+
Semantics:
31051+
""""""""""
31052+
31053+
This intrinsic emits a no-op relocation for the symbol at the location of the
31054+
intrinsic call.
31055+
3102531056

3102631057
Stack Map Intrinsics
3102731058
--------------------

llvm/include/llvm/CodeGen/ISDOpcodes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,9 @@ enum NodeType {
15371537
#define BEGIN_REGISTER_VP_SDNODE(VPSDID, ...) VPSDID,
15381538
#include "llvm/IR/VPIntrinsics.def"
15391539

1540+
// Issue a no-op relocation against a given symbol at the current location.
1541+
RELOC_NONE,
1542+
15401543
// The `llvm.experimental.convergence.*` intrinsics.
15411544
CONVERGENCECTRL_ANCHOR,
15421545
CONVERGENCECTRL_ENTRY,

llvm/include/llvm/CodeGen/SelectionDAGISel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ class SelectionDAGISel {
474474
void Select_WRITE_REGISTER(SDNode *Op);
475475
void Select_UNDEF(SDNode *N);
476476
void Select_FAKE_USE(SDNode *N);
477+
void Select_RELOC_NONE(SDNode *N);
477478
void CannotYetSelect(SDNode *N);
478479

479480
void Select_FREEZE(SDNode *N);

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,9 @@ def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatch
19341934
def int_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
19351935
[], [IntrNoMem]>;
19361936

1937+
def int_reloc_none : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
1938+
[IntrNoMem, IntrHasSideEffects]>;
1939+
19371940
//===---------------- Vector Predication Intrinsics --------------===//
19381941
// Memory Intrinsics
19391942
def int_vp_store : DefaultAttrsIntrinsic<[],

llvm/include/llvm/Support/TargetOpcodes.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ HANDLE_TARGET_OPCODE(MEMBARRIER)
233233
// using.
234234
HANDLE_TARGET_OPCODE(JUMP_TABLE_DEBUG_INFO)
235235

236+
// Issue a no-op relocation against a given symbol at the current location.
237+
HANDLE_TARGET_OPCODE(RELOC_NONE)
238+
236239
HANDLE_TARGET_OPCODE(CONVERGENCECTRL_ENTRY)
237240
HANDLE_TARGET_OPCODE(CONVERGENCECTRL_ANCHOR)
238241
HANDLE_TARGET_OPCODE(CONVERGENCECTRL_LOOP)

llvm/include/llvm/Target/Target.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,11 @@ def JUMP_TABLE_DEBUG_INFO : StandardPseudoInstruction {
15541554
let Size = 0;
15551555
let isMeta = true;
15561556
}
1557+
def RELOC_NONE : StandardPseudoInstruction {
1558+
let OutOperandList = (outs);
1559+
let InOperandList = (ins unknown:$symbol);
1560+
let hasSideEffects = true;
1561+
}
15571562

15581563
let hasSideEffects = false, isMeta = true, isConvergent = true in {
15591564
def CONVERGENCECTRL_ANCHOR : StandardPseudoInstruction {

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,17 @@ void AsmPrinter::emitFunctionBody() {
20882088
// This is only used to influence register allocation behavior, no
20892089
// actual initialization is needed.
20902090
break;
2091+
case TargetOpcode::RELOC_NONE: {
2092+
// Generate a temporary label for the current PC.
2093+
MCSymbol *Sym = OutContext.createTempSymbol("reloc_none");
2094+
OutStreamer->emitLabel(Sym);
2095+
const MCExpr *Dot = MCSymbolRefExpr::create(Sym, OutContext);
2096+
const MCExpr *Value = MCSymbolRefExpr::create(
2097+
OutContext.getOrCreateSymbol(MI.getOperand(0).getSymbolName()),
2098+
OutContext);
2099+
OutStreamer->emitRelocDirective(*Dot, "BFD_RELOC_NONE", Value, SMLoc());
2100+
break;
2101+
}
20912102
default:
20922103
emitInstruction(&MI);
20932104

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2700,6 +2700,13 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
27002700
case Intrinsic::experimental_convergence_entry:
27012701
case Intrinsic::experimental_convergence_loop:
27022702
return translateConvergenceControlIntrinsic(CI, ID, MIRBuilder);
2703+
case Intrinsic::reloc_none: {
2704+
Metadata *MD = cast<MetadataAsValue>(CI.getArgOperand(0))->getMetadata();
2705+
StringRef SymbolName = cast<MDString>(MD)->getString();
2706+
MIRBuilder.buildInstr(TargetOpcode::RELOC_NONE)
2707+
.addExternalSymbol(SymbolName.data());
2708+
return true;
2709+
}
27032710
}
27042711
return false;
27052712
}

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7843,6 +7843,17 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
78437843
return;
78447844
}
78457845

7846+
case Intrinsic::reloc_none: {
7847+
Metadata *MD = cast<MetadataAsValue>(I.getArgOperand(0))->getMetadata();
7848+
StringRef SymbolName = cast<MDString>(MD)->getString();
7849+
SDValue Ops[2] = {
7850+
getRoot(),
7851+
DAG.getTargetExternalSymbol(
7852+
SymbolName.data(), TLI.getProgramPointerTy(DAG.getDataLayout()))};
7853+
DAG.setRoot(DAG.getNode(ISD::RELOC_NONE, sdl, MVT::Other, Ops));
7854+
return;
7855+
}
7856+
78467857
case Intrinsic::eh_exceptionpointer:
78477858
case Intrinsic::eh_exceptioncode: {
78487859
// Get the exception pointer vreg, copy from it, and resize it to fit.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
472472
case ISD::LIFETIME_END: return "lifetime.end";
473473
case ISD::FAKE_USE:
474474
return "fake_use";
475+
case ISD::RELOC_NONE:
476+
return "reloc_none";
475477
case ISD::PSEUDO_PROBE:
476478
return "pseudoprobe";
477479
case ISD::GC_TRANSITION_START: return "gc_transition.start";

0 commit comments

Comments
 (0)