[PATCH] Refactoring SimplifyLibCalls to remove static initializers and generally cleaning up the code.

Owen Anderson resistor at mac.com
Tue Sep 16 17:04:01 PDT 2014


LGTM otherwise.

================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:114
@@ -144,13 +113,3 @@
 
-struct FortifiedLibCallOptimization : public LibCallOptimization {
-protected:
-  virtual bool isFoldable(unsigned SizeCIOp, unsigned SizeArgOp,
-			  bool isString) const = 0;
-};
-
-struct InstFortifiedLibCallOptimization : public FortifiedLibCallOptimization {
-  CallInst *CI;
-
-  bool isFoldable(unsigned SizeCIOp, unsigned SizeArgOp,
-                  bool isString) const override {
-    if (CI->getArgOperand(SizeCIOp) == CI->getArgOperand(SizeArgOp))
+static bool isFoldable(CallInst *CI, unsigned SizeCIOp, unsigned SizeArgOp,
+                       bool isString) {
----------------
I think this needs a more descriptive name now that it is not contained in a class with a self-documenting name.

================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:321
@@ +320,3 @@
+  FunctionType *FT = Callee->getFunctionType();
+  if (FT->getNumParams() != 2 || FT->getReturnType() != B.getInt8PtrTy() ||
+      FT->getParamType(0) != FT->getReturnType() ||
----------------
I think the old formatting was more readable here.

http://reviews.llvm.org/D5364






More information about the llvm-commits mailing list