This is an archive of the discontinued LLVM Phabricator instance.

[llvm-c] Add header deprecations
ClosedPublic

Authored by nikic on Dec 2 2021, 1:15 AM.

Details

Reviewers
deadalnix
aeubanks
Group Reviewers
Restricted Project
Commits
rGb15d77928e2b: [llvm-c] Add header deprecations
Summary

This adds support for header deprecation using LLVM_ATTRIBUTE_C_DEPRECATED (note that we can't use LLVM_ATTRIBUTE_DEPRECATED, which is C++ specific). This will not help people using the FFI interface, but may help people using the C headers.

While migrating the test code away from deprecated APIs I had to add a LLVMGetGEPSourceElementType() function, as the necessary functionality didn't seem to be present yet.

Diff Detail

Event Timeline

nikic created this revision.Dec 2 2021, 1:15 AM
nikic requested review of this revision.Dec 2 2021, 1:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2021, 1:15 AM
aeubanks accepted this revision.Dec 2 2021, 10:31 AM
aeubanks added a subscriber: aeubanks.

it'd be nice to split out the API changes and the deprecation macro addition, but not a huge deal

llvm/include/llvm-c/Core.h
3685–3686

could move these comments into the deprecation message

This revision is now accepted and ready to land.Dec 2 2021, 10:31 AM

it'd be nice to split out the API changes and the deprecation macro addition, but not a huge deal

Yep, +1 to that - submit the API changes/fixes first, then the deprecations.

This revision was landed with ongoing or failed builds.Dec 6 2021, 12:18 AM
This revision was automatically updated to reflect the committed changes.
uabelho added a subscriber: uabelho.Dec 6 2021, 5:55 AM

Hi,

I think more fixes are needed. With this commit I see:

../unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp:206:5: error: 'LLVMBuildCall' is deprecated: Use LLVMBuildCall2 instead to support opaque pointers [-Werror,-Wdeprecated-declarations]
    LLVMBuildCall(builder, stackmap, stackmapArgs, 3, "");
    ^
../include/llvm-c/Core.h:3985:1: note: 'LLVMBuildCall' has been explicitly marked deprecated here
LLVM_ATTRIBUTE_C_DEPRECATED(
^
../include/llvm-c/Deprecated.h:26:23: note: expanded from macro 'LLVM_ATTRIBUTE_C_DEPRECATED'
  decl __attribute__((deprecated(message)))
                      ^
../unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp:233:31: error: 'LLVMBuildLoad' is deprecated: Use LLVMBuildLoad2 instead to support opaque pointers [-Werror,-Wdeprecated-declarations]
        LLVMValueRef IntVal = LLVMBuildLoad(Builder, GlobalVar, "intVal");
                              ^
../include/llvm-c/Core.h:3885:1: note: 'LLVMBuildLoad' has been explicitly marked deprecated here
LLVM_ATTRIBUTE_C_DEPRECATED(
^
../include/llvm-c/Deprecated.h:26:23: note: expanded from macro 'LLVM_ATTRIBUTE_C_DEPRECATED'
  decl __attribute__((deprecated(message)))
                      ^
../unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp:492:25: error: 'LLVMBuildCall' is deprecated: Use LLVMBuildCall2 instead to support opaque pointers [-Werror,-Wdeprecated-declarations]
  LLVMValueRef RetVal = LLVMBuildCall(Builder, MappedFn, nullptr, 0, "");
                        ^
../include/llvm-c/Core.h:3985:1: note: 'LLVMBuildCall' has been explicitly marked deprecated here
LLVM_ATTRIBUTE_C_DEPRECATED(
^
../include/llvm-c/Deprecated.h:26:23: note: expanded from macro 'LLVM_ATTRIBUTE_C_DEPRECATED'
  decl __attribute__((deprecated(message)))
                      ^
3 errors generated.
nikic added a comment.Dec 6 2021, 7:03 AM

Hi,

I think more fixes are needed. With this commit I see:

../unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp:206:5: error: 'LLVMBuildCall' is deprecated: Use LLVMBuildCall2 instead to support opaque pointers [-Werror,-Wdeprecated-declarations]
    LLVMBuildCall(builder, stackmap, stackmapArgs, 3, "");
    ^
../include/llvm-c/Core.h:3985:1: note: 'LLVMBuildCall' has been explicitly marked deprecated here
LLVM_ATTRIBUTE_C_DEPRECATED(
^
../include/llvm-c/Deprecated.h:26:23: note: expanded from macro 'LLVM_ATTRIBUTE_C_DEPRECATED'
  decl __attribute__((deprecated(message)))
                      ^
../unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp:233:31: error: 'LLVMBuildLoad' is deprecated: Use LLVMBuildLoad2 instead to support opaque pointers [-Werror,-Wdeprecated-declarations]
        LLVMValueRef IntVal = LLVMBuildLoad(Builder, GlobalVar, "intVal");
                              ^
../include/llvm-c/Core.h:3885:1: note: 'LLVMBuildLoad' has been explicitly marked deprecated here
LLVM_ATTRIBUTE_C_DEPRECATED(
^
../include/llvm-c/Deprecated.h:26:23: note: expanded from macro 'LLVM_ATTRIBUTE_C_DEPRECATED'
  decl __attribute__((deprecated(message)))
                      ^
../unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp:492:25: error: 'LLVMBuildCall' is deprecated: Use LLVMBuildCall2 instead to support opaque pointers [-Werror,-Wdeprecated-declarations]
  LLVMValueRef RetVal = LLVMBuildCall(Builder, MappedFn, nullptr, 0, "");
                        ^
../include/llvm-c/Core.h:3985:1: note: 'LLVMBuildCall' has been explicitly marked deprecated here
LLVM_ATTRIBUTE_C_DEPRECATED(
^
../include/llvm-c/Deprecated.h:26:23: note: expanded from macro 'LLVM_ATTRIBUTE_C_DEPRECATED'
  decl __attribute__((deprecated(message)))
                      ^
3 errors generated.

Oops, sorry about that, I missed building the unit tests once again. Should be fixed by https://github.com/llvm/llvm-project/commit/24a72dc070b36d9e62d6b84abe5f1912c5a49581.

Nice to see that we have this now! (There was an earlier attempt in D18964 that somehow didn't make it.)

llvm/include/llvm-c/Deprecated.h
26–29

Can't we always place the attribute in front of the declaration, and then remove the need to pass decl into the macro? Then we could write

LLVM_ATTRIBUTE_C_DEPRECATED("Use LLVMBar instead")
void LLVMFoo(void);
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 3:53 PM