Skip to content

Commit b7f8a9c

Browse files
committed
Add a type arg
1 parent 68761d9 commit b7f8a9c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

llvm/docs/LangRef.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,7 +2635,7 @@ For example:
26352635
This attribute indicates that outlining passes should not modify the
26362636
function.
26372637

2638-
``"modular-format"="<string_idx>,<first_idx_to_check>,<modular_impl_fn>,<impl_name>,<aspects...>"``
2638+
``"modular-format"="<type>,<string_idx>,<first_idx_to_check>,<modular_impl_fn>,<impl_name>,<aspects...>"``
26392639
This attribute indicates that the implementation is modular on a particular
26402640
format string argument . When the argument for a given call is constant, the
26412641
compiler may redirect the call to a modular implementation function
@@ -2648,13 +2648,15 @@ For example:
26482648
brought into the link to satisfy weak references in the modular
26492649
implemenation function.
26502650

2651-
The first two arguments have the same semantics as the arguments to the C
2651+
The first three arguments have the same semantics as the arguments to the C
26522652
``format`` attribute.
26532653

26542654
The following aspects are currently supported:
26552655

26562656
- ``float``: The call has a floating point argument
26572657

2658+
2659+
26582660
Call Site Attributes
26592661
----------------------
26602662

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4008,18 +4008,18 @@ static Value *optimizeModularFormat(CallInst *CI, IRBuilderBase &B) {
40084008

40094009
SmallVector<StringRef> Args(
40104010
llvm::split(CI->getFnAttr("modular-format").getValueAsString(), ','));
4011-
// TODO: Examine the format argument in Args[0].
4011+
// TODO: Make use of the first two arguments
40124012
// TODO: Error handling
40134013
unsigned FirstArgIdx;
4014-
if (!llvm::to_integer(Args[1], FirstArgIdx))
4014+
if (!llvm::to_integer(Args[2], FirstArgIdx))
40154015
return nullptr;
40164016
if (FirstArgIdx == 0)
40174017
return nullptr;
40184018
--FirstArgIdx;
4019-
StringRef FnName = Args[2];
4020-
StringRef ImplName = Args[3];
4019+
StringRef FnName = Args[3];
4020+
StringRef ImplName = Args[4];
40214021
DenseSet<StringRef> Aspects(llvm::from_range,
4022-
ArrayRef<StringRef>(Args).drop_front(4));
4022+
ArrayRef<StringRef>(Args).drop_front(5));
40234023
Module *M = CI->getModule();
40244024
LLVMContext &Ctx = M->getContext();
40254025
Function *Callee = CI->getCalledFunction();

0 commit comments

Comments
 (0)