Skip to content

Commit c89242c

Browse files
committed
Lower reloc.none in Global ISel
1 parent a2a222a commit c89242c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,6 +2654,16 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
26542654
case Intrinsic::experimental_convergence_entry:
26552655
case Intrinsic::experimental_convergence_loop:
26562656
return translateConvergenceControlIntrinsic(CI, ID, MIRBuilder);
2657+
case Intrinsic::reloc_none: {
2658+
Metadata *MD = cast<MetadataAsValue>(CI.getArgOperand(0))->getMetadata();
2659+
StringRef SymbolName = cast<MDString>(MD)->getString();
2660+
auto *M = const_cast<Module *>(CI.getModule());
2661+
auto *RelocSymbol = cast<GlobalVariable>(
2662+
M->getOrInsertGlobal(SymbolName, StructType::create(M->getContext())));
2663+
MIRBuilder.buildInstr(TargetOpcode::RELOC_NONE)
2664+
.addGlobalAddress(RelocSymbol);
2665+
return true;
2666+
}
26572667
}
26582668
return false;
26592669
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=CHECK
3+
4+
define void @test_reloc_none() {
5+
; CHECK-LABEL: test_reloc_none:
6+
; CHECK: # %bb.0:
7+
; CHECK-NEXT: .Lreloc_none0:
8+
; CHECK-NEXT: .reloc .Lreloc_none0, BFD_RELOC_NONE, foo
9+
; CHECK-NEXT: retq
10+
call void @llvm.reloc.none(metadata !"foo")
11+
ret void
12+
}
13+
14+
declare void @llvm.reloc.none(metadata)

0 commit comments

Comments
 (0)