17 #include <llvm/IR/Function.h>
19 #include <llvm/Analysis/CallGraph.h>
20 #include <llvm/Analysis/CallGraphSCCPass.h>
22 #include <llvm/Pass.h>
23 #include <llvm/Support/raw_ostream.h>
39 bool runOnSCC(llvm::CallGraphSCC& SCC)
override {
40 bool updated_function_defs =
false;
43 for (
auto& node : SCC) {
45 auto fcn = node->getFunction();
51 updated_function_defs =
true;
52 std::vector<llvm::Attribute::AttrKind> attrs{llvm::Attribute::NoFree,
53 llvm::Attribute::NoSync,
54 llvm::Attribute::NoUnwind,
55 llvm::Attribute::WillReturn,
56 llvm::Attribute::ReadNone,
57 llvm::Attribute::Speculatable};
60 fcn->removeFnAttr(llvm::Attribute::WriteOnly);
61 for (
const auto& attr : attrs) {
67 return updated_function_defs;
70 llvm::StringRef
getPassName()
const override {
return "AnnotateInternalFunctionsPass"; }
91 std::set<std::string>{
"point_coord_array_is_null",
92 "decompress_x_coord_geoint",
93 "decompress_y_coord_geoint",
94 "compress_x_coord_geoint",
95 "compress_y_coord_geoint",
97 "transform_4326_900913_x",
98 "transform_4326_900913_y",
99 "transform_900913_4326_x",
100 "transform_900913_4326_y",
102 "conv_4326_900913_x",
103 "conv_4326_900913_y",
104 "distance_in_meters",
105 "approx_distance_in_meters",
108 "rect_pixel_bin_packed",
109 "reg_hex_horiz_pixel_bin_x",
110 "reg_hex_horiz_pixel_bin_y",
111 "reg_hex_horiz_pixel_bin_packed",
112 "reg_hex_vert_pixel_bin_x",
113 "reg_hex_vert_pixel_bin_y",
114 "reg_hex_vert_pixel_bin_packed",
115 "convert_meters_to_merc_pixel_width",
116 "convert_meters_to_merc_pixel_height",
117 "is_point_in_merc_view",
118 "is_point_size_in_merc_view"};
124 std::set<std::string>{
"Acos",
"Asin",
"Atan",
"Atan2",
"Ceil",
"Cos",
125 "Cot",
"degrees",
"Exp",
"Floor",
"ln",
"Log",
126 "Log10",
"log",
"pi",
"power",
"radians",
"Round",
127 "Sin",
"Tan",
"tan",
"Truncate",
"is_nan",
"is_inf"};
bool runOnSCC(llvm::CallGraphSCC &SCC) override
static const std::set< std::string > extension_functions
static bool isInternalStatelessFunction(const llvm::StringRef &func_name)
AnnotateInternalFunctionsPass()
llvm::StringRef getPassName() const override
static const std::set< std::string > math_builtins
static bool isInternalMathFunction(const llvm::StringRef &func_name)