aboutsummaryrefslogtreecommitdiff
path: root/instrumentation/cmplog-routines-pass.cc
diff options
context:
space:
mode:
Diffstat (limited to 'instrumentation/cmplog-routines-pass.cc')
-rw-r--r--instrumentation/cmplog-routines-pass.cc59
1 files changed, 31 insertions, 28 deletions
diff --git a/instrumentation/cmplog-routines-pass.cc b/instrumentation/cmplog-routines-pass.cc
index 8205cfb0..78317d5d 100644
--- a/instrumentation/cmplog-routines-pass.cc
+++ b/instrumentation/cmplog-routines-pass.cc
@@ -5,7 +5,7 @@
Written by Andrea Fioraldi <andreafioraldi@gmail.com>
Copyright 2015, 2016 Google Inc. All rights reserved.
- Copyright 2019-2022 AFLplusplus Project. All rights reserved.
+ Copyright 2019-2024 AFLplusplus Project. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -38,7 +38,9 @@
#include "llvm/IR/Module.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#if LLVM_VERSION_MAJOR < 17
+ #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#endif
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Pass.h"
#include "llvm/Analysis/ValueTracking.h"
@@ -83,7 +85,7 @@ class CmpLogRoutines : public ModulePass {
#if LLVM_VERSION_MAJOR >= 11 /* use new pass manager */
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
#else
- bool runOnModule(Module &M) override;
+ bool runOnModule(Module &M) override;
#if LLVM_VERSION_MAJOR >= 4
StringRef getPassName() const override {
@@ -383,7 +385,8 @@ bool CmpLogRoutines::hookRtns(Module &M) {
isStrcmp &=
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) &&
- FT->getParamType(0) == IntegerType::getInt8PtrTy(M.getContext());
+ FT->getParamType(0) ==
+ IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
bool isStrncmp = (!FuncName.compare("strncmp") ||
!FuncName.compare("xmlStrncmp") ||
@@ -396,12 +399,12 @@ bool CmpLogRoutines::hookRtns(Module &M) {
!FuncName.compare("g_ascii_strncasecmp") ||
!FuncName.compare("Curl_strncasecompare") ||
!FuncName.compare("g_strncasecmp"));
- isStrncmp &= FT->getNumParams() == 3 &&
- FT->getReturnType()->isIntegerTy(32) &&
- FT->getParamType(0) == FT->getParamType(1) &&
- FT->getParamType(0) ==
- IntegerType::getInt8PtrTy(M.getContext()) &&
- FT->getParamType(2)->isIntegerTy();
+ isStrncmp &=
+ FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
+ FT->getParamType(0) == FT->getParamType(1) &&
+ FT->getParamType(0) ==
+ IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
+ FT->getParamType(2)->isIntegerTy();
bool isGccStdStringStdString =
Callee->getName().find("__is_charIT_EE7__value") !=
@@ -506,8 +509,8 @@ bool CmpLogRoutines::hookRtns(Module &M) {
IRBuilder<> IRB(ThenTerm);
std::vector<Value *> args;
- Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
- Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
+ Value *v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
+ Value *v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
args.push_back(v1Pcasted);
args.push_back(v2Pcasted);
@@ -537,9 +540,9 @@ bool CmpLogRoutines::hookRtns(Module &M) {
IRBuilder<> IRB(ThenTerm);
std::vector<Value *> args;
- Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
- Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
- Value * v3Pbitcast = IRB.CreateBitCast(
+ Value *v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
+ Value *v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
+ Value *v3Pbitcast = IRB.CreateBitCast(
v3P, IntegerType::get(C, v3P->getType()->getPrimitiveSizeInBits()));
Value *v3Pcasted =
IRB.CreateIntCast(v3Pbitcast, IntegerType::get(C, 64), false);
@@ -572,8 +575,8 @@ bool CmpLogRoutines::hookRtns(Module &M) {
IRBuilder<> IRB(ThenTerm);
std::vector<Value *> args;
- Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
- Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
+ Value *v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
+ Value *v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
args.push_back(v1Pcasted);
args.push_back(v2Pcasted);
@@ -603,9 +606,9 @@ bool CmpLogRoutines::hookRtns(Module &M) {
IRBuilder<> IRB(ThenTerm);
std::vector<Value *> args;
- Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
- Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
- Value * v3Pbitcast = IRB.CreateBitCast(
+ Value *v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
+ Value *v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
+ Value *v3Pbitcast = IRB.CreateBitCast(
v3P, IntegerType::get(C, v3P->getType()->getPrimitiveSizeInBits()));
Value *v3Pcasted =
IRB.CreateIntCast(v3Pbitcast, IntegerType::get(C, 64), false);
@@ -638,8 +641,8 @@ bool CmpLogRoutines::hookRtns(Module &M) {
IRBuilder<> IRB(ThenTerm);
std::vector<Value *> args;
- Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
- Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
+ Value *v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
+ Value *v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
args.push_back(v1Pcasted);
args.push_back(v2Pcasted);
@@ -668,8 +671,8 @@ bool CmpLogRoutines::hookRtns(Module &M) {
IRBuilder<> IRB(ThenTerm);
std::vector<Value *> args;
- Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
- Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
+ Value *v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
+ Value *v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
args.push_back(v1Pcasted);
args.push_back(v2Pcasted);
@@ -698,8 +701,8 @@ bool CmpLogRoutines::hookRtns(Module &M) {
IRBuilder<> IRB(ThenTerm);
std::vector<Value *> args;
- Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
- Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
+ Value *v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
+ Value *v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
args.push_back(v1Pcasted);
args.push_back(v2Pcasted);
@@ -728,8 +731,8 @@ bool CmpLogRoutines::hookRtns(Module &M) {
IRBuilder<> IRB(ThenTerm);
std::vector<Value *> args;
- Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
- Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
+ Value *v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
+ Value *v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
args.push_back(v1Pcasted);
args.push_back(v2Pcasted);