[llvm] Refactor try demangle for vfabi to use only the vector abi mangled names (PR #67430)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 5 11:05:09 PDT 2023
================
@@ -27,15 +27,22 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
// present. We need to make sure we can even invoke
// `getOrInsertFunction` because such method asserts on strings with
// zeroes.
- if (!MangledName.empty() && MangledName.find_first_of(0) == StringRef::npos)
- M->getOrInsertFunction(
- MangledName,
- FunctionType::get(Type::getVoidTy(M->getContext()), false));
- const auto Info = VFABI::tryDemangleForVFABI(MangledName, *M);
+ if (!MangledName.empty() && MangledName.find_first_of(0) == StringRef::npos) {
+ FunctionType *FTy =
+ FunctionType::get(Type::getVoidTy(M->getContext()), false);
+ FunctionCallee F = M->getOrInsertFunction(MangledName, FTy);
+ // Fake the arguments to the CallInst.
+ SmallVector<Value *> Args;
+ for (Type *ParamTy : FTy->params()) {
+ Args.push_back(Constant::getNullValue(ParamTy));
+ }
+ std::unique_ptr<CallInst> CI(CallInst::Create(F, Args));
+ const auto Info = VFABI::tryDemangleForVFABI(MangledName, *(CI.get()));
- // Do not optimize away the return value. Inspired by
- // https://github.com/google/benchmark/blob/main/include/benchmark/benchmark.h#L307-L345
- asm volatile("" : : "r,m"(Info) : "memory");
+ // Do not optimize away the return value. Inspired by
+ // https://github.com/google/benchmark/blob/main/include/benchmark/benchmark.h#L307-L345
+ asm volatile("" : : "r,m"(Info) : "memory");
- return 0;
+ return 0;
----------------
JolantaJensen wrote:
Here, I'm only returning a value if the if condition is true but it does not make a sense to me to try to call `VFABI::tryDemangleForVFABI` if we do not have a CI. Grateful for suggestions how to rewrite this part.
https://github.com/llvm/llvm-project/pull/67430
More information about the llvm-commits
mailing list