diff --git a/FactGenerator/include/predicates.inc b/FactGenerator/include/predicates.inc index 6d6eb2e..e27f433 100644 --- a/FactGenerator/include/predicates.inc +++ b/FactGenerator/include/predicates.inc @@ -228,17 +228,14 @@ GROUP_END(resume) GROUP_BEGIN(invoke) PREDICATE2(invoke, instr) -// TODO(#42): Rename for consistency -PREDICATE(invoke, instr_direct, direct_invoke_instr) -PREDICATE(invoke, instr_indirect, indirect_invoke_instr) -PREDICATE(invoke, function, invoke_instr_fn_operand) -PREDICATE(invoke, arg, invoke_instr_arg) -PREDICATE(invoke, calling_conv, invoke_instr_with_calling_convention) -PREDICATE(invoke, return_attr, invoke_instr_with_return_attr) -PREDICATE(invoke, param_attr, invoke_instr_with_param_attr) -PREDICATE(invoke, fn_attr, invoke_instr_with_fn_attr) -PREDICATE(invoke, normal_label, invoke_instr_normal_label) -PREDICATE(invoke, exc_label, invoke_instr_exception_label) +PREDICATEI(invoke, func_operand) +PREDICATEI(invoke, arg) +PREDICATEI(invoke, calling_conv) +PREDICATEI(invoke, return_attr) +PREDICATEI(invoke, param_attr) +PREDICATEI(invoke, fn_attr) +PREDICATEI(invoke, normal_label) +PREDICATEI(invoke, exception_label) GROUP_END(invoke) // Vector Operations @@ -452,16 +449,13 @@ GROUP_END(va_arg) GROUP_BEGIN(call) PREDICATE2(call, instr) -// TODO(#42): -PREDICATE(call, instr_direct, direct_call_instr) -PREDICATE(call, instr_indirect, indirect_call_instr) -PREDICATE(call, function, call_instr_fn_operand) -PREDICATE(call, arg, call_instr_arg) -PREDICATE(call, calling_conv, call_instr_with_calling_convention) -PREDICATE(call, return_attr, call_instr_with_return_attr) -PREDICATE(call, param_attr, call_instr_with_param_attr) -PREDICATE(call, fn_attr, call_instr_with_fn_attr) -PREDICATE(call, tail, call_instr_is_tail_opt) +PREDICATEI(call, func_operand) +PREDICATEI(call, arg) +PREDICATEI(call, calling_conv) +PREDICATEI(call, return_attr) +PREDICATEI(call, param_attr) +PREDICATEI(call, fn_attr) +PREDICATEI(call, is_tail_opt) GROUP_END(call) GROUP_BEGIN(landingpad) diff --git a/FactGenerator/src/InstructionVisitor.cpp b/FactGenerator/src/InstructionVisitor.cpp index 9d2d9c5..419b956 100644 --- a/FactGenerator/src/InstructionVisitor.cpp +++ b/FactGenerator/src/InstructionVisitor.cpp @@ -276,11 +276,6 @@ void InstructionVisitor::visitIndirectBrInst(const llvm::IndirectBrInst &IBR) { void InstructionVisitor::visitInvokeInst(const llvm::InvokeInst &II) { refmode_t iref = recordInstruction(pred::invoke::instr, II); - gen.writeFact( - II.getCalledFunction() ? pred::invoke::instr_direct - : pred::invoke::instr_indirect, - iref); - #if LLVM_VERSION_MAJOR > 12 const llvm::Value *invokeOp = II.getCalledOperand(); #else @@ -288,14 +283,14 @@ void InstructionVisitor::visitInvokeInst(const llvm::InvokeInst &II) { #endif // invoke instruction function (also records type) - writeInstrOperand(pred::invoke::function, iref, invokeOp); + writeInstrOperand(pred::invoke::func_operand, iref, invokeOp); // actual args for (unsigned op = 0; op < II.getNumArgOperands(); ++op) writeInstrOperand(pred::invoke::arg, iref, II.getArgOperand(op), op); writeInstrOperand(pred::invoke::normal_label, iref, II.getNormalDest()); - writeInstrOperand(pred::invoke::exc_label, iref, II.getUnwindDest()); + writeInstrOperand(pred::invoke::exception_label, iref, II.getUnwindDest()); // Function Attributes const Attributes &Attrs = II.getAttributes(); @@ -544,17 +539,6 @@ void InstructionVisitor::visitCallInst(const llvm::CallInst &CI) { // instructions due to the constraint that all direct calls must // be able to determine the function to be called. - if (!CI.isInlineAsm()) { - // Record if instruction is direct or indirect. This is - // probably redundant since it is inferred by the logic - // itself, according to the kind of the function operand. - - gen.writeFact( - CI.getCalledFunction() ? pred::call::instr_direct - : pred::call::instr_indirect, - iref); - } - #if LLVM_VERSION_MAJOR > 12 const llvm::Value *callOp = CI.getCalledOperand(); #else @@ -562,12 +546,12 @@ void InstructionVisitor::visitCallInst(const llvm::CallInst &CI) { #endif // call instruction function (also records type) - writeInstrOperand(pred::call::function, iref, callOp); + writeInstrOperand(pred::call::func_operand, iref, callOp); for (unsigned op = 0; op < CI.getNumArgOperands(); ++op) writeInstrOperand(pred::call::arg, iref, CI.getArgOperand(op), op); - if (CI.isTailCall()) gen.writeFact(pred::call::tail, iref); + if (CI.isTailCall()) gen.writeFact(pred::call::is_tail_opt, iref); if (CI.getCallingConv() != llvm::CallingConv::C) { refmode_t cconv = gen.refmode(CI.getCallingConv()); diff --git a/datalog/context/drop.dl b/datalog/context/drop.dl index ac33984..9016934 100644 --- a/datalog/context/drop.dl +++ b/datalog/context/drop.dl @@ -36,8 +36,8 @@ call_or_invoke_instr_fn_type(?instr, ?fnType) :- .decl indirect_call_or_invoke_instr(?instr: Instruction) indirect_call_or_invoke_instr(?instr) :- - indirect_call_instr(?instr); - indirect_invoke_instr(?instr). + call_instr_indirect(?instr); + invoke_instr_direct(?instr). .decl num_indirect_calls_to_compatible_func(?n: number, ?func: FunctionDecl) num_indirect_calls_to_compatible_func(?n, ?func) :- @@ -89,8 +89,8 @@ func_type_has_no_pointer_return(?funcType) :- drop_context_by_invoc(?invoc) :- user_option_value("drop_redundant_contexts", "on"), - ( call_instr_fn_operand(?invoc, ?funcOp) - ; invoke_instr_fn_operand(?invoc, ?funcOp) + ( call_instr_func_operand(?invoc, ?funcOp) + ; invoke_instr_func_operand(?invoc, ?funcOp) ), operand_has_type(?funcOp, ?funcOpType), pointer_type_has_component(?funcOpType, ?declaredType), diff --git a/datalog/export/debug-output-extended.dl b/datalog/export/debug-output-extended.dl index e945d9a..2782de1 100644 --- a/datalog/export/debug-output-extended.dl +++ b/datalog/export/debug-output-extended.dl @@ -143,24 +143,26 @@ .output block_predecessors (compress=true) .output boolean_type (compress=true) .output boolean_vector_type (compress=true) +.output br_instr (compress=true) .output br_instr_cond (compress=true) .output br_instr_condition (compress=true) .output br_instr_false_label (compress=true) .output br_instr_true_label (compress=true) -.output br_instr (compress=true) .output br_instr_uncond (compress=true) .output br_instr_uncond_label (compress=true) .output call_instr (compress=true) .output call_instr_arg (compress=true) -.output call_instr_fn_operand (compress=true) +.output call_instr_calling_conv (compress=true) +.output call_instr_direct (compress=true) +.output call_instr_fn_attr (compress=true) .output call_instr_fn_target (compress=true) .output call_instr_fn_type (compress=true) +.output call_instr_func_operand (compress=true) +.output call_instr_indirect (compress=true) .output call_instr_is_tail_opt (compress=true) +.output call_instr_param_attr (compress=true) +.output call_instr_return_attr (compress=true) .output call_instr_return_type (compress=true) -.output call_instr_with_calling_convention (compress=true) -.output call_instr_with_fn_attr (compress=true) -.output call_instr_with_param_attr (compress=true) -.output call_instr_with_return_attr (compress=true) .output call_or_invoke_instr_fn_type (compress=true) .output called_at_startup (compress=true) .output calling_convention (compress=true) @@ -217,8 +219,6 @@ .output default_visibility (compress=true) .output derived_type (compress=true) .output destructor_class_type (compress=true) -.output direct_call_instr (compress=true) -.output direct_invoke_instr (compress=true) .output direct_subclass (compress=true) .output direct_superclass (compress=true) .output dllexport_linkage_type (compress=true) @@ -469,9 +469,7 @@ .output icmp_instr_from_type (compress=true) .output icmp_instr_second_operand (compress=true) .output icmp_instr_to_type (compress=true) -.output indirect_call_instr (compress=true) .output indirect_call_or_invoke_instr (compress=true) -.output indirect_invoke_instr (compress=true) .output indirectbr_instr (compress=true) .output indirectbr_instr_address (compress=true) .output indirectbr_instr_label (compress=true) @@ -504,6 +502,8 @@ .output instr_func (compress=true) .output instr_pos (compress=true) .output instr_returns_type (compress=true) +.output instr_successor (compress=true) +.output instr_successor_index (compress=true) .output int1_type (compress=true) .output int32_type (compress=true) .output int32_vector_type (compress=true) @@ -524,16 +524,18 @@ .output inttoptr_instr_to_type (compress=true) .output invoke_instr (compress=true) .output invoke_instr_arg (compress=true) +.output invoke_instr_calling_conv (compress=true) +.output invoke_instr_direct (compress=true) .output invoke_instr_exception_label (compress=true) -.output invoke_instr_fn_operand (compress=true) +.output invoke_instr_fn_attr (compress=true) .output invoke_instr_fn_target (compress=true) .output invoke_instr_fn_type (compress=true) +.output invoke_instr_func_operand (compress=true) +.output invoke_instr_indirect (compress=true) .output invoke_instr_normal_label (compress=true) +.output invoke_instr_param_attr (compress=true) +.output invoke_instr_return_attr (compress=true) .output invoke_instr_return_type (compress=true) -.output invoke_instr_with_calling_convention (compress=true) -.output invoke_instr_with_fn_attr (compress=true) -.output invoke_instr_with_param_attr (compress=true) -.output invoke_instr_with_return_attr (compress=true) .output label_type (compress=true) .output landingpad (compress=true) .output landingpad_instr (compress=true) @@ -575,8 +577,6 @@ .output mul_instr_first_operand (compress=true) .output mul_instr_second_operand (compress=true) .output nallocs_by_pt_size (compress=true) -.output instr_successor (compress=true) -.output instr_successor_index (compress=true) .output non_allocation (compress=true) .output nonempty_ptr (compress=true) .output nonempty_ptrs (compress=true) @@ -674,6 +674,7 @@ .output resume_instr_operand (compress=true) .output ret_instr (compress=true) .output ret_instr_operand (compress=true) +.output ret_instr_void_ (compress=true) .output schema_invalid_alias (compress=true) .output schema_invalid_constant (compress=true) .output schema_invalid_func (compress=true) @@ -826,7 +827,6 @@ .output vector_type_has_component (compress=true) .output vector_type_has_size (compress=true) .output visibility (compress=true) -.output ret_instr_void_ (compress=true) .output void_type (compress=true) .output vtable (compress=true) .output vtable_func (compress=true) diff --git a/datalog/export/debug-output.dl b/datalog/export/debug-output.dl index e945d9a..2782de1 100644 --- a/datalog/export/debug-output.dl +++ b/datalog/export/debug-output.dl @@ -143,24 +143,26 @@ .output block_predecessors (compress=true) .output boolean_type (compress=true) .output boolean_vector_type (compress=true) +.output br_instr (compress=true) .output br_instr_cond (compress=true) .output br_instr_condition (compress=true) .output br_instr_false_label (compress=true) .output br_instr_true_label (compress=true) -.output br_instr (compress=true) .output br_instr_uncond (compress=true) .output br_instr_uncond_label (compress=true) .output call_instr (compress=true) .output call_instr_arg (compress=true) -.output call_instr_fn_operand (compress=true) +.output call_instr_calling_conv (compress=true) +.output call_instr_direct (compress=true) +.output call_instr_fn_attr (compress=true) .output call_instr_fn_target (compress=true) .output call_instr_fn_type (compress=true) +.output call_instr_func_operand (compress=true) +.output call_instr_indirect (compress=true) .output call_instr_is_tail_opt (compress=true) +.output call_instr_param_attr (compress=true) +.output call_instr_return_attr (compress=true) .output call_instr_return_type (compress=true) -.output call_instr_with_calling_convention (compress=true) -.output call_instr_with_fn_attr (compress=true) -.output call_instr_with_param_attr (compress=true) -.output call_instr_with_return_attr (compress=true) .output call_or_invoke_instr_fn_type (compress=true) .output called_at_startup (compress=true) .output calling_convention (compress=true) @@ -217,8 +219,6 @@ .output default_visibility (compress=true) .output derived_type (compress=true) .output destructor_class_type (compress=true) -.output direct_call_instr (compress=true) -.output direct_invoke_instr (compress=true) .output direct_subclass (compress=true) .output direct_superclass (compress=true) .output dllexport_linkage_type (compress=true) @@ -469,9 +469,7 @@ .output icmp_instr_from_type (compress=true) .output icmp_instr_second_operand (compress=true) .output icmp_instr_to_type (compress=true) -.output indirect_call_instr (compress=true) .output indirect_call_or_invoke_instr (compress=true) -.output indirect_invoke_instr (compress=true) .output indirectbr_instr (compress=true) .output indirectbr_instr_address (compress=true) .output indirectbr_instr_label (compress=true) @@ -504,6 +502,8 @@ .output instr_func (compress=true) .output instr_pos (compress=true) .output instr_returns_type (compress=true) +.output instr_successor (compress=true) +.output instr_successor_index (compress=true) .output int1_type (compress=true) .output int32_type (compress=true) .output int32_vector_type (compress=true) @@ -524,16 +524,18 @@ .output inttoptr_instr_to_type (compress=true) .output invoke_instr (compress=true) .output invoke_instr_arg (compress=true) +.output invoke_instr_calling_conv (compress=true) +.output invoke_instr_direct (compress=true) .output invoke_instr_exception_label (compress=true) -.output invoke_instr_fn_operand (compress=true) +.output invoke_instr_fn_attr (compress=true) .output invoke_instr_fn_target (compress=true) .output invoke_instr_fn_type (compress=true) +.output invoke_instr_func_operand (compress=true) +.output invoke_instr_indirect (compress=true) .output invoke_instr_normal_label (compress=true) +.output invoke_instr_param_attr (compress=true) +.output invoke_instr_return_attr (compress=true) .output invoke_instr_return_type (compress=true) -.output invoke_instr_with_calling_convention (compress=true) -.output invoke_instr_with_fn_attr (compress=true) -.output invoke_instr_with_param_attr (compress=true) -.output invoke_instr_with_return_attr (compress=true) .output label_type (compress=true) .output landingpad (compress=true) .output landingpad_instr (compress=true) @@ -575,8 +577,6 @@ .output mul_instr_first_operand (compress=true) .output mul_instr_second_operand (compress=true) .output nallocs_by_pt_size (compress=true) -.output instr_successor (compress=true) -.output instr_successor_index (compress=true) .output non_allocation (compress=true) .output nonempty_ptr (compress=true) .output nonempty_ptrs (compress=true) @@ -674,6 +674,7 @@ .output resume_instr_operand (compress=true) .output ret_instr (compress=true) .output ret_instr_operand (compress=true) +.output ret_instr_void_ (compress=true) .output schema_invalid_alias (compress=true) .output schema_invalid_constant (compress=true) .output schema_invalid_func (compress=true) @@ -826,7 +827,6 @@ .output vector_type_has_component (compress=true) .output vector_type_has_size (compress=true) .output visibility (compress=true) -.output ret_instr_void_ (compress=true) .output void_type (compress=true) .output vtable (compress=true) .output vtable_func (compress=true) diff --git a/datalog/points-to/assertions.dl b/datalog/points-to/assertions.dl index 71cc06e..6745ad2 100644 --- a/datalog/points-to/assertions.dl +++ b/datalog/points-to/assertions.dl @@ -270,8 +270,8 @@ assert_bitcast_operand_in_same_func(?bitcastInstr) :- assert_reachable_direct_calls_have_callees(?ctx, ?call) :- subset.callgraph.reachable_context(?ctx, ?instrFunc), instr_func(?call, ?instrFunc), - direct_call_instr(?call), - call_instr_fn_operand(?call, ?funcOp), + call_instr_direct(?call), + call_instr_func_operand(?call, ?funcOp), ! undef_constant(?funcOp), ! subset.callgraph.callgraph_edge(_, _, ?ctx, ?call). diff --git a/datalog/points-to/interprocedural.dl b/datalog/points-to/interprocedural.dl index 759a404..f65b1d4 100644 --- a/datalog/points-to/interprocedural.dl +++ b/datalog/points-to/interprocedural.dl @@ -88,7 +88,7 @@ func_by_location(?alloc, ?callee) :- _callgraph_edge_interim_direct_call(?callee, ?callerCtx, ?callerInstr) :- - direct_call_instr(?callerInstr), + call_instr_direct(?callerInstr), call_instr_fn_target(?callerInstr, ?callee), instr_func(?callerInstr, ?instrFunc), reachable_context(?callerCtx, ?instrFunc). @@ -103,7 +103,7 @@ func_by_location(?alloc, ?callee) :- _callgraph_edge_interim_direct_invoke(?callee, ?callerCtx, ?callerInstr) :- - direct_call_instr(?callerInstr), + call_instr_direct(?callerInstr), invoke_instr_fn_target(?callerInstr, ?callee), instr_func(?callerInstr, ?instrFunc), reachable_context(?callerCtx, ?instrFunc). @@ -121,8 +121,8 @@ func_by_location(?alloc, ?callee) :- _callgraph_edge_interim_indirect_call(?callee, ?callerCtx, ?aCtx, ?callerInstr) :- - indirect_call_instr(?callerInstr), - call_instr_fn_operand(?callerInstr, ?funcOp), + call_instr_indirect(?callerInstr), + call_instr_func_operand(?callerInstr, ?funcOp), func_pointer_operand_points_to(?aCtx, ?funcLoc, ?callerCtx, ?funcOp), func_by_location(?funcLoc, ?callee), func_ty(?callee, ?actualType), @@ -141,7 +141,7 @@ func_by_location(?alloc, ?callee) :- _callgraph_edge_interim_indirect_invoke(?callee, ?callerCtx, ?aCtx, ?callerInstr) :- invoke_instr(?callerInstr), - invoke_instr_fn_operand(?callerInstr, ?funcOp), + invoke_instr_func_operand(?callerInstr, ?funcOp), func_pointer_operand_points_to(?aCtx, ?funcLoc, ?callerCtx, ?funcOp), func_by_location(?funcLoc, ?callee), func_ty(?callee, ?actualType), diff --git a/datalog/schema/call-instr.dl b/datalog/schema/call-instr.dl index 211b629..cd14752 100644 --- a/datalog/schema/call-instr.dl +++ b/datalog/schema/call-instr.dl @@ -7,7 +7,7 @@ instr(v) :- call_instr(v). // Function operand: can be either a constant or a variable -.decl call_instr_fn_operand(instr:CallInstruction, op:Operand) +.decl call_instr_func_operand(instr:CallInstruction, op:Operand) // Resolved func of call instr. Initially empty. .decl call_instr_fn_target(instr:CallInstruction, func:FunctionDecl) @@ -18,8 +18,8 @@ instr(v) :- call_instr(v). // If none is specified, the call defaults to using C // calling conventions. -.decl call_instr_with_calling_convention(instr:CallInstruction, cc:CallingConvention) -calling_convention(cc) :- call_instr_with_calling_convention(_, cc). +.decl call_instr_calling_conv(instr:CallInstruction, cc:CallingConvention) +calling_convention(cc) :- call_instr_calling_conv(_, cc). //--------------------------------------------------------------- @@ -30,20 +30,20 @@ calling_convention(cc) :- call_instr_with_calling_convention(_, cc). // through a func pointer variable. //--------------------------------------------------------------- -.decl direct_call_instr(instr:CallInstruction) -.decl indirect_call_instr(instr:CallInstruction) +.decl call_instr_direct(instr:CallInstruction) +.decl call_instr_indirect(instr:CallInstruction) .decl asm_call_instr(instr:CallInstruction) -direct_call_instr(Instr) :- - call_instr_fn_operand(Instr, Constant), +call_instr_direct(Instr) :- + call_instr_func_operand(Instr, Constant), constant(Constant), !inline_asm(Constant). -indirect_call_instr(Instr) :- - call_instr_fn_operand(Instr, Variable), +call_instr_indirect(Instr) :- + call_instr_func_operand(Instr, Variable), variable(Variable). asm_call_instr(Instr) :- - call_instr_fn_operand(Instr, Constant), + call_instr_func_operand(Instr, Constant), inline_asm(Constant). @@ -52,13 +52,13 @@ asm_call_instr(Instr) :- //-------------------------------------------------- .decl call_instr_arg(instr:CallInstruction, i:ArgumentIndex, arg:Operand) -.decl call_instr_with_return_attr(instr:CallInstruction, attr:Attribute) -.decl call_instr_with_param_attr(instr:CallInstruction, i:ArgumentIndex, attr:Attribute) -.decl call_instr_with_fn_attr(instr:CallInstruction, attr:Attribute) +.decl call_instr_return_attr(instr:CallInstruction, attr:Attribute) +.decl call_instr_param_attr(instr:CallInstruction, i:ArgumentIndex, attr:Attribute) +.decl call_instr_fn_attr(instr:CallInstruction, attr:Attribute) -attr(Attr) :- call_instr_with_fn_attr(_, Attr). -attr(Attr) :- call_instr_with_return_attr(_, Attr). -attr(Attr) :- call_instr_with_param_attr(_, _, Attr). +attr(Attr) :- call_instr_fn_attr(_, Attr). +attr(Attr) :- call_instr_return_attr(_, Attr). +attr(Attr) :- call_instr_param_attr(_, _, Attr). //----------------------------- @@ -69,7 +69,7 @@ attr(Attr) :- call_instr_with_param_attr(_, _, Attr). .decl call_instr_return_type(instr:CallInstruction, type:Type) call_instr_fn_type(Instr, FnType) :- - call_instr_fn_operand(Instr, FnOp), + call_instr_func_operand(Instr, FnOp), operand_has_type(FnOp, PtrType), pointer_type_has_component(PtrType, FnType), func_type(FnType). @@ -100,7 +100,7 @@ call_instr_return_type(Instr, Type) :- schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_sanity(), call_instr(Instr), - !call_instr_fn_operand(Instr, _). + !call_instr_func_operand(Instr, _). schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_sanity(), @@ -110,7 +110,7 @@ schema_invalid_instr(Instr, __FILE__, __LINE__) :- // attr compatibility schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_sanity(), - call_instr_with_return_attr(Instr, Attr), + call_instr_return_attr(Instr, Attr), !parameter_attr__zeroext(Attr), !parameter_attr__signext(Attr), !parameter_attr__inreg(Attr), @@ -119,7 +119,7 @@ schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_sanity(), - call_instr_with_fn_attr(Instr, Attr), + call_instr_fn_attr(Instr, Attr), !func_fn_attr__noreturn(Attr), !func_fn_attr__nounwind(Attr), !func_fn_attr__readonly(Attr), @@ -138,7 +138,7 @@ schema_invalid_instr(Instr, __FILE__, __LINE__) :- // schema_invalid_instr(Instr, __FILE__, __LINE__) :- // schema_sanity(), // call_instr_fn_target(Instr, Func), -// call_instr_with_calling_convention(Instr, CConv), +// call_instr_calling_conv(Instr, CConv), // !func_calling_conv(Func, CConv). // c2 // Signature conformance diff --git a/datalog/schema/invoke-instr.dl b/datalog/schema/invoke-instr.dl index 39ec2b8..b2988ea 100644 --- a/datalog/schema/invoke-instr.dl +++ b/datalog/schema/invoke-instr.dl @@ -8,15 +8,15 @@ instr(v) :- invoke_instr(v). terminator_instr(v) :- invoke_instr(v). // Function operand: can be either a constant or a variable -.decl invoke_instr_fn_operand(instr:InvokeInstruction, op:Operand) +.decl invoke_instr_func_operand(instr:InvokeInstruction, op:Operand) // Resolved func of invoke instr. Initially empty. .decl invoke_instr_fn_target(instr:InvokeInstruction, func:FunctionDecl) // If none is specified, the invoke defaults to using C // calling conventions. -.decl invoke_instr_with_calling_convention(instr:InvokeInstruction, cc:CallingConvention) -calling_convention(cc) :- invoke_instr_with_calling_convention(_, cc). +.decl invoke_instr_calling_conv(instr:InvokeInstruction, cc:CallingConvention) +calling_convention(cc) :- invoke_instr_calling_conv(_, cc). //--------------------------------------------------------------- @@ -27,15 +27,15 @@ calling_convention(cc) :- invoke_instr_with_calling_convention(_, cc). // through a func pointer variable. //--------------------------------------------------------------- -.decl direct_invoke_instr(instr:InvokeInstruction) -.decl indirect_invoke_instr(instr:InvokeInstruction) +.decl invoke_instr_direct(instr:InvokeInstruction) +.decl invoke_instr_indirect(instr:InvokeInstruction) -direct_invoke_instr(Instr) :- - invoke_instr_fn_operand(Instr, Constant), +invoke_instr_direct(Instr) :- + invoke_instr_func_operand(Instr, Constant), constant(Constant). -indirect_invoke_instr(Instr) :- - invoke_instr_fn_operand(Instr, Variable), +invoke_instr_indirect(Instr) :- + invoke_instr_func_operand(Instr, Variable), variable(Variable). @@ -44,13 +44,13 @@ indirect_invoke_instr(Instr) :- //-------------------------------------------------- .decl invoke_instr_arg(instr:InvokeInstruction, i:ArgumentIndex, arg:Operand) -.decl invoke_instr_with_return_attr(instr:InvokeInstruction, attr:Attribute) -.decl invoke_instr_with_param_attr(instr:InvokeInstruction, i:ArgumentIndex, attr:Attribute) -.decl invoke_instr_with_fn_attr(instr:InvokeInstruction, attr:Attribute) +.decl invoke_instr_return_attr(instr:InvokeInstruction, attr:Attribute) +.decl invoke_instr_param_attr(instr:InvokeInstruction, i:ArgumentIndex, attr:Attribute) +.decl invoke_instr_fn_attr(instr:InvokeInstruction, attr:Attribute) -attr(Attr) :- invoke_instr_with_fn_attr(_, Attr). -attr(Attr) :- invoke_instr_with_return_attr(_, Attr). -attr(Attr) :- invoke_instr_with_param_attr(_, _, Attr). +attr(Attr) :- invoke_instr_fn_attr(_, Attr). +attr(Attr) :- invoke_instr_return_attr(_, Attr). +attr(Attr) :- invoke_instr_param_attr(_, _, Attr). //----------------------------- @@ -61,7 +61,7 @@ attr(Attr) :- invoke_instr_with_param_attr(_, _, Attr). .decl invoke_instr_return_type(instr:InvokeInstruction, type:Type) invoke_instr_fn_type(Instr, FnType) :- - invoke_instr_fn_operand(Instr, FnOp), + invoke_instr_func_operand(Instr, FnOp), operand_has_type(FnOp, PtrType), pointer_type_has_component(PtrType, FnType), func_type(FnType). @@ -108,7 +108,7 @@ invoke_instr_return_type(Instr, Type) :- schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_sanity(), invoke_instr(Instr), - !invoke_instr_fn_operand(Instr, _). + !invoke_instr_func_operand(Instr, _). schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_sanity(), @@ -123,7 +123,7 @@ schema_invalid_instr(Instr, __FILE__, __LINE__) :- // attr compatibility schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_sanity(), - invoke_instr_with_return_attr(Instr, Attr), + invoke_instr_return_attr(Instr, Attr), !parameter_attr__zeroext(Attr), !parameter_attr__signext(Attr), !parameter_attr__inreg(Attr), @@ -132,7 +132,7 @@ schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_sanity(), - invoke_instr_with_fn_attr(Instr, Attr), + invoke_instr_fn_attr(Instr, Attr), !func_fn_attr__noreturn(Attr), !func_fn_attr__nounwind(Attr), !func_fn_attr__readonly(Attr), diff --git a/datalog/symbol-lookup/resolve-func-calls.dl b/datalog/symbol-lookup/resolve-func-calls.dl index 1d84766..d0c45e4 100644 --- a/datalog/symbol-lookup/resolve-func-calls.dl +++ b/datalog/symbol-lookup/resolve-func-calls.dl @@ -91,14 +91,14 @@ constant_references_variable(OtherConstant, GVar) :- .decl _instr_calls_func(instr:Instruction, target:FunctionDecl) _instr_calls_func(Instr, Func) :- - direct_call_instr(Instr), - call_instr_fn_operand(Instr, FunctionConstant), + call_instr_direct(Instr), + call_instr_func_operand(Instr, FunctionConstant), constant(FunctionConstant), constant_references_func(FunctionConstant, Func). _instr_calls_func(Instr, Func) :- - direct_invoke_instr(Instr), - invoke_instr_fn_operand(Instr, FunctionConstant), + invoke_instr_direct(Instr), + invoke_instr_func_operand(Instr, FunctionConstant), constant(FunctionConstant), constant_references_func(FunctionConstant, Func). @@ -106,12 +106,12 @@ _instr_calls_func(Instr, Func) :- // Is this always true for our tests? schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_sanity(), - direct_call_instr(Instr), + call_instr_direct(Instr), !call_instr_fn_target(Instr, _). schema_invalid_instr(Instr, __FILE__, __LINE__) :- schema_sanity(), - direct_invoke_instr(Instr), + invoke_instr_direct(Instr), !invoke_instr_fn_target(Instr, _).