Skip to content

Commit 7f725c0

Browse files
committed
llvm.reloc.none takes a GlobalValue again
This avoids avoid modifying Module in ISel
1 parent 64f3f00 commit 7f725c0

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
@@ -4111,12 +4111,11 @@ static Value *optimizeModularFormat(CallInst *CI, IRBuilderBase &B) {
41114111
DenseSet<StringRef> Aspects(llvm::from_range,
41124112
ArrayRef<StringRef>(Args).drop_front(5));
41134113
Module *M = CI->getModule();
4114-
LLVMContext &Ctx = M->getContext();
41154114
Function *Callee = CI->getCalledFunction();
41164115
FunctionCallee ModularFn =
41174116
M->getOrInsertFunction(FnName, Callee->getFunctionType(),
41184117
Callee->getAttributes().removeFnAttribute(
4119-
Ctx, "modular-format"));
4118+
M->getContext(), "modular-format"));
41204119
CallInst *New = cast<CallInst>(CI->clone());
41214120
New->setCalledFunction(ModularFn);
41224121
New->removeFnAttr("modular-format");
@@ -4126,10 +4125,11 @@ static Value *optimizeModularFormat(CallInst *CI, IRBuilderBase &B) {
41264125
SmallString<20> Name = ImplName;
41274126
Name += '_';
41284127
Name += Aspect;
4128+
Constant *Sym =
4129+
M->getOrInsertGlobal(Name, Type::getInt8Ty(M->getContext()));
41294130
Function *RelocNoneFn =
41304131
Intrinsic::getOrInsertDeclaration(M, Intrinsic::reloc_none);
4131-
B.CreateCall(RelocNoneFn,
4132-
{MetadataAsValue::get(Ctx, MDString::get(Ctx, Name))});
4132+
B.CreateCall(RelocNoneFn, {Sym});
41334133
};
41344134

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

0 commit comments

Comments
 (0)