diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 6604ec60d9ba..4999e619ecd0 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -2635,7 +2635,7 @@ For example: This attribute indicates that outlining passes should not modify the function. -``"modular-format"=",,,,"`` +``"modular-format"=",,,,,"`` This attribute indicates that the implementation is modular on a particular format string argument . When the argument for a given call is constant, the compiler may redirect the call to a modular implementation function @@ -2648,13 +2648,15 @@ For example: brought into the link to satisfy weak references in the modular implemenation function. - The first two arguments have the same semantics as the arguments to the C + The first three arguments have the same semantics as the arguments to the C ``format`` attribute. The following aspects are currently supported: - ``float``: The call has a floating point argument + + Call Site Attributes ---------------------- diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 83aa79899710..0e102175cbb4 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -4008,18 +4008,18 @@ static Value *optimizeModularFormat(CallInst *CI, IRBuilderBase &B) { SmallVector Args( llvm::split(CI->getFnAttr("modular-format").getValueAsString(), ',')); - // TODO: Examine the format argument in Args[0]. + // TODO: Make use of the first two arguments // TODO: Error handling unsigned FirstArgIdx; - if (!llvm::to_integer(Args[1], FirstArgIdx)) + if (!llvm::to_integer(Args[2], FirstArgIdx)) return nullptr; if (FirstArgIdx == 0) return nullptr; --FirstArgIdx; - StringRef FnName = Args[2]; - StringRef ImplName = Args[3]; + StringRef FnName = Args[3]; + StringRef ImplName = Args[4]; DenseSet Aspects(llvm::from_range, - ArrayRef(Args).drop_front(4)); + ArrayRef(Args).drop_front(5)); Module *M = CI->getModule(); LLVMContext &Ctx = M->getContext(); Function *Callee = CI->getCalledFunction();