Skip to content

Commit 4c26a6c

Browse files
committed
Add a type arg
1 parent 23fca03 commit 4c26a6c

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
@@ -2633,7 +2633,7 @@ For example:
26332633
This attribute indicates that outlining passes should not modify the
26342634
function.
26352635

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

2649-
The first two arguments have the same semantics as the arguments to the C
2649+
The first three arguments have the same semantics as the arguments to the C
26502650
``format`` attribute.
26512651

26522652
The following aspects are currently supported:
26532653

26542654
- ``float``: The call has a floating point argument
26552655

2656+
2657+
26562658
Call Site Attributes
26572659
----------------------
26582660

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

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

39593959
SmallVector<StringRef> Args(
39603960
llvm::split(CI->getFnAttr("modular-format").getValueAsString(), ','));
3961-
// TODO: Examine the format argument in Args[0].
3961+
// TODO: Make use of the first two arguments
39623962
// TODO: Error handling
39633963
unsigned FirstArgIdx;
3964-
if (!llvm::to_integer(Args[1], FirstArgIdx))
3964+
if (!llvm::to_integer(Args[2], FirstArgIdx))
39653965
return nullptr;
39663966
if (FirstArgIdx == 0)
39673967
return nullptr;
39683968
--FirstArgIdx;
3969-
StringRef FnName = Args[2];
3970-
StringRef ImplName = Args[3];
3969+
StringRef FnName = Args[3];
3970+
StringRef ImplName = Args[4];
39713971
DenseSet<StringRef> Aspects(llvm::from_range,
3972-
ArrayRef<StringRef>(Args).drop_front(4));
3972+
ArrayRef<StringRef>(Args).drop_front(5));
39733973
Module *M = CI->getModule();
39743974
LLVMContext &Ctx = M->getContext();
39753975
Function *Callee = CI->getCalledFunction();

0 commit comments

Comments
 (0)