aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/BackendUtil.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-08-30[sanitizer-coverage] add two more modes of instrumentation: trace-div and ↵Kostya Serebryany1-0/+2
trace-gep, mostly usaful for value-profile-based fuzzing; clang part llvm-svn: 280044
2016-08-17[ThinLTO] Adapt backend invocation to llvm API changes.Mehdi Amini1-4/+18
Reviewers: tejohnson Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D23579 llvm-svn: 278906
2016-08-17[PM] Update Clang for LLVM's r278896 which re-organized a header.Chandler Carruth1-2/+3
(sorry this didn't get landed closer in time...) llvm-svn: 278897
2016-08-12CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.Teresa Johnson1-33/+64
Summary: This changes clang to use the llvm::lto::thinBackend function instead of its own less comprehensive ThinLTO backend implementation. Patch by Peter Collingbourne Reviewers: tejohnson, mehdi_amini Subscribers: cfe-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D21545 llvm-svn: 278541
2016-08-08[ARM] Command-line options for embedded position-independent codeOliver Stannard1-0/+6
This patch (with the corresponding ARM backend patch) adds support for some new relocation models: * Read-only position independence (ROPI): Code and read-only data is accessed PC-relative. The offsets between all code and RO data sections are known at static link time. * Read-write position independence (RWPI): Read-write data is accessed relative to a static base register. The offsets between all writeable data sections are known at static link time. These two modes are independent (they specify how different objects should be addressed), so they can be used individually or together. These modes are intended for bare-metal systems or systems with small real-time operating systems. They are designed to avoid the need for a dynamic linker, the only initialisation required is setting the static base register to an appropriate value for RWPI code. There is one C construct not currently supported by these modes: global variables initialised to the address of another global variable or function, where that address is not known at static-link time. There are a few possible ways to solve this: * Disallow this, and require the user to write their own initialisation function if they need variables like this. * Emit dynamic initialisers for these variables in the compiler, called from the .init_array section (as is currently done for C++ dynamic initialisers). We have a patch to do this, described in my original RFC email (http://lists.llvm.org/pipermail/llvm-dev/2015-December/093022.html), but the feedback from that RFC thread was that this is not something that belongs in clang. * Use a small dynamic loader to fix up these variables, by adding the difference between the load and execution address of the relevant section. This would require linker co-operation to generate a table of addresses that need fixing up. Differential Revision: https://reviews.llvm.org/D23196 llvm-svn: 278016
2016-07-29Initial vectorization support for svml calls (short vector math library).Matt Masten1-0/+3
Differential Revision: https://reviews.llvm.org/D19544 llvm-svn: 277167
2016-07-27Add flags to toggle preservation of assembly commentsNirav Dave1-0/+1
Summary: Add -fpreserve-as-comments and -fno-preserve-as-comments. Reviewers: echristo, rnk Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D22883 llvm-svn: 276907
2016-07-23[Profile] Use a flag to enable PGO rather than the profraw filenameXinliang David Li1-0/+1
Patch by Jake VanAdrighem Differential Revision: http://reviews.llvm.org/D22608 llvm-svn: 276517
2016-07-22[Profile] Enable profile merging with -fprofile-generat[=<dir>]Xinliang David Li1-1/+1
This patch enables raw profile merging for this option which is the new intended behavior. llvm-svn: 276484
2016-07-15Frontend: Simplify ownership model for clang's output streams.Peter Collingbourne1-87/+60
This changes the CompilerInstance::createOutputFile function to return a std::unique_ptr<llvm::raw_ostream>, rather than an llvm::raw_ostream implicitly owned by the CompilerInstance. This in most cases required that I move ownership of the output stream to the relevant ASTConsumer. The motivation for this change is to allow BackendConsumer to be a client of interfaces such as D20268 which take ownership of the output stream. Differential Revision: http://reviews.llvm.org/D21537 llvm-svn: 275507
2016-07-10Delete dead code.Sean Silva1-1/+0
We were just setting DisableUnitAtATime to its default value. llvm-svn: 275005
2016-06-23Invoke simplifycfg and sroa before instcombine.Dehao Chen1-3/+9
Summary: InstCombine needs to be performed after simplifycfg and sroa, otherwise it may make bad optimization decisions. Reviewers: davidxl, wmi, dnovillo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D21568 llvm-svn: 273606
2016-06-22Add support for /Ob1 and -finline-hint-functions flagsHans Wennborg1-1/+2
Add support for /Ob1 (and equivalent -finline-hint-functions), which enable inlining only for functions marked inline, either explicitly (via inline keyword, for example), or implicitly (function definition in class body, for example). This works by enabling inlining pass, and adding noinline attribute to every function not marked inline. Patch by Rudy Pons <rudy.pons@ilod.org>! Differential Revision: http://reviews.llvm.org/D20647 llvm-svn: 273440
2016-06-21Invoke PruneEH pass before Sample Profile pass.Dehao Chen1-0/+1
Summary: We need to call PruneEH pass before AutoFDO pass so that some EH-related calls can get inlined in Sample Profile pass. Reviewers: davidxl, dnovillo Subscribers: junbuml, llvm-commits Differential Revision: http://reviews.llvm.org/D21197 llvm-svn: 273298
2016-06-02[asan] Added -fsanitize-address-use-after-scope flagVitaly Buka1-4/+7
Summary: Also emit lifetime markers for -fsanitize-address-use-after-scope. Asan uses life-time markers for use-after-scope check. PR27453 Reviewers: kcc, eugenis, aizatsky Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20759 llvm-svn: 271451
2016-05-29Handle -Wa,--mrelax-relocations=[no|yes].Rafael Espindola1-0/+1
llvm-svn: 271162
2016-05-27Add instcombine pass if sampleprofile pass is enabled.Dehao Chen1-2/+10
Summary: Sample profile pass need to have instcombine pass. A related change is http://reviews.llvm.org/D17742. But we should not explicitly add dependency between to non-analysis passes. So we add the dependency here. Reviewers: davidxl, dnovillo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20502 llvm-svn: 271010
2016-05-25[esan|wset] Add working set tool driver flagsDerek Bruening1-0/+2
Summary: Adds a new -fsanitize=efficiency-working-set flag to enable esan's working set tool. Adds appropriate tests for the new flag. Reviewers: aizatsky Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits Differential Revision: http://reviews.llvm.org/D20484 llvm-svn: 270641
2016-05-24CodeGen: indicate to the backend the exception modelSaleem Abdulrasool1-0/+3
Thread through -fsjlj-exceptions to the backend via the TargetOptions. This is in preparation for supporting SjLj exceptions on x86 (e.g. for MinGW). llvm-svn: 270528
2016-05-20CodeGen: address -Wcast-qual warningSaleem Abdulrasool1-1/+1
Add a const_cast rather than the C-style cast. NFC. llvm-svn: 270180
2016-05-18Update for llvm change.Rafael Espindola1-1/+1
llvm-svn: 269989
2016-05-16Change embed-bitcode linkage typeSteven Wu1-22/+51
Embedded bitcode should have private linkage instead of appending or external. Otherwise, it will cause link failure due to duplicated symbols. Also add llvm.embedded.module and llvm.cmdline to llvm.compiler.used so they don't get optimized out. rdar://problem/21555860 llvm-svn: 269679
2016-05-11Fixed msvc warningsSimon Pilgrim1-0/+2
llvm-svn: 269242
2016-05-11Embed bitcode in object file (clang cc1 part)Steven Wu1-0/+90
Summary: Teach clang to embed bitcode inside bitcode. When -fembed-bitcode cc1 option is used, clang will embed both the input bitcode and cc1 commandline into the bitcode in special sections before compiling to the object file. Using -fembed-bitcode-marker will only introduce a marker in both sections. Depends on D17390 Reviewers: rsmith Subscribers: yaron.keren, vsk, cfe-commits Differential Revision: http://reviews.llvm.org/D17392 llvm-svn: 269202
2016-04-29Delete store to Target option PositionIndependentExecutable as PIE is now ↵Sriraman Tallam1-1/+0
set in module flags. Differential Revision: http://reviews.llvm.org/D19749 llvm-svn: 268137
2016-04-27Call TargetMachine::addEarlyAsPossiblePasses from BackendUtil.Justin Lebar1-0/+8
Summary: As of D18614, TargetMachine exposes a hook to add a set of passes that should be run as early as possible. Invoke this hook from clang when setting up the pass manager. Reviewers: chandlerc Subscribers: rnk, cfe-commits, tra Differential Revision: http://reviews.llvm.org/D18617 llvm-svn: 267764
2016-04-21[esan] EfficiencySanitizer driver flagsDerek Bruening1-0/+18
Summary: Adds a framework to enable the instrumentation pass for the new EfficiencySanitizer ("esan") family of tools. Adds a flag for esan's cache fragmentation tool via -fsanitize=efficiency-cache-frag. Adds appropriate tests for the new flag. Reviewers: eugenis, vitalybuka, aizatsky, filcab Subscribers: filcab, kubabrecka, llvm-commits, zhaoqin, kcc Differential Revision: http://reviews.llvm.org/D19169 llvm-svn: 267059
2016-04-18Update InstrProf pass creator API referenceXinliang David Li1-1/+1
llvm-svn: 266638
2016-04-12Pass -backend-option to LLVM when there is no target machine.Yaxun Liu1-16/+23
Clang should pass -backend-option to LLVM even though there is no target machine, since LLVM passes are used when emitting LLVM IR. Differential Revision: http://reviews.llvm.org/D17552 llvm-svn: 266117
2016-04-11Emit the module hash by default with -flto=thin.Mehdi Amini1-1/+2
Reviewers: tejohnson Subscribers: joker.eph, cfe-commits Differential Revision: http://reviews.llvm.org/D18947 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265977
2016-04-08Move EABIVersion from CodeGenOptions to TargetOptionsSaleem Abdulrasool1-1/+1
It is possible to argue that the EABIVersion field is similar in spirit to the ABI field in TargetOptions. It represents the embedded ABI that the target follows. This will allow us to thread this information into the target information construction. llvm-svn: 265807
2016-04-08revert SVN r265702, r265640Saleem Abdulrasool1-2/+2
Revert the two changes to thread CodeGenOptions into the TargetInfo allocation and to fix the layering violation by moving CodeGenOptions into Basic. Code Generation is arguably not particularly "basic". This addresses Richard's post-commit review comments. This change purely does the mechanical revert and will be followed up with an alternate approach to thread the desired information into TargetInfo. llvm-svn: 265806
2016-04-07Basic: move CodeGenOptions from FrontendSaleem Abdulrasool1-2/+2
This is a mechanical move of CodeGenOptions from libFrontend to libBasic. This fixes the layering violation introduced earlier by threading CodeGenOptions into TargetInfo. It should also fix the modules based self-hosting builds. NFC. llvm-svn: 265702
2016-03-15[ThinLTO] Clang side of renaming of function index (NFC)Teresa Johnson1-18/+18
This is the companion to an LLVM patch that renamed the function index data structures and files to use the more general module summary index. (Recommit after fixing LLVM side to add back missed file) llvm-svn: 263514
2016-03-14Revert "[ThinLTO] Clang side of renaming of function index (NFC)"Teresa Johnson1-18/+18
This reverts commit r263491. Missed a file on the LLVM side. llvm-svn: 263494
2016-03-14[ThinLTO] Clang side of renaming of function index (NFC)Teresa Johnson1-18/+18
This is the companion to an LLVM patch that renamed the function index data structures and files to use the more general module summary index. llvm-svn: 263491
2016-03-11Update to include the new header file providing createGVNPass.Chandler Carruth1-0/+1
llvm-svn: 263210
2016-03-04Make TargetInfo store an actual DataLayout instead of a string.James Y Knight1-6/+6
Use it to calculate UserLabelPrefix, instead of specifying it (often incorrectly). Note that the *actual* user label prefix has always come from the DataLayout, and is handled within LLVM. The main thing clang's TargetInfo::UserLabelPrefix did was to set the #define value. Having these be different from each-other is just silly. Differential Revision: http://reviews.llvm.org/D17183 llvm-svn: 262737
2016-03-02[PGO] Change profile use cc1 option to handle IR level profilesRong Xu1-0/+2
This patch changes cc1 option for PGO profile use from -fprofile-instr-use=<path> to -fprofile-instrument-use-path=<path>. -fprofile-instr-use=<path> is now a driver only option. In addition to decouple the cc1 option from the driver level option, this patch also enables IR level profile use. cc1 option handling now reads the profile header and sets CodeGenOpt ProfileUse (valid values are {None, Clang, LLVM} -- this is a common enum for -fprofile-instrument={}, for the profile instrumentation), and invoke the pipeline to enable the respective PGO use pass. Reviewers: silvas, davidxl Differential Revision: http://reviews.llvm.org/D17737 llvm-svn: 262515
2016-02-29[PGO] clang cc1 option change to enable IR level instrumentationRong Xu1-0/+6
This patch expands cc1 option -fprofile-instrument= with a new value: -fprofile-instrument=llvm which enables IR level PGO instrumentation. Reviewers: davidxl, silvas Differential Revision: http://reviews.llvm.org/D17622 llvm-svn: 262239
2016-02-17[sanitizer-coverage] implement -fsanitize-coverage=trace-pc. This is similar ↵Kostya Serebryany1-0/+1
to trace-bb, but has a different API. We already use the equivalent flag in GCC for Linux kernel fuzzing. We may be able to use this flag with AFL too llvm-svn: 261159
2016-02-17Teach clang to use the ThinLTO pipelineMehdi Amini1-1/+2
Summary: Use the new pipeline implemented in D17115 Reviewers: tejohnson Subscribers: joker.eph, cfe-commits Differential Revision: http://reviews.llvm.org/D17272 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 261045
2016-02-05Eliminate an unnecessary enum, use the LLVM version. NFCPaul Robinson1-13/+1
llvm-svn: 259950
2016-02-04[PGO] cc1 option name change for profile instrumentationRong Xu1-1/+1
This patch changes cc1 option -fprofile-instr-generate to an enum option -fprofile-instrument={clang|none}. It also changes cc1 options -fprofile-instr-generate= to -fprofile-instrument-path=. The driver level option -fprofile-instr-generate and -fprofile-instr-generate= remain intact. This change will pave the way to integrate new PGO instrumentation in IR level. Review: http://reviews.llvm.org/D16730 llvm-svn: 259811
2016-02-02Move DebugInfoKind into its own header to cut the cyclic dependency edge ↵Benjamin Kramer1-1/+1
from Driver to Frontend. llvm-svn: 259489
2016-01-08[ThinLTO] Leverage new in-place renaming supportTeresa Johnson1-16/+33
Due to the new in-place renaming support added in r257174, we no longer need to invoke ThinLTO global renaming from clang. It will be invoked on the module in the FunctionImport pass (by an immediately following llvm commit). As a result, we don't need to load the FunctionInfoIndex as early, so that is moved down into EmitAssemblyHelper::EmitAssembly. llvm-svn: 257179
2016-01-06[Driver] Add support for -fno-builtin-foo options.Chad Rosier1-0/+7
Addresses PR4941 and rdar://6756912. http://reviews.llvm.org/D15195 llvm-svn: 256937
2015-12-21[clang-cl] Add support for /BreproDavid Majnemer1-0/+2
The /Brepro flag controls whether or not the compiler should embed timestamps into the object file. Object files which do not embed timestamps are not suitable for incremental linking but are suitable for hermetic build systems and staged self-hosts of clang. A normal clang spelling of this flag has been added, -mincremental-linker-compatible. llvm-svn: 256204
2015-12-19Recommit CC1 part of debugger tuning; pass through setting from driver to LLVM.Paul Robinson1-0/+13
Reapplies r256063, except instead of frugally re-using an LLVM enum, we define a Clang enum, to avoid exposing too much LLVM interface. Differential Revision: http://reviews.llvm.org/D15650 llvm-svn: 256078
2015-12-19Revert r256063, it's killing clang-tools-extraPaul Robinson1-1/+0
llvm-svn: 256066