summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
AgeCommit message (Collapse)Author
2014-07-10Be more specific about return types of some methods.Alexey Samsonov
This would allow to call addCompilerUsedGlobal on some Clang-generated globals. llvm-svn: 212767
2014-07-09Decouple llvm::SpecialCaseList text representation and its LLVM IR semantics.Alexey Samsonov
Turn llvm::SpecialCaseList into a simple class that parses text files in a specified format and knows nothing about LLVM IR. Move this class into LLVMSupport library. Implement two users of this class: * DFSanABIList in DFSan instrumentation pass. * SanitizerBlacklist in Clang CodeGen library. The latter will be modified to use actual source-level information from frontend (source file names) instead of unstable LLVM IR things (LLVM Module identifier). Remove dependency edge from ClangCodeGen/ClangDriver to LLVMTransformUtils. No functionality change. llvm-svn: 212643
2014-07-07[Sanitizer] Reduce the usage of sanitizer blacklist in CodeGenModuleAlexey Samsonov
Get rid of cached CodeGenModule::SanOpts, which was used to turn off sanitizer codegen options if current LLVM Module is blacklisted, and use plain LangOpts.Sanitize instead. 1) Some codegen decisions (turning TBAA or writable strings on/off) shouldn't depend on the contents of blacklist. 2) llvm.asan.globals should *always* be created, even if the module is blacklisted - soon Clang's CodeGen where we read sanitizer blacklist files, so we should properly report which globals are blacklisted to the backend. llvm-svn: 212499
2014-07-07CodeGen: Refactor RTTI emissionDavid Majnemer
Let's not expose ABI specific minutia inside of CodeGenModule and Type. Instead, let's abstract it through CXXABI. This gets rid of: CodeGenModule::getCompleteObjectLocator, CodeGenModule::EmitFundamentalTypeDescriptor{s,}, CodeGenModule::getMSTypeDescriptor, CodeGenModule::getMSCompleteObjectLocator, CGCXXABI::shouldRTTIBeUnique, CGCXXABI::classifyRTTIUniqueness. CGRTTI was *almost* entirely centered around providing Itanium-style RTTI information. Instead of providing interfaces that only it consumes, move it to the ItaniumCXXABI implementation file. This allows it to have access to Itanium-specific implementation details without providing useless expansion points for the Microsoft ABI side. Differential Revision: http://reviews.llvm.org/D4261 llvm-svn: 212435
2014-07-03Move the calling of emitTargetMD() later.Robert Lytton
Summary: Because a global created by GetOrCreateLLVMGlobal() is not finalised until later viz: extern char a[]; char f(){ return a[5];} char a[10]; Change MangledDeclNames to use a MapVector rather than a DenseMap so that the Metadata is output in order of original declaration, so to make deterministic and improve human readablity. Differential Revision: http://reviews.llvm.org/D4176 llvm-svn: 212263
2014-07-03refactor for-loop as range-loop before making changes.Robert Lytton
Differential Revision: http://reviews.llvm.org/D4176 llvm-svn: 212262
2014-07-02[ASan] Print exact source location of global variables in error reports.Alexey Samsonov
See https://code.google.com/p/address-sanitizer/issues/detail?id=299 for the original feature request. Introduce llvm.asan.globals metadata, which Clang (or any other frontend) may use to report extra information about global variables to ASan instrumentation pass in the backend. This metadata replaces llvm.asan.dynamically_initialized_globals that was used to detect init-order bugs. llvm.asan.globals contains the following data for each global: 1) source location (file/line/column info); 2) whether it is dynamically initialized; 3) whether it is blacklisted (shouldn't be instrumented). Source location data is then emitted in the binary and can be picked up by ASan runtime in case it needs to print error report involving some global. For example: 0x... is located 4 bytes to the right of global variable 'C::array' defined in '/path/to/file:17:8' (0x...) of size 40 These source locations are printed even if the binary doesn't have any debug info. This is an ABI-breaking change. ASan initialization is renamed to __asan_init_v4(). Pre-built libraries compiled with older Clang will not work with the fresh runtime. llvm-svn: 212188
2014-06-26CodeGen: Improve warnings about uninstrumented files when profilingJustin Bogner
Improve the warning when building with -fprofile-instr-use and a file appears not to have been profiled at all. This keys on whether a function is defined in the main file or not to avoid false negatives when one includes a header with functions that have been profiled. llvm-svn: 211760
2014-06-23CodeGen: Remove a stray tab character (NFC)Justin Bogner
llvm-svn: 211528
2014-06-20Add module flags metadata to record the settings for enum and wchar widthOliver Stannard
Add module flags metadata to record the settings for enum and wchar width, to allow correct ARM build attribute generation llvm-svn: 211354
2014-06-12Replace llvm::error_code with std::error_code.Rafael Espindola
llvm-svn: 210780
2014-06-11CodeGen: Correct linkage of thread_local for OS XDavid Majnemer
The backing store of thread local variables is internal for OS X and all accesses must go through the thread wrapper. However, individual TUs may have inlined through the thread wrapper. To fix this, give the thread wrapper functions WeakAnyLinkage. This prevents them from getting inlined into call-sites. This fixes PR19989. llvm-svn: 210632
2014-06-09[C++11] Use 'nullptr'.Craig Topper
llvm-svn: 210448
2014-06-05Implement -Wframe-larger-than backend diagnosticAlp Toker
Add driver and frontend support for the GCC -Wframe-larger-than=bytes warning. This is the first GCC-compatible backend diagnostic built around LLVM's reporting feature. This commit adds infrastructure to perform reverse lookup from mangled names emitted after LLVM IR generation. We use that to resolve precise locations and originating AST functions, lambdas or block declarations to produce seamless codegen-guided diagnostics. An associated change, StringMap now maintains unique mangled name strings instead of allocating copies. This is a net memory saving in C++ and a small hit for C where we no longer reuse IdentifierInfo storage, pending further optimisation. llvm-svn: 210293
2014-06-04Remove the overload of GetAddrOfConstantString methodAlexey Samsonov
llvm-svn: 210214
2014-06-04Refactor and generalize GetAddrOfConstantString and ↵Alexey Samsonov
GetAddrOfConstantStringFromLiteral. Share mode code between these functions and re-structure them in a way which shows how similar they actually are. The latter function works well with literals of multi-byte chars and does a GlobalVariable name mangling (if global strings are non-writable). No functionality change. llvm-svn: 210212
2014-06-04This cast is not necessary any more (llvm api change).Rafael Espindola
llvm-svn: 210206
2014-06-03Update for llvm API change.Rafael Espindola
Aliases in llvm now hold an arbitrary expression. llvm-svn: 210063
2014-06-03Eliminate redundant MangleBuffer classAlp Toker
The only remaining user didn't actually use the non-dynamic storage facility this class provides. The std::string is transitional and likely to be StringRefized shortly. llvm-svn: 210058
2014-05-29MS ABI: Emit static data members with proper linkageNico Rieck
llvm-svn: 209826
2014-05-29[ASan] Hoist blacklisting globals from init-order checking to Clang.Alexey Samsonov
Clang knows about the sanitizer blacklist and it makes no sense to add global to the list of llvm.asan.dynamically_initialized_globals if it will be blacklisted in the instrumentation pass anyway. Instead, we should do as much blacklisting as possible (if not all) in the frontend. llvm-svn: 209789
2014-05-28Don't dllimport/export destructor variants implemented by thunks.Hans Wennborg
MSVC doesn't export these functions, so trying to import them doesnt' work. Also, don't let any dll attributes on the CXXDestructorDecl influence the thunk's linkage -- they should always be linkonce_odr. This takes care of the FIXME's for this in Nico's tests. Differential Revision: http://reviews.llvm.org/D3930 llvm-svn: 209706
2014-05-23Use comdats to avoid double initialization of weak dataReid Kleckner
Initializers of global data that can appear multiple TUs (static data members of class templates or __declspec(selectany) data) are now in a comdat group keyed on the global variable being initialized. On non-Windows platforms, this is a code size and startup time optimization. On Windows, this is necessary for ABI compatibility with MSVC. Fixes PR16959. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D3811 llvm-svn: 209555
2014-05-22Don't set unnamed_addr in CreateRuntimeVariable.Rafael Espindola
This was fairly broken. For example, @__dso_handle would or would not get an unnamed_addr depending on how many global destructors were used in a translation unit. The consensus was that not every runtime variable is unnamed_addr and that __dso_handle handle should not be, so just don't add unnamed_addr in CreateRuntimeVariable. llvm-svn: 209484
2014-05-21[C++11] Use 'nullptr'. CodeGen edition.Craig Topper
llvm-svn: 209272
2014-05-19Demote the "Debug Info Version" module flag to llvm::Module::WarningAdrian Prantl
behavior on mismatch. The AutoUpgrader will drop incompatible debug info any way and also emit a warning diagnostic for it. rdar://problem/16926122 llvm-svn: 209182
2014-05-17Update for llvm api change.Rafael Espindola
llvm-svn: 209077
2014-05-17Update for llvm api change.Rafael Espindola
llvm-svn: 209074
2014-05-16Use getAliasee instead of getAliasedGlobal.Rafael Espindola
No functionality change. llvm-svn: 209038
2014-05-16Update for llvm api change.Rafael Espindola
Now that llvm cannot represent alias cycles, we have to diagnose erros just before trying to close the cycle. This degrades the errors a bit. The real solution is what it was before: if we want to provide good errors for these cases, we have to be able to find a clang level decl given a mangled name and produce the error from Sema. llvm-svn: 209008
2014-05-16Update for llvm API change.Rafael Espindola
llvm-svn: 208984
2014-05-15Allow dllimport/dllexport on inline functions and adjust the linkage.Hans Wennborg
This is a step towards handling these attributes on classes (PR11170). Differential Revision: http://reviews.llvm.org/D3772 llvm-svn: 208925
2014-05-14Rename CodeGenModule::getLLVMLinkageforDeclarator -> getLLVMLinkageForDeclaratorHans Wennborg
No functionality change. llvm-svn: 208808
2014-05-13Update for llvm API change.Rafael Espindola
llvm-svn: 208717
2014-05-09Pacify bots again - turns out my checkout was slightly polluted when I was ↵James Molloy
reverting a olista01s change, and this pollution made it upstream during the revert checkin :/ Sorryemacs -nw lib/CodeGen/CodeGenModule.cpp llvm-svn: 208426
2014-05-09Revert r208417 (olista01 'ARM: HFAs must be passed in consecutive ↵James Molloy
registers'). This is a followon commit from r208413 which broke the LLVM bots. llvm-svn: 208422
2014-05-09Use auto to avoid duplicating the type.Rafael Espindola
llvm-svn: 208374
2014-05-08Cleanup setFunctionDefinitionAttributes.Rafael Espindola
Use more specific type, update comments and name style. llvm-svn: 208328
2014-05-08Small simplification: Reduce the use of cast<>.Rafael Espindola
llvm-svn: 208320
2014-05-06[OPENMP] Initial codegen for '#pragma omp parallel'Alexey Bataev
llvm-svn: 208077
2014-05-05Fix pr19653.Rafael Espindola
Warn if an alias requests a section other than the aliasee section. llvm-svn: 207997
2014-05-05Small refactoring, no functionality change.Rafael Espindola
llvm-svn: 207991
2014-05-02XCore target: fix bug in dereferencing null pointer.Robert Lytton
Also add basic cpp ABI tests where they differ from C ABI output. llvm-svn: 207834
2014-05-02XCore target: Add TypeString meta data to IR output.Robert Lytton
This includes the addition of the virtual function: TargetCodeGenInfo::EmitTargetMD() llvm-svn: 207832
2014-05-01AST: Mangle reference temporaries reliablyDavid Majnemer
Summary: Previously, we would generate a single name for all reference temporaries and allow LLVM to rename them for us. Instead, number the reference temporaries as we build them in Sema. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3554 llvm-svn: 207776
2014-04-29CodeGen: Reference temporaries inherit visibilityDavid Majnemer
Reference temporaries inherited many properties from the variable that they correspond to but visibility wasn't one of them. llvm-svn: 207496
2014-04-28CodeGen: Fix linkage of reference temporariesDavid Majnemer
Summary: A reference temporary should inherit the linkage of the variable it initializes. Otherwise, we may hit cases where a reference temporary wouldn't have the same value in all translation units. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3515 llvm-svn: 207451
2014-04-25CodeGen: Cleanup variable linkage calculationDavid Majnemer
Almost all linkage calculation for VarDecls occured inside of GetLLVMLinkageVarDefinition except for static data members. Centralize the logic so that it can be more readily reused. No functionality change. llvm-svn: 207241
2014-04-25CodeGen: Refactor linkage/visibility calculationDavid Majnemer
It turns out that linkage and visibility have rather similar logic for both functions and non-variable globals. Split the calculation out so that both sides may share this code. No functionality change. llvm-svn: 207239
2014-04-19Remove some empty statementsAlp Toker
Cleanup only. llvm-svn: 206709