From 371a18bc2ef51b92ef45e91bb133aaafa905f534 Mon Sep 17 00:00:00 2001 From: Langston Barrett Date: Tue, 11 Oct 2022 14:29:19 -0400 Subject: [PATCH] Consistent names for GEP relations --- FactGenerator/include/predicates.inc | 15 +++++++-------- FactGenerator/src/InstructionVisitor.cpp | 12 ++++++------ datalog/export/debug-output-extended.dl | 2 +- datalog/export/debug-output.dl | 2 +- datalog/schema/getelementptr-instr.dl | 2 +- scripts/format.sh | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/FactGenerator/include/predicates.inc b/FactGenerator/include/predicates.inc index 6d6eb2e..5e2655f 100644 --- a/FactGenerator/include/predicates.inc +++ b/FactGenerator/include/predicates.inc @@ -330,14 +330,13 @@ PREDICATEI(cmpxchg, type) PREDICATEI(cmpxchg, is_volatile) GROUP_END(cmpxchg) -GROUP_BEGIN(gep) -// TODO(#42): Rename getelementptr to gep in Datalog -PREDICATE(gep, instr, getelementptr_instr) -PREDICATE(gep, base, getelementptr_instr_base) -PREDICATE(gep, index, getelementptr_instr_index) -PREDICATE(gep, nindices, getelementptr_instr_nindices) -PREDICATE(gep, inbounds, getelementptr_instr_is_inbounds) -GROUP_END(gep) +GROUP_BEGIN(getelementptr) +PREDICATE2(getelementptr, instr) +PREDICATEI(getelementptr, base) +PREDICATEI(getelementptr, index) +PREDICATEI(getelementptr, nindices) +PREDICATEI(getelementptr, inbounds) +GROUP_END(getelementptr) // Conversion Operations diff --git a/FactGenerator/src/InstructionVisitor.cpp b/FactGenerator/src/InstructionVisitor.cpp index 9d2d9c5..ba86cdd 100644 --- a/FactGenerator/src/InstructionVisitor.cpp +++ b/FactGenerator/src/InstructionVisitor.cpp @@ -443,14 +443,14 @@ void InstructionVisitor::visitFenceInst(const llvm::FenceInst &FI) { void InstructionVisitor::visitGetElementPtrInst( const llvm::GetElementPtrInst &GEP) { - refmode_t iref = recordInstruction(pred::gep::instr, GEP); - writeInstrOperand(pred::gep::base, iref, GEP.getPointerOperand()); + refmode_t iref = recordInstruction(pred::getelementptr::instr, GEP); + writeInstrOperand(pred::getelementptr::base, iref, GEP.getPointerOperand()); for (unsigned index = 1; index < GEP.getNumOperands(); ++index) { const llvm::Value *GepOperand = GEP.getOperand(index); - refmode_t opref = - writeInstrOperand(pred::gep::index, iref, GepOperand, index - 1); + refmode_t opref = writeInstrOperand( + pred::getelementptr::index, iref, GepOperand, index - 1); if (const auto *c = dyn_cast(GepOperand)) { if (c->getUniqueInteger().isIntN(16)) { @@ -463,9 +463,9 @@ void InstructionVisitor::visitGetElementPtrInst( } } - gen.writeFact(pred::gep::nindices, iref, GEP.getNumIndices()); + gen.writeFact(pred::getelementptr::nindices, iref, GEP.getNumIndices()); - if (GEP.isInBounds()) gen.writeFact(pred::gep::inbounds, iref); + if (GEP.isInBounds()) gen.writeFact(pred::getelementptr::inbounds, iref); } void InstructionVisitor::visitPHINode(const llvm::PHINode &PHI) { diff --git a/datalog/export/debug-output-extended.dl b/datalog/export/debug-output-extended.dl index 34d73e3..309f784 100644 --- a/datalog/export/debug-output-extended.dl +++ b/datalog/export/debug-output-extended.dl @@ -415,7 +415,7 @@ .output getelementptr_instr_base_type (compress=true) .output getelementptr_instr_index (compress=true) .output getelementptr_instr_index_type (compress=true) -.output getelementptr_instr_is_inbounds (compress=true) +.output getelementptr_instr_inbounds (compress=true) .output getelementptr_instr_nindices (compress=true) .output getelementptr_instr_value_type (compress=true) .output getelementptr_instrterm_type (compress=true) diff --git a/datalog/export/debug-output.dl b/datalog/export/debug-output.dl index 34d73e3..309f784 100644 --- a/datalog/export/debug-output.dl +++ b/datalog/export/debug-output.dl @@ -415,7 +415,7 @@ .output getelementptr_instr_base_type (compress=true) .output getelementptr_instr_index (compress=true) .output getelementptr_instr_index_type (compress=true) -.output getelementptr_instr_is_inbounds (compress=true) +.output getelementptr_instr_inbounds (compress=true) .output getelementptr_instr_nindices (compress=true) .output getelementptr_instr_value_type (compress=true) .output getelementptr_instrterm_type (compress=true) diff --git a/datalog/schema/getelementptr-instr.dl b/datalog/schema/getelementptr-instr.dl index 844710b..94945d2 100644 --- a/datalog/schema/getelementptr-instr.dl +++ b/datalog/schema/getelementptr-instr.dl @@ -8,7 +8,7 @@ instr(v) :- getelementptr_instr(v). .decl getelementptr_instr_base(instr:GetElementPtrInstruction, ptr:Operand) -.decl getelementptr_instr_is_inbounds(instr:GetElementPtrInstruction) +.decl getelementptr_instr_inbounds(instr:GetElementPtrInstruction) //------------------------------------------------------------------------------ diff --git a/scripts/format.sh b/scripts/format.sh index 96eb14c..692a534 100644 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -2,6 +2,6 @@ set -eo pipefail -for f in ./*.cpp ./FactGenerator/**/*.cpp; do +for f in ./src/*.cpp ./FactGenerator/**/*.cpp; do clang-format-10 -i "${f}" done