https://bugs.llvm.org/show_bug.cgi?id=48925
Bug ID: 48925
Summary: Always_inline / __forceinline should override
dllimport inline function suppression
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangb...@nondot.org
Reporter: r...@google.com
CC: e...@efcs.ca, h...@chromium.org,
llvm-bugs@lists.llvm.org, neeil...@live.com,
richard-l...@metafoo.co.uk
Consider:
$ cat t.cpp
int notImported();
int __forceinline __declspec(dllimport) foo() { return notImported(); }
int bar() { return foo(); }
$ clang -S t.cpp -o - --target=x86_64-windows-msvc
...
# %bb.0: # %entry
subq $40, %rsp
.seh_stackalloc 40
.seh_endprologue
callq *"__imp_?foo@@YAHXZ"(%rip)
nop
addq $40, %rsp
retq
.seh_endproc
...
Clang doesn't honor the __forceinline attribute here because the dllimport
function refers to something that is not also imported. This logic lives here:
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenModule.cpp#L3035
if (F->hasAttr<DLLImportAttr>()) {
// Check whether it would be safe to inline this dllimport function.
DLLImportFunctionVisitor Visitor;
Visitor.TraverseFunctionDecl(const_cast<FunctionDecl*>(F));
if (!Visitor.SafeToInline)
return false;
It seems reasonable to power down this safety check when the user has an
explicit attribute. MSVC will inline when optimizations are enabled, but not at
-Od, so this should be OK:
https://gcc.godbolt.org/z/GYTKhM
This is related to https://crbug.com/1090975#c10 and the FIXME here
http://github.com/llvm/llvm-project/commit/411210838d762303027f7ac8ddc12427d774b170.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs