Skip to content

Commit a045626

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

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
@@ -30691,14 +30691,14 @@ that purpose.
3069130691
Arguments:
3069230692
""""""""""
3069330693

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

3069730697
Semantics:
3069830698
""""""""""
3069930699

30700-
This intrinsic emits a no-op relocation at the location of the intrinsic call
30701-
for the symbol that corresponds to the global value argument.
30700+
This intrinsic emits a no-op relocation for the symbol the location of the
30701+
intrinsic call.
3070230702

3070330703

3070430704
Stack Map Intrinsics

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatch
19131913
def int_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
19141914
[], [IntrNoMem]>;
19151915

1916-
def int_reloc_none : DefaultAttrsIntrinsic<[], [llvm_ptr_ty],
1916+
def int_reloc_none : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
19171917
[IntrHasSideEffects, IntrInaccessibleMemOnly, IntrWillReturn]>;
19181918

19191919
//===---------------- Vector Predication Intrinsics --------------===//

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

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

77537753
case Intrinsic::reloc_none: {
7754-
SDValue V = getValue(I.getArgOperand(0));
7755-
auto *GA = dyn_cast<GlobalAddressSDNode>(V);
7756-
if (!GA)
7757-
report_fatal_error("llvm.reloc.none operand must be a GlobalValue");
7754+
Metadata *MD = cast<MetadataAsValue>(I.getArgOperand(0))->getMetadata();
7755+
StringRef SymbolName = cast<MDString>(MD)->getString();
7756+
auto *M = const_cast<Module *>(I.getModule());
7757+
auto *RelocSymbol = cast<GlobalVariable>(
7758+
M->getOrInsertGlobal(SymbolName, StructType::create(M->getContext())));
77587759
SDValue Ops[2];
77597760
Ops[0] = getRoot();
7760-
Ops[1] = DAG.getTargetGlobalAddress(GA->getGlobal(), sdl, V.getValueType(),
7761-
GA->getOffset());
7761+
Ops[1] = DAG.getTargetGlobalAddress(
7762+
RelocSymbol, sdl, TLI.getPointerTy(DAG.getDataLayout()), 0);
77627763
DAG.setRoot(DAG.getNode(ISD::RELOC_NONE, sdl, MVT::Other, Ops));
77637764
return;
77647765
}

0 commit comments

Comments
 (0)