================
@@ -208,10 +209,34 @@ void llvm::setKCFIType(Module &M, Function &F, StringRef
MangledType) {
std::string Type = MangledType.str();
if (M.getModuleFlag("cfi-normalize-integers"))
Type += ".normalized";
+
+ uint32_t OutHash = static_cast<uint32_t>(llvm::xxHash64(Type));
+ auto T = Triple(Twine(M.getTargetTriple()));
+ if (T.isX86() && T.isArch64Bit() && T.isOSLinux()) {
+ // Estimate the function's arity (i.e., the number of arguments) at the ABI
+ // level by counting the number of parameters that are likely to be passed
+ // as registers, such as pointers and 64-bit (or smaller) integers. The
+ // Linux x86-64 ABI allows up to 6 parameters to be passed in GPRs.
+ // Additional parameters or parameters larger than 64 bits may be passed on
+ // the stack, in which case the arity is denoted as 7.
+ size_t NumParams = F.arg_size();
+ bool MayHaveStackArgs = NumParams > 6;
+
+ for (unsigned int i = 0; !MayHaveStackArgs && i < NumParams; ++i) {
+ const llvm::Type *PT = F.getArg(i)->getType();
+ if (!(PT->isPointerTy() || PT->getIntegerBitWidth() <= 64))
----------------
phoebewang wrote:
Sorry, I don't understand the point of indirect calls. Here `setKCFIType` has
an argument `F` which never will be null. Why do we need another
`getCalledFunction()`?
https://github.com/llvm/llvm-project/pull/117121
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits