Skip to content

Commit 2ed9e3d

Browse files
committed
llvm.reloc.none takes a GlobalValue again
This avoids avoid modifying Module in ISel
1 parent 56fca31 commit 2ed9e3d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4021,12 +4021,11 @@ static Value *optimizeModularFormat(CallInst *CI, IRBuilderBase &B) {
40214021
DenseSet<StringRef> Aspects(llvm::from_range,
40224022
ArrayRef<StringRef>(Args).drop_front(5));
40234023
Module *M = CI->getModule();
4024-
LLVMContext &Ctx = M->getContext();
40254024
Function *Callee = CI->getCalledFunction();
40264025
FunctionCallee ModularFn =
40274026
M->getOrInsertFunction(FnName, Callee->getFunctionType(),
40284027
Callee->getAttributes().removeFnAttribute(
4029-
Ctx, "modular-format"));
4028+
M->getContext(), "modular-format"));
40304029
CallInst *New = cast<CallInst>(CI->clone());
40314030
New->setCalledFunction(ModularFn);
40324031
New->removeFnAttr("modular-format");
@@ -4036,10 +4035,11 @@ static Value *optimizeModularFormat(CallInst *CI, IRBuilderBase &B) {
40364035
SmallString<20> Name = ImplName;
40374036
Name += '_';
40384037
Name += Aspect;
4038+
Constant *Sym =
4039+
M->getOrInsertGlobal(Name, Type::getInt8Ty(M->getContext()));
40394040
Function *RelocNoneFn =
40404041
Intrinsic::getOrInsertDeclaration(M, Intrinsic::reloc_none);
4041-
B.CreateCall(RelocNoneFn,
4042-
{MetadataAsValue::get(Ctx, MDString::get(Ctx, Name))});
4042+
B.CreateCall(RelocNoneFn, {Sym});
40434043
};
40444044

40454045
if (Aspects.contains("float")) {

0 commit comments

Comments
 (0)