@@ -1059,18 +1059,19 @@ static void sendBytesData(FILE *out, const uint8_t *bytes, size_t len)
10591059static bool matchEval (const MatchExpr *expr, const Targets &targets,
10601060 const InstrInfo *I, const char *basename = nullptr ,
10611061 const Record **record = nullptr );
1062- static intptr_t lookupValue (const Action *action, const Targets &targets,
1063- const InstrInfo *I, const char *basename, intptr_t idx)
1062+ static intptr_t lookupValue (const Action *action, size_t idx,
1063+ const Targets &targets, const InstrInfo *I, const char *basename,
1064+ intptr_t pos)
10641065{
10651066 const Record *record = nullptr ;
10661067 bool pass = matchEval (action->match , targets, I, basename, &record);
10671068 if (!pass || record == nullptr )
10681069 error (" failed to lookup value from file \" %s.csv\" ; matching is "
10691070 " ambiguous" , basename);
1070- if (idx >= (intptr_t )record->size ())
1071+ if (pos >= (intptr_t )record->size ())
10711072 error (" failed to lookup value from file \" %s.csv\" ; index %zd is "
1072- " out-of-range 0..%zu" , basename, idx , record->size ()-1 );
1073- const char *str = record->at (idx );
1073+ " out-of-range 0..%zu" , basename, pos , record->size ()-1 );
1074+ const char *str = record->at (pos );
10741075 intptr_t x = nameToInt (basename, str);
10751076 return x;
10761077}
@@ -1079,24 +1080,24 @@ static intptr_t lookupValue(const Action *action, const Targets &targets,
10791080 * Send instructions to load an argument into a register.
10801081 */
10811082static Type sendLoadArgumentMetadata (FILE *out, CallInfo &info,
1082- const ELF *elf, const Action *action, const Argument &arg,
1083+ const ELF *elf, const Action *action, size_t idx, const Argument &arg,
10831084 const InstrInfo *I, intptr_t id, int argno, int regno)
10841085{
10851086 if (regno < 0 )
10861087 error (" failed to load argument; call instrumentation exceeds the "
10871088 " maximum number of arguments (%d)" , argno);
10881089 sendSaveRegToStack (out, info, getReg (regno));
10891090
1090- const Patch *patch = action->patch ;
1091+ const Patch *patch = action->patch [idx];
10911092 const char *name = patch->name +1 ;
10921093 bool _static = arg._static ;
10931094 Type t = TYPE_INT64;
10941095 switch (arg.kind )
10951096 {
10961097 case ARGUMENT_USER:
10971098 {
1098- intptr_t value = lookupValue (action, elf->targets , I, arg. name ,
1099- arg.value );
1099+ intptr_t value = lookupValue (action, idx, elf->targets , I,
1100+ arg.name , arg. value );
11001101 sendLoadValueMetadata (out, value, regno);
11011102 break ;
11021103 }
@@ -1491,11 +1492,11 @@ static void sendArgumentDataMetadata(FILE *out, const char *name,
14911492 * Build metadata.
14921493 */
14931494static bool sendMetadata (FILE *out, const ELF *elf, const Action *action,
1494- const InstrInfo *I, intptr_t id)
1495+ size_t idx, const InstrInfo *I, intptr_t id)
14951496{
14961497 if (action == nullptr )
14971498 return false ;
1498- const Patch *patch = action->patch ;
1499+ const Patch *patch = action->patch [idx] ;
14991500 const char *name = patch->name +1 ;
15001501
15011502 switch (patch->kind )
@@ -1550,8 +1551,8 @@ static bool sendMetadata(FILE *out, const ELF *elf, const Action *action,
15501551 for (const auto &arg: patch->args )
15511552 {
15521553 int regno = getArgRegIdx (sysv, argno);
1553- Type t = sendLoadArgumentMetadata (out, info, elf, action, arg ,
1554- I, id, argno, regno);
1554+ Type t = sendLoadArgumentMetadata (out, info, elf, action, idx ,
1555+ arg, I, id, argno, regno);
15551556 sig = setType (sig, t, argno);
15561557 argno++;
15571558 }
0 commit comments