Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent names for GEP relations #65

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions FactGenerator/include/predicates.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions FactGenerator/src/InstructionVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<llvm::Constant>(GepOperand)) {
if (c->getUniqueInteger().isIntN(16)) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion datalog/export/debug-output-extended.dl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion datalog/export/debug-output.dl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion datalog/schema/getelementptr-instr.dl
Original file line number Diff line number Diff line change
Expand Up @@ -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)


//------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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