This is an archive of the discontinued LLVM Phabricator instance.

[BPF] do not generate predefined macro bpf
ClosedPublic

Authored by yonghong-song on Apr 25 2019, 10:55 PM.

Details

Summary

"DefineStd(Builder, "bpf", Opts)" generates the following three macros:

bpf
__bpf
__bpf__

and the macro "bpf" is due to the fact that the target language
is C which allows GNU extensions.

The name "bpf" could be easily used as variable name or type
field name. For example, in current linux kernel, there are
four places where bpf is used as a field name. If the corresponding
types are included in bpf program, the compilation error will
occur.

This patch removed predefined macro "bpf" as well as "__bpf" which

is rarely used if used at all.

Diff Detail

Repository
rL LLVM

Event Timeline

yonghong-song created this revision.Apr 25 2019, 10:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2019, 10:55 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ast added inline comments.Apr 25 2019, 10:59 PM
lib/Basic/Targets/BPF.cpp
23 ↗(On Diff #196797)

I don't think anyone is using this one.
May be we can keep __bpf__ and __BPF__ only?

yonghong-song marked an inline comment as done.Apr 25 2019, 11:09 PM
yonghong-song added inline comments.
lib/Basic/Targets/BPF.cpp
23 ↗(On Diff #196797)

We can do this for sure.

yonghong-song edited the summary of this revision. (Show Details)

remove __bpf.

This revision is now accepted and ready to land.Apr 25 2019, 11:20 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2019, 8:33 AM