diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-06-05 11:20:20 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-06-05 11:20:20 -0700 |
commit | c0d9b337419b72e69cbd9c64f84ae39560ab344f (patch) | |
tree | 357d707887775feadeb1fa26a94dfbff96e2605b /lib/Analysis | |
parent | 69a8e32d4f4451e11cda6d48b318ba4f7e01c683 (diff) |
PNaCl ABI: Strip out attributes on functions and function calls
Add a pass, StripAttributes, for doing this, and enable it.
Add an ABI check to reject these attributes.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=2346
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3415
TEST=*.ll tests + PNaCl toolchain trybots
Review URL: https://codereview.chromium.org/16325025
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp | 2 | ||||
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyModule.cpp | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp index 43eef2f6c0..167cad15d0 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp @@ -258,6 +258,8 @@ const char *PNaClABIVerifyFunctions::checkInstruction(const Instruction *Inst) { case Instruction::Call: if (cast<CallInst>(Inst)->isInlineAsm()) return "inline assembly"; + if (!cast<CallInst>(Inst)->getAttributes().isEmpty()) + return "bad call attributes"; // Intrinsic calls can have multiple pointer arguments and // metadata arguments, so handle them specially. diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp index 7daeabd0e8..91f71c949c 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp @@ -305,6 +305,18 @@ static bool isCompoundElement(const Constant *C) { return true; } +static std::string getAttributesAsString(AttributeSet Attrs) { + std::string AttrsAsString; + for (unsigned Slot = 0; Slot < Attrs.getNumSlots(); ++Slot) { + for (AttributeSet::iterator Attr = Attrs.begin(Slot), + E = Attrs.end(Slot); Attr != E; ++Attr) { + AttrsAsString += " "; + AttrsAsString += Attr->getAsString(); + } + } + return AttrsAsString; +} + // This checks that the GlobalVariable has the normal form produced by // the FlattenGlobals pass. void PNaClABIVerifyModule::checkGlobalIsFlattened(const GlobalVariable *GV) { @@ -366,6 +378,11 @@ bool PNaClABIVerifyModule::runOnModule(Module &M) { Reporter->addError() << "Function " << MI->getName() << " is declared but not defined (disallowed)\n"; } + if (!MI->getAttributes().isEmpty()) { + Reporter->addError() + << "Function " << MI->getName() << " has disallowed attributes:" + << getAttributesAsString(MI->getAttributes()) << "\n"; + } } checkGlobalValueCommon(MI); |