Skip to content

Commit cc1668f

Browse files
committed
Take symbol name by metadata arg rather than ptr to GlobalValue
1 parent b8e772f commit cc1668f

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

llvm/docs/LangRef.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30462,14 +30462,14 @@ that purpose.
3046230462
Arguments:
3046330463
""""""""""
3046430464

30465-
The ``llvm.reloc.none`` intrinsic takes one argument, which may be any global
30466-
value.
30465+
The ``llvm.reloc.none`` intrinsic takes the symbol as a metadata string
30466+
argument.
3046730467

3046830468
Semantics:
3046930469
""""""""""
3047030470

30471-
This intrinsic emits a no-op relocation at the location of the intrinsic call
30472-
for the symbol that corresponds to the global value argument.
30471+
This intrinsic emits a no-op relocation for the symbol the location of the
30472+
intrinsic call.
3047330473

3047430474

3047530475
Stack Map Intrinsics

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,7 @@ def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatch
19171917
def int_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
19181918
[], [IntrNoMem]>;
19191919

1920-
def int_reloc_none : DefaultAttrsIntrinsic<[], [llvm_ptr_ty],
1920+
def int_reloc_none : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
19211921
[IntrHasSideEffects, IntrInaccessibleMemOnly, IntrWillReturn]>;
19221922

19231923
//===---------------- Vector Predication Intrinsics --------------===//

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7758,14 +7758,15 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
77587758
}
77597759

77607760
case Intrinsic::reloc_none: {
7761-
SDValue V = getValue(I.getArgOperand(0));
7762-
auto *GA = dyn_cast<GlobalAddressSDNode>(V);
7763-
if (!GA)
7764-
report_fatal_error("llvm.reloc.none operand must be a GlobalValue");
7761+
Metadata *MD = cast<MetadataAsValue>(I.getArgOperand(0))->getMetadata();
7762+
StringRef SymbolName = cast<MDString>(MD)->getString();
7763+
auto *M = const_cast<Module *>(I.getModule());
7764+
auto *RelocSymbol = cast<GlobalVariable>(
7765+
M->getOrInsertGlobal(SymbolName, StructType::create(M->getContext())));
77657766
SDValue Ops[2];
77667767
Ops[0] = getRoot();
7767-
Ops[1] = DAG.getTargetGlobalAddress(GA->getGlobal(), sdl, V.getValueType(),
7768-
GA->getOffset());
7768+
Ops[1] = DAG.getTargetGlobalAddress(
7769+
RelocSymbol, sdl, TLI.getPointerTy(DAG.getDataLayout()), 0);
77697770
DAG.setRoot(DAG.getNode(ISD::RELOC_NONE, sdl, MVT::Other, Ops));
77707771
return;
77717772
}

0 commit comments

Comments
 (0)