Skip to content

Commit 821f9a9

Browse files
committed
llvm.reloc.none takes a GlobalValue again
This avoids avoid modifying Module in ISel
1 parent 4f489c1 commit 821f9a9

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
@@ -4091,12 +4091,11 @@ static Value *optimizeModularFormat(CallInst *CI, IRBuilderBase &B) {
40914091
DenseSet<StringRef> Aspects(llvm::from_range,
40924092
ArrayRef<StringRef>(Args).drop_front(5));
40934093
Module *M = CI->getModule();
4094-
LLVMContext &Ctx = M->getContext();
40954094
Function *Callee = CI->getCalledFunction();
40964095
FunctionCallee ModularFn =
40974096
M->getOrInsertFunction(FnName, Callee->getFunctionType(),
40984097
Callee->getAttributes().removeFnAttribute(
4099-
Ctx, "modular-format"));
4098+
M->getContext(), "modular-format"));
41004099
CallInst *New = cast<CallInst>(CI->clone());
41014100
New->setCalledFunction(ModularFn);
41024101
New->removeFnAttr("modular-format");
@@ -4106,10 +4105,11 @@ static Value *optimizeModularFormat(CallInst *CI, IRBuilderBase &B) {
41064105
SmallString<20> Name = ImplName;
41074106
Name += '_';
41084107
Name += Aspect;
4108+
Constant *Sym =
4109+
M->getOrInsertGlobal(Name, Type::getInt8Ty(M->getContext()));
41094110
Function *RelocNoneFn =
41104111
Intrinsic::getOrInsertDeclaration(M, Intrinsic::reloc_none);
4111-
B.CreateCall(RelocNoneFn,
4112-
{MetadataAsValue::get(Ctx, MDString::get(Ctx, Name))});
4112+
B.CreateCall(RelocNoneFn, {Sym});
41134113
};
41144114

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

0 commit comments

Comments
 (0)