Skip to content

Commit 56fca31

Browse files
committed
Add a type arg
1 parent b1abfcf commit 56fca31

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
@@ -2637,7 +2637,7 @@ For example:
26372637
This attribute indicates that outlining passes should not modify the
26382638
function.
26392639

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

2653-
The first two arguments have the same semantics as the arguments to the C
2653+
The first three arguments have the same semantics as the arguments to the C
26542654
``format`` attribute.
26552655

26562656
The following aspects are currently supported:
26572657

26582658
- ``float``: The call has a floating point argument
26592659

2660+
2661+
26602662
Call Site Attributes
26612663
----------------------
26622664

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)