[PATCH] D12087: always_inline codegen rewrite

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 17 11:29:19 PDT 2015


rsmith added inline comments.

================
Comment at: lib/CodeGen/CodeGenModule.cpp:447-448
@@ +446,4 @@
+      C->handleOperandChange(GV, IndirectReplacement, &U);
+    } else if (!isa<llvm::InvokeInst>(U.getUser()) &&
+               !isa<llvm::CallInst>(U.getUser())) {
+      U.set(IndirectReplacement);
----------------
Do you need to check which operand of the call or invoke you found? For instance:

  void f(void (*)());
  extern inline __attribute__((always_inline, gnu_inline)) void g() {}
  void h() { f(g); } // should not use alwaysinline symbol

================
Comment at: lib/CodeGen/CodeGenModule.cpp:505-506
@@ +504,4 @@
+void CodeGenModule::RewriteAlwaysInlineFunctions() {
+  for (llvm::Function &Fn : TheModule.functions()) {
+    if (Fn.hasFnAttribute(llvm::Attribute::AlwaysInline)) {
+      RewriteAlwaysInlineFunction(&Fn);
----------------
I think it would be better to make a list of `always_inline` functions rather than actually marking them as `always_inline` in the IR; that way, you don't need to walk all the functions here, and you don't need to temporarily violate the invariant that only `internal`/`private` functions are ever `always_inline`.


Repository:
  rL LLVM

http://reviews.llvm.org/D12087





More information about the cfe-commits mailing list