This is an archive of the discontinued LLVM Phabricator instance.

Remove uses of push_macro/pop_macro in APInt::KnuthDiv
AbandonedPublic

Authored by teemperor on Aug 3 2018, 11:09 AM.

Details

Reviewers
craig.topper
Summary

The APInt::KnuthDiv uses push_macro/pop_macro to temporarily redefine the LLVM_DEBUG macro.

It turns out that when building with LLVM_ENABLE_MODULES, clang doesn't correctly
handle the push_macro/pop_macro pragmas, which causes that LLVM_DEBUG is actually undefined
after KnuthDiv calls pop_macro. This hasn't been a problem so far as we never used LLVM_DEBUG
after the KnuthDiv implementation.

However, rL338758 added new uses of the LLVM_DEBUG macro after the KnuthDiv implementation,
which now fail to compile with LLVM_ENABLE_MODULES as clang can't find the definition of
LLVM_DEBUG.

To fix the LLVM builds with enabled modules, we either move the KnuthDiv implementation to the end
of the file, or we just replace the use of push_macro/pop_macro pragmas. This patch uses the latter
option because it's less intrusive to the change log.

Diff Detail

Event Timeline

teemperor created this revision.Aug 3 2018, 11:09 AM
kristina added a subscriber: kristina.EditedAug 3 2018, 3:36 PM

D50232 is essentially identical to this one except for KNUTH_DEBUG vs LLVM_KNUTH_DEBUG. I tested the former and it seems fine.

teemperor abandoned this revision.Aug 3 2018, 3:44 PM

Oh right, didn't see that.