[PATCH] D53431: clang appears not to respect __attribute__((noinline))

Francois de Ferriere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 19 04:28:58 PDT 2018


fdeferriere created this revision.
fdeferriere added reviewers: chandlerc, dmajor, dblaikie.
fdeferriere added a project: 3.7.1-merged.
Herald added a subscriber: llvm-commits.

Bug 26545 reports that the "noinline" attribute does not prevent the result of a function to be "inlined" into the caller.
The problem comes in fact from the Inter-Procedural Sparse Constant Propagation which propagates the return value into the caller.
This patch fixes this problem by patching the function "canTrackReturnsInterprocedurally". This function now returns false on functions with the "noinline" attribute.


Repository:
  rL LLVM

https://reviews.llvm.org/D53431

Files:
  lib/Analysis/ValueLatticeUtils.cpp


Index: lib/Analysis/ValueLatticeUtils.cpp
===================================================================
--- lib/Analysis/ValueLatticeUtils.cpp
+++ lib/Analysis/ValueLatticeUtils.cpp
@@ -22,7 +22,8 @@
 }
 
 bool llvm::canTrackReturnsInterprocedurally(Function *F) {
-  return F->hasExactDefinition() && !F->hasFnAttribute(Attribute::Naked);
+  return F->hasExactDefinition() && !F->hasFnAttribute(Attribute::Naked)
+      && !F.hasFnAttribute(Attribute::NoInline);
 }
 
 bool llvm::canTrackGlobalVariableInterprocedurally(GlobalVariable *GV) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53431.170183.patch
Type: text/x-patch
Size: 549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181019/48cbced9/attachment.bin>


More information about the llvm-commits mailing list