From de49f360ec4780acb382a3ae923d1716fdb0dc03 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 10 Sep 2010 18:51:56 +0000 Subject: [PATCH] Auto-upgrade the magic ".llvm.eh.catch.all.value" global to "llvm.eh.catch.all.value". Only the name needs to be changed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113600 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/AutoUpgrade.h | 5 +++++ lib/Bitcode/Reader/BitcodeReader.cpp | 6 ++++++ lib/VMCore/AutoUpgrade.cpp | 14 ++++++++++++++ test/Bitcode/AutoUpgradeGlobals.ll | 3 +++ test/Bitcode/AutoUpgradeGlobals.ll.bc | Bin 0 -> 312 bytes 5 files changed, 28 insertions(+) create mode 100644 test/Bitcode/AutoUpgradeGlobals.ll create mode 100644 test/Bitcode/AutoUpgradeGlobals.ll.bc diff --git a/include/llvm/AutoUpgrade.h b/include/llvm/AutoUpgrade.h index 0a81c807956..5ce20b69e2f 100644 --- a/include/llvm/AutoUpgrade.h +++ b/include/llvm/AutoUpgrade.h @@ -16,6 +16,7 @@ namespace llvm { class Module; + class GlobalVariable; class Function; class CallInst; @@ -35,6 +36,10 @@ namespace llvm { /// so that it can update all calls to the old function. void UpgradeCallsToIntrinsic(Function* F); + /// This checks for global variables which should be upgraded. It returns true + /// if it requires upgrading. + bool UpgradeGlobalVariable(GlobalVariable *GV); + /// This function checks debug info intrinsics. If an intrinsic is invalid /// then this function simply removes the intrinsic. void CheckDebugInfoIntrinsics(Module *M); diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 02b1fb0e6b4..74b8e40a18d 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1288,6 +1288,12 @@ bool BitcodeReader::ParseModule() { UpgradedIntrinsics.push_back(std::make_pair(FI, NewFn)); } + // Look for global variables which need to be renamed. + for (Module::global_iterator + GI = TheModule->global_begin(), GE = TheModule->global_end(); + GI != GE; ++GI) + UpgradeGlobalVariable(GI); + // Force deallocation of memory for these vectors to favor the client that // want lazy deserialization. std::vector >().swap(GlobalInits); diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index fd64460d6fd..3908e8aed68 100644 --- a/lib/VMCore/AutoUpgrade.cpp +++ b/lib/VMCore/AutoUpgrade.cpp @@ -365,6 +365,20 @@ bool llvm::UpgradeIntrinsicFunction(Function *F, Function *&NewFn) { return Upgraded; } +bool llvm::UpgradeGlobalVariable(GlobalVariable *GV) { + const std::string &Name = GV->getName(); + + // We are only upgrading one symbol here. If we upgrade more, we will want to + // perform some sort of short-circuiting like in the + // "UpgradeIntrinsicFunction1" function. + if (Name == ".llvm.eh.catch.all.value") { + GV->setName("llvm.eh.catch.all.value"); + return true; + } + + return false; +} + /// ExtendNEONArgs - For NEON "long" and "wide" operations, where the results /// have vector elements twice as big as one or both source operands, do the /// sign- or zero-extension that used to be handled by intrinsics. The diff --git a/test/Bitcode/AutoUpgradeGlobals.ll b/test/Bitcode/AutoUpgradeGlobals.ll new file mode 100644 index 00000000000..8a8767337dc --- /dev/null +++ b/test/Bitcode/AutoUpgradeGlobals.ll @@ -0,0 +1,3 @@ +; This isn't really an assembly file. It just runs test on bitcode to ensure +; it is auto-upgraded. +; RUN: llvm-dis < %s.bc | not grep {i32 @\\.llvm\\.eh} diff --git a/test/Bitcode/AutoUpgradeGlobals.ll.bc b/test/Bitcode/AutoUpgradeGlobals.ll.bc new file mode 100644 index 0000000000000000000000000000000000000000..1abe9688e291ccdedf5e7516cef2b111d450ffe4 GIT binary patch literal 312 zcmZ>AK5$Qwhk?PHfq{WhfPp~>NV7L8Pjo!N;>jjpWI2hkg-4Z@LsE{VJE?)kmC0!m zw^NFMk%$F{geRAgi;4%=1V!Z|K@B{TibX2yCr$_?tyr+a;n)X8pgEor3=GUbn!Dvc z5Xd_SFflL$Dljl`0>zA!PH-rsHnlLQIeV~jsyQEHbuv=p;1NpfV^EyNpbS*Oz@RNv zmcU+}!ET<>UbLXSK%u<=NM5K^aAcBHWK{Xk$mhw%zyLI}K}Udr6=bH|3=T;_p9wvj zYVOBaoDXpT#S#@57=Wr6gjpCFRe)vyl{1(bgd70TAW#W(BZzIx(I9i=p$tQz0?_|J iK3l`j(?N!Ig+G`KINSMky5kwST_YF*1A2jSAOHZ^5JPbQ literal 0 HcmV?d00001