[llvm] r226546 - Bitcode: Don't create comdats when autoupgrading macho bitcode
Rafael EspĂndola
rafael.espindola at gmail.com
Tue Jan 20 05:22:47 PST 2015
Thanks!
On 20 January 2015 at 00:58, David Majnemer <david.majnemer at gmail.com> wrote:
> Author: majnemer
> Date: Mon Jan 19 23:58:07 2015
> New Revision: 226546
>
> URL: http://llvm.org/viewvc/llvm-project?rev=226546&view=rev
> Log:
> Bitcode: Don't create comdats when autoupgrading macho bitcode
>
> Don't infer COMDAT groups from older bitcode if the target is macho,
> it doesn't have COMDATs.
>
> Added:
> llvm/trunk/test/Bitcode/weak-macho-3.5.ll
> llvm/trunk/test/Bitcode/weak-macho-3.5.ll.bc
> Modified:
> llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
>
> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=226546&r1=226545&r2=226546&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jan 19 23:58:07 2015
> @@ -11,6 +11,7 @@
> #include "BitcodeReader.h"
> #include "llvm/ADT/SmallString.h"
> #include "llvm/ADT/SmallVector.h"
> +#include "llvm/ADT/Triple.h"
> #include "llvm/Bitcode/LLVMBitCodes.h"
> #include "llvm/IR/AutoUpgrade.h"
> #include "llvm/IR/Constants.h"
> @@ -1106,6 +1107,8 @@ std::error_code BitcodeReader::ParseValu
>
> SmallVector<uint64_t, 64> Record;
>
> + Triple TT(TheModule->getTargetTriple());
> +
> // Read all the records for this value table.
> SmallString<128> ValueName;
> while (1) {
> @@ -1137,8 +1140,12 @@ std::error_code BitcodeReader::ParseValu
>
> V->setName(StringRef(ValueName.data(), ValueName.size()));
> if (auto *GO = dyn_cast<GlobalObject>(V)) {
> - if (GO->getComdat() == reinterpret_cast<Comdat *>(1))
> - GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
> + if (GO->getComdat() == reinterpret_cast<Comdat *>(1)) {
> + if (TT.isOSBinFormatMachO())
> + GO->setComdat(nullptr);
> + else
> + GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
> + }
> }
> ValueName.clear();
> break;
>
> Added: llvm/trunk/test/Bitcode/weak-macho-3.5.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/weak-macho-3.5.ll?rev=226546&view=auto
> ==============================================================================
> --- llvm/trunk/test/Bitcode/weak-macho-3.5.ll (added)
> +++ llvm/trunk/test/Bitcode/weak-macho-3.5.ll Mon Jan 19 23:58:07 2015
> @@ -0,0 +1,11 @@
> +; RUN: llvm-dis < %s.bc| FileCheck %s
> +
> +; weak-macho-3.5.ll.bc was generated by passing this file to llvm-as-3.5
> +; The test checks that LLVM does not place weak GlobalVariables into Comdats for
> +; macho object files, they don't support it.
> +
> +target triple = "x86_64-apple-macosx10.9.0"
> +; CHECK: target triple = "x86_64-apple-macosx10.9.0"
> +
> + at x = weak global i32 0
> +; CHECK: @x = weak global i32 0{{$}}
>
> Added: llvm/trunk/test/Bitcode/weak-macho-3.5.ll.bc
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/weak-macho-3.5.ll.bc?rev=226546&view=auto
> ==============================================================================
> Binary files llvm/trunk/test/Bitcode/weak-macho-3.5.ll.bc (added) and llvm/trunk/test/Bitcode/weak-macho-3.5.ll.bc Mon Jan 19 23:58:07 2015 differ
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list