[llvm-branch-commits] [llvm-branch] r196822 - Merging r196158:
Manman Ren
manman.ren at gmail.com
Mon Dec 9 13:06:30 PST 2013
Author: mren
Date: Mon Dec 9 15:06:30 2013
New Revision: 196822
URL: http://llvm.org/viewvc/llvm-project?rev=196822&view=rev
Log:
Merging r196158:
------------------------------------------------------------------------
r196158 | mren | 2013-12-02 13:29:56 -0800 (Mon, 02 Dec 2013) | 12 lines
Debug Info: drop debug info via upgrading path if version number does not match.
Add a helper function getDebugInfoVersionFromModule to return the debug info
version number for a module.
"Verifier/module-flags-1.ll" checks for verification errors.
It will seg fault when calling getDebugInfoVersionFromModule because of the
incorrect format for module flags in the testing case. We make
getModuleFlagsMetadata more robust by checking for error conditions.
PR17982
------------------------------------------------------------------------
Added:
llvm/branches/release_34/test/Bitcode/drop-debug-info.ll
- copied unchanged from r196158, llvm/trunk/test/Bitcode/drop-debug-info.ll
Modified:
llvm/branches/release_34/ (props changed)
llvm/branches/release_34/include/llvm/AutoUpgrade.h
llvm/branches/release_34/include/llvm/DebugInfo.h
llvm/branches/release_34/lib/AsmParser/LLParser.cpp
llvm/branches/release_34/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/branches/release_34/lib/IR/AutoUpgrade.cpp
llvm/branches/release_34/lib/IR/DebugInfo.cpp
llvm/branches/release_34/lib/IR/Module.cpp
Propchange: llvm/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 9 15:06:30 2013
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195136,195138,195148,195152,195156-195157,195161-195162,195193,195272,195317-195318,195327,195330,195333,195339,195343,195355,195364,195379,195397-195399,195401,195408,195421,195423-195424,195432,195439,195444,195455-195456,195469,195476-195477,195479,195491-195495,195504-195505,195514,195528,195535,195547,195567,195573-195576,195590-195591,195599,195632,195635-195636,195670,195677,195679,195682,195684,195713,195716,195769,195773,195779,195782,195787-195788,195791,195803,195812,195827,195834,195843-195844,195878-195881,195887,195903,195905,195912,195915,195932,195936-195943,195972-195973,195975-195976,196004,196044-196046,196069,196100,196104,196129,196144,196151,196153,196156,196189-196192,196198-196199,196208-196211,196261,196267,196269,196294,196359-196362,196369,196391,196456,196493,196508,196532-196533,196535,196538,196588,196611,196637-196638,196658,196668,196725,196735,196751,196755
+/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195136,195138,195148,195152,195156-195157,195161-195162,195193,195272,195317-195318,195327,195330,195333,195339,195343,195355,195364,195379,195397-195399,195401,195408,195421,195423-195424,195432,195439,195444,195455-195456,195469,195476-195477,195479,195491-195495,195504-195505,195514,195528,195535,195547,195567,195573-195576,195590-195591,195599,195632,195635-195636,195670,195677,195679,195682,195684,195713,195716,195769,195773,195779,195782,195787-195788,195791,195803,195812,195827,195834,195843-195844,195878-195881,195887,195903,195905,195912,195915,195932,195936-195943,195972-195973,195975-195976,196004,196044-196046,196069,196100,196104,196129,196144,196151,196153,196156,196158,196189-196192,196198-196199,196208-196211,196261,196267,196269,196294,196359-196362,196369,196391,196456,196493,196508,196532-196533,196535,196538,196588,196611,196637-196638,196658,196668,196725,196735,196751,196755
Modified: llvm/branches/release_34/include/llvm/AutoUpgrade.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/include/llvm/AutoUpgrade.h?rev=196822&r1=196821&r2=196822&view=diff
==============================================================================
--- llvm/branches/release_34/include/llvm/AutoUpgrade.h (original)
+++ llvm/branches/release_34/include/llvm/AutoUpgrade.h Mon Dec 9 15:06:30 2013
@@ -57,6 +57,10 @@ namespace llvm {
/// with different address spaces: the instruction is replaced by a pair
/// ptrtoint+inttoptr.
Value *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy);
+
+ /// Check the debug info version number, if it is out-dated, drop the debug
+ /// info. Return true if module is modified.
+ bool UpgradeDebugInfo(Module &M);
} // End llvm namespace
#endif
Modified: llvm/branches/release_34/include/llvm/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/include/llvm/DebugInfo.h?rev=196822&r1=196821&r2=196822&view=diff
==============================================================================
--- llvm/branches/release_34/include/llvm/DebugInfo.h (original)
+++ llvm/branches/release_34/include/llvm/DebugInfo.h Mon Dec 9 15:06:30 2013
@@ -759,6 +759,9 @@ DITypeIdentifierMap generateDITypeIdenti
/// Return true if module is modified.
bool StripDebugInfo(Module &M);
+/// Return Debug Info Version by checking module flags.
+unsigned getDebugInfoVersionFromModule(const Module &M);
+
/// DebugInfoFinder tries to list all debug info MDNodes used in a module. To
/// list debug info MDNodes used by an instruction, DebugInfoFinder uses
/// processDeclare, processValue and processLocation to handle DbgDeclareInst,
Modified: llvm/branches/release_34/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/AsmParser/LLParser.cpp?rev=196822&r1=196821&r2=196822&view=diff
==============================================================================
--- llvm/branches/release_34/lib/AsmParser/LLParser.cpp (original)
+++ llvm/branches/release_34/lib/AsmParser/LLParser.cpp Mon Dec 9 15:06:30 2013
@@ -182,6 +182,8 @@ bool LLParser::ValidateEndOfModule() {
for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; )
UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
+ UpgradeDebugInfo(*M);
+
return false;
}
Modified: llvm/branches/release_34/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Bitcode/Reader/BitcodeReader.cpp?rev=196822&r1=196821&r2=196822&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/release_34/lib/Bitcode/Reader/BitcodeReader.cpp Mon Dec 9 15:06:30 2013
@@ -3152,6 +3152,7 @@ error_code BitcodeReader::MaterializeMod
for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++)
UpgradeInstWithTBAATag(InstsWithTBAATag[I]);
+ UpgradeDebugInfo(*M);
return error_code::success();
}
Modified: llvm/branches/release_34/lib/IR/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/IR/AutoUpgrade.cpp?rev=196822&r1=196821&r2=196822&view=diff
==============================================================================
--- llvm/branches/release_34/lib/IR/AutoUpgrade.cpp (original)
+++ llvm/branches/release_34/lib/IR/AutoUpgrade.cpp Mon Dec 9 15:06:30 2013
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/AutoUpgrade.h"
+#include "llvm/DebugInfo.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
@@ -489,3 +490,12 @@ Value *llvm::UpgradeBitCastExpr(unsigned
return 0;
}
+
+/// Check the debug info version number, if it is out-dated, drop the debug
+/// info. Return true if module is modified.
+bool llvm::UpgradeDebugInfo(Module &M) {
+ if (getDebugInfoVersionFromModule(M) == DEBUG_METADATA_VERSION)
+ return false;
+
+ return StripDebugInfo(M);
+}
Modified: llvm/branches/release_34/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/IR/DebugInfo.cpp?rev=196822&r1=196821&r2=196822&view=diff
==============================================================================
--- llvm/branches/release_34/lib/IR/DebugInfo.cpp (original)
+++ llvm/branches/release_34/lib/IR/DebugInfo.cpp Mon Dec 9 15:06:30 2013
@@ -1478,3 +1478,11 @@ bool llvm::StripDebugInfo(Module &M) {
return Changed;
}
+
+/// Return Debug Info Version by checking module flags.
+unsigned llvm::getDebugInfoVersionFromModule(const Module &M) {
+ Value *Val = M.getModuleFlag("Debug Info Version");
+ if (!Val)
+ return 0;
+ return cast<ConstantInt>(Val)->getZExtValue();
+}
Modified: llvm/branches/release_34/lib/IR/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/IR/Module.cpp?rev=196822&r1=196821&r2=196822&view=diff
==============================================================================
--- llvm/branches/release_34/lib/IR/Module.cpp (original)
+++ llvm/branches/release_34/lib/IR/Module.cpp Mon Dec 9 15:06:30 2013
@@ -318,11 +318,16 @@ getModuleFlagsMetadata(SmallVectorImpl<M
for (unsigned i = 0, e = ModFlags->getNumOperands(); i != e; ++i) {
MDNode *Flag = ModFlags->getOperand(i);
- ConstantInt *Behavior = cast<ConstantInt>(Flag->getOperand(0));
- MDString *Key = cast<MDString>(Flag->getOperand(1));
- Value *Val = Flag->getOperand(2);
- Flags.push_back(ModuleFlagEntry(ModFlagBehavior(Behavior->getZExtValue()),
- Key, Val));
+ if (Flag->getNumOperands() >= 3 && isa<ConstantInt>(Flag->getOperand(0)) &&
+ isa<MDString>(Flag->getOperand(1))) {
+ // Check the operands of the MDNode before accessing the operands.
+ // The verifier will actually catch these failures.
+ ConstantInt *Behavior = cast<ConstantInt>(Flag->getOperand(0));
+ MDString *Key = cast<MDString>(Flag->getOperand(1));
+ Value *Val = Flag->getOperand(2);
+ Flags.push_back(ModuleFlagEntry(ModFlagBehavior(Behavior->getZExtValue()),
+ Key, Val));
+ }
}
}
More information about the llvm-branch-commits
mailing list