Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: src/IceGlobalInits.h

Issue 1740033002: Force __pnacl_pso_root to be an external declaration. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Removing unused argument Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/PNaClTranslator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceGlobalInits.h - Global declarations -------*- C++ -*-===// 1 //===- subzero/src/IceGlobalInits.h - Global declarations -------*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool isProto() const { return IsProto; } 147 bool isProto() const { return IsProto; }
148 static bool classof(const GlobalDeclaration *Addr) { 148 static bool classof(const GlobalDeclaration *Addr) {
149 return Addr->getKind() == FunctionDeclarationKind; 149 return Addr->getKind() == FunctionDeclarationKind;
150 } 150 }
151 void dumpType(Ostream &Stream) const final; 151 void dumpType(Ostream &Stream) const final;
152 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 152 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
153 bool getSuppressMangling() const final { return isExternal() && IsProto; } 153 bool getSuppressMangling() const final { return isExternal() && IsProto; }
154 154
155 /// Returns true if linkage is correct for the function declaration. 155 /// Returns true if linkage is correct for the function declaration.
156 bool verifyLinkageCorrect(const GlobalContext *Ctx) const { 156 bool verifyLinkageCorrect(const GlobalContext *Ctx) const {
157 if (isPNaClABIExternalName() || isIntrinsicName(Ctx)) 157 if (isPNaClABIExternalName() || isIntrinsicName(Ctx))
Mark Seaborn 2016/02/26 01:56:57 This check is actually backwards. It should be:
Sean Klein 2016/02/26 02:28:06 This is small (and related) enough that I've updat
158 return Linkage == llvm::GlobalValue::ExternalLinkage; 158 return Linkage == llvm::GlobalValue::ExternalLinkage;
159 return verifyLinkageDefault(Ctx); 159 return verifyLinkageDefault(Ctx);
160 } 160 }
161 161
162 /// Validates that the type signature of the function is correct. Returns true 162 /// Validates that the type signature of the function is correct. Returns true
163 /// if valid. 163 /// if valid.
164 bool validateTypeSignature(const GlobalContext *Ctx) const { 164 bool validateTypeSignature(const GlobalContext *Ctx) const {
165 bool IsIntrinsic; 165 bool IsIntrinsic;
166 if (const Intrinsics::FullIntrinsicInfo *Info = 166 if (const Intrinsics::FullIntrinsicInfo *Info =
167 getIntrinsicInfo(Ctx, &IsIntrinsic)) 167 getIntrinsicInfo(Ctx, &IsIntrinsic))
(...skipping 23 matching lines...) Expand all
191 bool IsProto; 191 bool IsProto;
192 192
193 FunctionDeclaration(const FuncSigType &Signature, 193 FunctionDeclaration(const FuncSigType &Signature,
194 llvm::CallingConv::ID CallingConv, 194 llvm::CallingConv::ID CallingConv,
195 llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) 195 llvm::GlobalValue::LinkageTypes Linkage, bool IsProto)
196 : GlobalDeclaration(FunctionDeclarationKind, Linkage), 196 : GlobalDeclaration(FunctionDeclarationKind, Linkage),
197 Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {} 197 Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {}
198 198
199 bool isPNaClABIExternalName() const { 199 bool isPNaClABIExternalName() const {
200 const char *Name = getName().c_str(); 200 const char *Name = getName().c_str();
201 return strcmp(Name, "_start") == 0 || strcmp(Name, "__pnacl_pso_root") == 0; 201 return strcmp(Name, "_start") == 0;
202 } 202 }
203 203
204 bool isIntrinsicName(const GlobalContext *Ctx) const { 204 bool isIntrinsicName(const GlobalContext *Ctx) const {
205 bool IsIntrinsic; 205 bool IsIntrinsic;
206 getIntrinsicInfo(Ctx, &IsIntrinsic); 206 getIntrinsicInfo(Ctx, &IsIntrinsic);
207 return IsIntrinsic; 207 return IsIntrinsic;
208 } 208 }
209 209
210 bool validateRegularTypeSignature() const; 210 bool validateRegularTypeSignature() const;
211 211
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 409
410 /// Prints out type for initializer associated with the declaration to Stream. 410 /// Prints out type for initializer associated with the declaration to Stream.
411 void dumpType(Ostream &Stream) const final; 411 void dumpType(Ostream &Stream) const final;
412 412
413 /// Prints out the definition of the global variable declaration (including 413 /// Prints out the definition of the global variable declaration (including
414 /// initialization). 414 /// initialization).
415 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 415 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
416 416
417 /// Returns true if linkage is correct for the variable declaration. 417 /// Returns true if linkage is correct for the variable declaration.
418 bool verifyLinkageCorrect(const GlobalContext *Ctx) const { 418 bool verifyLinkageCorrect(const GlobalContext *Ctx) const {
419 if (isPNaClABIExternalName()) {
420 return Linkage == llvm::GlobalValue::ExternalLinkage;
421 }
419 return verifyLinkageDefault(Ctx); 422 return verifyLinkageDefault(Ctx);
420 } 423 }
421 424
425 /// Returns true if the linkage was updated.
426 bool forcePNaClABILinkage() {
427 if (isPNaClABIExternalName()) {
428 /// Force Linkage to be External for PNaCl ABI.
Mark Seaborn 2016/02/26 01:56:56 Nit: Just "//" Also you probably don't want to ca
Sean Klein 2016/02/26 02:28:06 Updated. Re: "//", I was just trying to match the
429 setLinkage(llvm::GlobalValue::ExternalLinkage);
Mark Seaborn 2016/02/26 01:56:57 A comment about why this is necessary would be goo
Sean Klein 2016/02/26 02:28:06 Comment added. Where would you recommend doing tha
430 return true;
431 }
432 return false;
433 }
434
422 static bool classof(const GlobalDeclaration *Addr) { 435 static bool classof(const GlobalDeclaration *Addr) {
423 return Addr->getKind() == VariableDeclarationKind; 436 return Addr->getKind() == VariableDeclarationKind;
424 } 437 }
425 438
426 bool getSuppressMangling() const final { 439 bool getSuppressMangling() const final {
427 if (ForceSuppressMangling) 440 if (ForceSuppressMangling)
428 return true; 441 return true;
429 return isExternal() && !hasInitializer(); 442 return isExternal() && !hasInitializer();
430 } 443 }
431 444
432 void setSuppressMangling() { ForceSuppressMangling = true; } 445 void setSuppressMangling() { ForceSuppressMangling = true; }
433 446
434 void discardInitializers() { Initializers = nullptr; } 447 void discardInitializers() { Initializers = nullptr; }
435 448
436 private: 449 private:
450 bool isPNaClABIExternalName() const {
451 const char *Name = getName().c_str();
452 return strcmp(Name, "__pnacl_pso_root") == 0;
453 }
454
437 /// List of initializers for the declared variable. 455 /// List of initializers for the declared variable.
438 std::unique_ptr<InitializerListType> Initializers; 456 std::unique_ptr<InitializerListType> Initializers;
439 bool HasInitializer; 457 bool HasInitializer;
440 /// The alignment of the declared variable. 458 /// The alignment of the declared variable.
441 uint32_t Alignment; 459 uint32_t Alignment;
442 /// True if a declared (global) constant. 460 /// True if a declared (global) constant.
443 bool IsConstant; 461 bool IsConstant;
444 /// If set to true, force getSuppressMangling() to return true. 462 /// If set to true, force getSuppressMangling() to return true.
445 bool ForceSuppressMangling; 463 bool ForceSuppressMangling;
446 464
(...skipping 14 matching lines...) Expand all
461 template <class StreamType> 479 template <class StreamType>
462 inline StreamType &operator<<(StreamType &Stream, 480 inline StreamType &operator<<(StreamType &Stream,
463 const GlobalDeclaration &Addr) { 481 const GlobalDeclaration &Addr) {
464 Addr.dump(Stream); 482 Addr.dump(Stream);
465 return Stream; 483 return Stream;
466 } 484 }
467 485
468 } // end of namespace Ice 486 } // end of namespace Ice
469 487
470 #endif // SUBZERO_SRC_ICEGLOBALINITS_H 488 #endif // SUBZERO_SRC_ICEGLOBALINITS_H
OLDNEW
« no previous file with comments | « no previous file | src/PNaClTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698