Skip to content

Commit ce7b95e

Browse files
committed
Lower reloc.none in Global ISel
1 parent 49b0e09 commit ce7b95e

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
@@ -2645,6 +2645,16 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
26452645
case Intrinsic::experimental_convergence_entry:
26462646
case Intrinsic::experimental_convergence_loop:
26472647
return translateConvergenceControlIntrinsic(CI, ID, MIRBuilder);
2648+
case Intrinsic::reloc_none: {
2649+
Metadata *MD = cast<MetadataAsValue>(CI.getArgOperand(0))->getMetadata();
2650+
StringRef SymbolName = cast<MDString>(MD)->getString();
2651+
auto *M = const_cast<Module *>(CI.getModule());
2652+
auto *RelocSymbol = cast<GlobalVariable>(
2653+
M->getOrInsertGlobal(SymbolName, StructType::create(M->getContext())));
2654+
MIRBuilder.buildInstr(TargetOpcode::RELOC_NONE)
2655+
.addGlobalAddress(RelocSymbol);
2656+
return true;
2657+
}
26482658
}
26492659
return false;
26502660
}
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)