Skip to content

Commit 64f3f00

Browse files
committed
Add a type arg
1 parent c0571f9 commit 64f3f00

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
@@ -2747,7 +2747,7 @@ For example:
27472747
all arguments are not undef and not poison. Otherwise, it is undefined
27482748
behavior.
27492749

2750-
``"modular-format"="<string_idx>,<first_idx_to_check>,<modular_impl_fn>,<impl_name>,<aspects...>"``
2750+
``"modular-format"="<type>,<string_idx>,<first_idx_to_check>,<modular_impl_fn>,<impl_name>,<aspects...>"``
27512751
This attribute indicates that the implementation is modular on a particular
27522752
format string argument . When the argument for a given call is constant, the
27532753
compiler may redirect the call to a modular implementation function
@@ -2760,13 +2760,15 @@ For example:
27602760
brought into the link to satisfy weak references in the modular
27612761
implemenation function.
27622762

2763-
The first two arguments have the same semantics as the arguments to the C
2763+
The first three arguments have the same semantics as the arguments to the C
27642764
``format`` attribute.
27652765

27662766
The following aspects are currently supported:
27672767

27682768
- ``float``: The call has a floating point argument
27692769

2770+
2771+
27702772
Call Site Attributes
27712773
----------------------
27722774

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

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

40994099
SmallVector<StringRef> Args(
41004100
llvm::split(CI->getFnAttr("modular-format").getValueAsString(), ','));
4101-
// TODO: Examine the format argument in Args[0].
4101+
// TODO: Make use of the first two arguments
41024102
// TODO: Error handling
41034103
unsigned FirstArgIdx;
4104-
if (!llvm::to_integer(Args[1], FirstArgIdx))
4104+
if (!llvm::to_integer(Args[2], FirstArgIdx))
41054105
return nullptr;
41064106
if (FirstArgIdx == 0)
41074107
return nullptr;
41084108
--FirstArgIdx;
4109-
StringRef FnName = Args[2];
4110-
StringRef ImplName = Args[3];
4109+
StringRef FnName = Args[3];
4110+
StringRef ImplName = Args[4];
41114111
DenseSet<StringRef> Aspects(llvm::from_range,
4112-
ArrayRef<StringRef>(Args).drop_front(4));
4112+
ArrayRef<StringRef>(Args).drop_front(5));
41134113
Module *M = CI->getModule();
41144114
LLVMContext &Ctx = M->getContext();
41154115
Function *Callee = CI->getCalledFunction();

0 commit comments

Comments
 (0)